ctrl+shift+p filters: :st2 :st3 :win :osx :linux
Browse

Cpp​Builder

by Sharlock93 ALL

A simple plugin to make Makefiles, and an initial testing of how to make plugins for sublime Text

Details

Installs

  • Total 9K
  • Win 5K
  • Mac 1K
  • Linux 3K
Apr 23 Apr 22 Apr 21 Apr 20 Apr 19 Apr 18 Apr 17 Apr 16 Apr 15 Apr 14 Apr 13 Apr 12 Apr 11 Apr 10 Apr 9 Apr 8 Apr 7 Apr 6 Apr 5 Apr 4 Apr 3 Apr 2 Apr 1 Mar 31 Mar 30 Mar 29 Mar 28 Mar 27 Mar 26 Mar 25 Mar 24 Mar 23 Mar 22 Mar 21 Mar 20 Mar 19 Mar 18 Mar 17 Mar 16 Mar 15 Mar 14 Mar 13 Mar 12 Mar 11 Mar 10
Windows 1 0 1 0 0 0 1 0 1 1 1 0 0 1 0 3 1 0 1 0 0 0 0 0 1 0 0 0 1 0 2 2 1 2 1 0 0 0 0 0 0 0 0 0 0
Mac 0 0 0 0 0 1 0 0 0 1 1 0 1 0 0 0 0 0 0 0 0 0 0 1 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
Linux 1 0 0 0 0 0 0 0 1 0 0 0 0 2 0 0 0 0 0 0 1 1 1 0 1 0 0 0 1 0 0 1 1 0 0 1 0 0 0 0 1 0 0 2 0

Readme

Source
raw.​githubusercontent.​com

Note: as a university student, work on this project will be slow, sorry.

Welcome

This is my fist plugin so there might be bugs :) I have only tested this one windows thus far, Linux and Mac come later.

This is a simple plugin that will generate a project folder for you, and will also generate a Makefile to use with GNU Make. It can also Run your project.

This meant as a very simple project management system, there are bugs, and it can only handle one generated binary file. (Does that even make sense?!)

Install

  1. Use Package Control
    • Search for CppBuilder
  2. or git clone the repo, and copy it to Packages/CppBuilder

Use

Ctrl+Alt+M
While a C++ file is open will run the command on windows, Haven't tested it on Mac or Linux yet… the command will make a Makefile in the same directory of the C++ file. Note: so far I can only compile and run while in a project, i will add single file compile and run some other time.

Project

goto Project > C++ Builder > New C++ Project to create a new project, an Input panel will come up and you can type in the name of your project, Then it will make the list of folders (build, header, obj, src), it will prompt you to agree for each folder, just click Yes to all of them. (This might be removed later.)

Keys (While new project is open)
  1. Ctrl+Alt+N : Generate Makefile (There must be at least one cpp file in your src folder).
  2. Ctrl+Alt+Z : Build the Project (This will just run make in the folder).
  3. Ctrl+Alt+C : Build & Run Project (No Input) (Running the project assuming there is no input required from the keyboard, useful for simple stuff).
  4. Ctrl+Alt+X : Build & Run (Console) (Running the project assuming it requires input, the output from the program is not captured by Sublime text, the Console window will pause).
  5. Ctrl+Alt+V : Clean Project (Will run make clean).
settings

You have some options that you can change, either per project (I will explain down below) or for single files:

If you change the settings in project.sublime-project file, then the settings only apply to that project only, however if you change the CppBuilder.sublime-settings, the changes apply to every file. i.e: a file outside a project.

Note: please set the workspace setting before anything else, this is required, for the New C++ Project command to work.

Note: For Linux you must also set terminal_emu and terminal_opts for your own linux distro

These are the basic settings you can change:

//per project settings (can also be set to apply to every file)

    //library directories (prefixed by -L in Makefile)
    "lib_dir": [
    "path/to/some/lib/folder",
    "path/to/someother/lib/folder"
    ],

    //library names used in your project, ORDER matters
    //(prefixed with -l in the makefile)
    "lib_names": [
    "somelibname",
    "anotherlibname"
    ],

    //header directory, .h/hpp files
    //(for projects this is set to the header folder created with the 
    //New C++ project command, so put your headers there if using a project)
    "include_dir": [
    "path/to/header",
    "path/another/header"
    ],

    //where to get the .cpp files
    //(set to src when in a project)
    "src_dir": "",

    //output folders
    //the name of the file to generate (the final executable )
    //(for project named after the project)
    "main_file": "",

    //where to put the intermediate .o files
    //this is to make sure we don't recompile everything from scratch
    //if not needed
    //(set to obj folder while in project)
    "obj_dir": "",

    //where to build the final executable
    //by default is in the same folder for a single .CPP file
    //(for project set to the build folder)
    "build_dir": "",


    //compiler
    "cc": "g++",

    //what to remove, example 'obj\*.o'
    //this just a simple way to clean up, you can add
    //more as required, remember, only supply what to delete
    //the delete command is added internally based on platform
    "clean" : [], 

//============================================================

//Linux Specific options:

    //command that opens a new terminal
    "terminal_emu":"x-terminal-emulator",
    "terminal_opts": [
        "-x"
    ],

//============================================================

    //additional flags for the compiler
    "additional_flags": [
        "Wall",
        "std=gnu++11",
        "D__USE_MINGW_ANSI_STDIO=1"
    ],

    //Default Project Settings
    //this should only be set by using CppBuilder.sublime-settings
    //this is where all your Projects are made
    //SET THIS or the plugin will not work, or it can even mess up stuff
    "workspace_dir":""

Goals

  • Running the Project after compiling. (Done)
  • Building & Running a single C++ file. (New)
  • Just getting peole to use it and work out any bugs found ;)

Update History

  • v 0.2.3 (New)
    • Now should support Linux.
    • Removed a few commands and Keyboard shortcuts as the where not required.

Update History

  • v 0.2.00 (Old)

    • Added Project Creation.
    • Added Project Building.
    • Added Project Execution.
    • This could be the first version that has some uses. :D ( I will build it as I go along)
  • v 0.0.11

    • lost local git folder, rebuild from scratch
    • added folder management.
  • v 0.0.8

    • Added a simple message test when installing package.
    • Added an option to make a folder for the object files.
    • fixed some bugs.
    • should be able to make simple makefiles without errors.
  • v 0.0.4

    • Added a Default main_file name if one is not give. (output.exe on windows, ouput.out on others)
    • removed some code, and it looks cleaner now.
    • Tested on Mac & Linux…working but fine.