|
1 | 1 | # runcpp2 |
2 | 2 |
|
3 | | - |
| 3 | + |
4 | 4 |
|
5 | | -A cross-platform declarative <s>and scriptable (WIP)</s> build system for c++ with the addition of letting you run any c++ files as a script, just like python! |
| 5 | +runcpp2 is a simple declarable, scriptable, flexible cross-platform build system build system for c or c++ |
6 | 6 |
|
7 | | -### 🛠️ Prerequisites |
8 | | -- Any C++ compiler. The default user config only has g++ and msvc profiles. But feel free to |
| 7 | +- 🚀 **Simple**: `runcpp2 main.cpp`, this is all you need to get started |
| 8 | +- 📝 **Declarable**: *Quick, Concise, Minimal* YAML format |
| 9 | +- 🔧 **Scriptable**: *Customize, Run And Debug* your build pipeline with c++, or just use it as a script. |
| 10 | + No longer need to juggle between CMake, Python, Bash, Batch, Lua, etc... |
| 11 | +- 🪜 **Flexible**: *YAML* for small project, *c++* for finer control |
| 12 | + |
| 13 | +For more information, see [Full Documentation](https://neko-box-coder.github.io/runcpp2/latest/) |
| 14 | + |
| 15 | +## 🛠️ Prerequisites |
| 16 | +- Any c or c++ compiler. The default user config only has g++ and msvc profiles. But feel free to |
9 | 17 | add other compilers. |
10 | 18 |
|
11 | | -### 📥️ Installation |
| 19 | +## 📥️ Installation |
12 | 20 | You can either build from source or use the binary release |
13 | 21 |
|
14 | | -To build from source: |
15 | | -1. Clone the repository with `git clone --recursive https://github.com/Neko-Box-Coder/runcpp2.git` |
16 | | -2. Run `Build.sh` or `Build.bat` to build |
17 | | - |
18 | 22 | Binary Release (Only Linux and Windows for now): |
19 | 23 | [https://github.com/Neko-Box-Coder/runcpp2/releases](https://github.com/Neko-Box-Coder/runcpp2/releases) |
20 | 24 |
|
21 | 25 |
|
22 | 26 | Finally, you just need to add runcpp2 binary location to the `PATH` environment variable and |
23 | 27 | you can run c++ files anywhere you want. |
24 | 28 |
|
25 | | -### ⚡️ Getting Started |
| 29 | +## ⚡️ Getting Started |
26 | 30 |
|
27 | | -#### 1. Running directly |
| 31 | +### 1. Running source file directly |
28 | 32 | Suppose you have a c++ file called `script.cpp`, you can run it immediately by doing |
29 | 33 |
|
| 34 | +> *shell* |
30 | 35 | ```shell |
31 | 36 | runcpp2 ./script.cpp <any arguments> |
32 | 37 | ``` |
33 | 38 |
|
34 | 39 | > [!NOTE] |
35 | | -> 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>` |
| 40 | +> On Unix, if you have added runcpp2 to your PATH and add this line `//bin/true;runcpp2 "$0" "$@"; exit $?;` |
| 41 | +> to the top of your script, you can run the script directly by `./script.cpp <arguments>` |
36 | 42 |
|
37 | | -#### 2. Watch and give compile errors |
| 43 | +--- |
| 44 | + |
| 45 | +### 2. Watch and give compile errors |
38 | 46 | If you want to edit the script but want to have feedback for any error, you can use "watch" mode. |
39 | 47 |
|
| 48 | +> *shell* |
40 | 49 | ```shell |
41 | 50 | runcpp2 --watch ./script.cpp |
42 | 51 | ``` |
43 | 52 |
|
44 | | -#### 3. Adding script build settings |
45 | | -If you want to add custom build settings such as compile/link flags, specify profile, etc. |
46 | | -You will need to provide such settings to runcpp2 in the format of YAML. |
47 | | - |
48 | | -This build settings can either be embedded as comment in the script itself, or provided as |
49 | | -a YAML file. |
| 53 | +--- |
50 | 54 |
|
51 | | -To generate a script build settings template, do |
| 55 | +### 3. Sepcifying Build Settings |
| 56 | +Build settings such as compile/link flags, external dependencies, command hooks, etc. |
| 57 | +can be spcified inlined inside a source file or as a separate yaml file in the format of YAML |
52 | 58 |
|
53 | | -```shell |
54 | | -# Embeds the build settings template as comment |
55 | | -runcpp2 --create-script-template ./script.cpp |
56 | | - |
57 | | -# Creates the build settings template as dedicated yaml file |
58 | | -runcpp2 --create-script-template ./script.yaml |
59 | | - |
60 | | -# Short form |
61 | | -runcpp2 -t ./script.cpp |
62 | | -``` |
| 59 | +- To specify build settings in a dedicated yaml file: |
| 60 | + - The yaml file in the same directory and share the same as the source file being run will be used |
| 61 | +- To specify inline build settings inside a source file: |
| 62 | + - Put them inside a comment with `runcpp2` at the beginning of the build settings |
| 63 | + - The inline build settings can exist in anywhere of the source file |
| 64 | + - Both inline (but continuous) comments (`//`) and block comments are supported (`/* */`) |
63 | 65 |
|
64 | | -This will generate the script build settings template for you. |
65 | | -Everything is documented as comment in the template but here's a quick summary. |
66 | | - |
67 | | -- `RequiredProfiles`: To specify a specific profile for building for different platforms |
68 | | -- `OverrideCompileFlags`: Compile flags to be added or removed from the current profile |
69 | | -- `OverrideLinkFlags`: Same as `OverrideCompileFlags` but for linking |
70 | | -- `OtherFilesToBeCompiled`: Other source files you wish to be compiled. |
71 | | -- `Dependencies`: Any external libraries you wish to use. See next section. |
72 | | - |
73 | | -> [!NOTE] |
74 | | -> Settings in the script info are passed directly to the shell. Be cautious when using user-provided input in your build commands. |
75 | | -
|
76 | | -#### 4. Using External Libraries |
77 | | - |
78 | | -To use any external libraries, you need to specify them in the Dependencies section. |
79 | | -Here's a quick run down on the important fields |
80 | | - |
81 | | -- `Source`: This specifies the source of the external dependency. |
82 | | -It can either be type `Git` or `Local` where it will clone the repository if it is `Git` or |
83 | | -copy the library folder in the filesystem if it is `Local` |
84 | | -- `LibraryType`: This specifies the dependency type to be either `Static`, `Object`, `Shared` |
85 | | -or `Header` |
86 | | -- `IncludePaths`: The include paths relative to the root of the dependency folder |
87 | | -- `LinkProperties`: Settings for linking |
88 | | -- `Setup`, `Build` and `Cleanup`: List of shell commands for one time setup, building and |
89 | | -cleaning up |
90 | | - |
91 | | -To access the source files of the dependencies, you can specify runcpp2 to build locally in |
92 | | -the current working directory by passing the `--local` flag. This is useful when you want to |
93 | | -look at the headers of the dependencies. |
| 66 | +For a complete list of build settings, see [Build Settings](https://neko-box-coder.github.io/runcpp2/latest/build_settings/) or generate the template with |
94 | 67 |
|
| 68 | +> *shell* |
95 | 69 | ```shell |
96 | | -runcpp2 --local ./script.cpp |
| 70 | +runcpp2 --create-script-template ./script.cpp # Embeds the build settings template as comment |
| 71 | +runcpp2 --create-script-template ./script.yaml # Creates the build settings template as dedicated yaml file |
| 72 | +runcpp2 -t ./script.cpp # Short form |
97 | 73 | ``` |
98 | 74 |
|
99 | | -This will create a `.runcpp2` folder in the current working directory, and all the builds and dependencies will be inside it. |
| 75 | + |
0 commit comments