A cross-platform declarative and scriptable (WIP) build system for c++ with the addition of letting you run any c++ files as a script, just like python!
- Any C++ compiler. The default user config only has g++ and msvc profiles. But feel free to add other compilers.
You can either build from source or use the binary release
To build from source:
- Clone the repository with
git clone --recursive https://github.com/Neko-Box-Coder/runcpp2.git - Run
Build.shorBuild.batto build
Binary Release (Only Linux and Windows for now): https://github.com/Neko-Box-Coder/runcpp2/releases
Finally, you just need to add runcpp2 binary location to the PATH environment variable and
you can run c++ files anywhere you want.
Suppose you have a c++ file called script.cpp, you can run it immediately by doing
runcpp2 ./script.cpp <any arguments>Note
On Unix, if you have added runcpp2 to your PATH and add this line //bin/true;runcpp2 "$0" "$@"; exit; to the top of your script, you can run the script directly by ./script.cpp <arguments>
If you want to edit the script but want to have feedback for any error, you can use "watch" mode.
runcpp2 --watch ./script.cppIf you want to add custom build settings such as compile/link flags, specify profile, etc. You will need to provide such settings to runcpp2 in the format of YAML.
This build settings can either be embedded as comment in the script itself, or provided as a YAML file.
To generate a script build settings template, do
# Embeds the build settings template as comment
runcpp2 --create-script-template ./script.cpp
# Creates the build settings template as dedicated yaml file
runcpp2 --create-script-template ./script.yaml
# Short form
runcpp2 -t ./script.cppThis will generate the script build settings template for you. Everything is documented as comment in the template but here's a quick summary.
RequiredProfiles: To specify a specific profile for building for different platformsOverrideCompileFlags: Compile flags to be added or removed from the current profileOverrideLinkFlags: Same asOverrideCompileFlagsbut for linkingOtherFilesToBeCompiled: Other source files you wish to be compiled.Dependencies: Any external libraries you wish to use. See next section.
Note
Settings in the script info are passed directly to the shell. Be cautious when using user-provided input in your build commands.
To use any external libraries, you need to specify them in the Dependencies section. Here's a quick run down on the important fields
Source: This specifies the source of the external dependency. It can either be typeGitorLocalwhere it will clone the repository if it isGitor copy the library folder in the filesystem if it isLocalLibraryType: This specifies the dependency type to be eitherStatic,Object,SharedorHeaderIncludePaths: The include paths relative to the root of the dependency folderLinkProperties: Settings for linkingSetup,BuildandCleanup: List of shell commands for one time setup, building and cleaning up
To access the source files of the dependencies, you can specify runcpp2 to build locally in
the current working directory by passing the --local flag. This is useful when you want to
look at the headers of the dependencies.
runcpp2 --local ./script.cppThis will create a .runcpp2 folder in the current working directory, and all the builds and dependencies will be inside it.
