Skip to content

Latest commit

 

History

History
99 lines (70 loc) · 3.79 KB

README.md

File metadata and controls

99 lines (70 loc) · 3.79 KB

runcpp2

runcpp2 logo

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!

🛠️ Prerequisites

  • Any C++ compiler. The default user config only has g++ and msvc profiles. But feel free to add other compilers.

📥️ Installation

You can either build from source or use the binary release

To build from source:

  1. Clone the repository with git clone --recursive https://github.com/Neko-Box-Coder/runcpp2.git
  2. Run Build.sh or Build.bat to 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.

⚡️ Getting Started

1. Running directly

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>

2. Watch and give compile errors

If you want to edit the script but want to have feedback for any error, you can use "watch" mode.

runcpp2 --watch ./script.cpp

3. Adding script build settings

If 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.cpp

This 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 platforms
  • OverrideCompileFlags: Compile flags to be added or removed from the current profile
  • OverrideLinkFlags: Same as OverrideCompileFlags but for linking
  • OtherFilesToBeCompiled: 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.

4. Using External Libraries

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 type Git or Local where it will clone the repository if it is Git or copy the library folder in the filesystem if it is Local
  • LibraryType: This specifies the dependency type to be either Static, Object, Shared or Header
  • IncludePaths: The include paths relative to the root of the dependency folder
  • LinkProperties: Settings for linking
  • Setup, Build and Cleanup: 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.cpp

This will create a .runcpp2 folder in the current working directory, and all the builds and dependencies will be inside it.