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

Cpp​Builder

by Sharlock93 ST2/ST3

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

Details

Installs

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

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.