Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ Resources/embed.exe

# Natural Docs cache data
DocsGeneration/ND_Config/Working\ Data
docs/
# docs/

# Language server files
.cache/
Expand Down
2 changes: 1 addition & 1 deletion DefaultYAMLs/DefaultScriptInfo.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -141,7 +141,7 @@ Dependencies:
# (Optional) Import dependency configuration from a YAML file if this field exists
# All other fields (Name, Platforms, etc...) are not needed if this field exists
# For Git source: Path is relative to the git repository root
# For Local source: Path is relative to the script directory.
# For Local source: Path is relative to the path specified under `Local`
# If neither source exists, local source with root script directory is assumed.
ImportPath: "config/dependency.yaml"

Expand Down
100 changes: 38 additions & 62 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,99 +1,75 @@
# runcpp2

![runcpp2 logo](./Runcpp2Logo.png)
![](./Runcpp2Logo.png)

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!
runcpp2 is a simple declarable, scriptable, flexible cross-platform build system build system for c or c++

### 🛠️ Prerequisites
- Any C++ compiler. The default user config only has g++ and msvc profiles. But feel free to
- 🚀 **Simple**: `runcpp2 main.cpp`, this is all you need to get started
- 📝 **Declarable**: *Quick, Concise, Minimal* YAML format
- 🔧 **Scriptable**: *Customize, Run And Debug* your build pipeline with c++, or just use it as a script.
No longer need to juggle between CMake, Python, Bash, Batch, Lua, etc...
- 🪜 **Flexible**: *YAML* for small project, *c++* for finer control

For more information, see [Full Documentation](https://neko-box-coder.github.io/runcpp2/latest/)

## 🛠️ Prerequisites
- Any c or c++ compiler. The default user config only has g++ and msvc profiles. But feel free to
add other compilers.

### 📥️ Installation
## 📥️ 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](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
## ⚡️ Getting Started

#### 1. Running directly
### 1. Running source file directly
Suppose you have a c++ file called `script.cpp`, you can run it immediately by doing

> *shell*
```shell
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>`
> 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
---

### 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.

> *shell*
```shell
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
### 3. Sepcifying Build Settings
Build settings such as compile/link flags, external dependencies, command hooks, etc.
can be spcified inlined inside a source file or as a separate yaml file in the format of YAML

```shell
# 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
```
- To specify build settings in a dedicated yaml file:
- The yaml file in the same directory and share the same as the source file being run will be used
- To specify inline build settings inside a source file:
- Put them inside a comment with `runcpp2` at the beginning of the build settings
- The inline build settings can exist in anywhere of the source file
- Both inline (but continuous) comments (`//`) and block comments are supported (`/* */`)

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

> *shell*
```shell
runcpp2 --local ./script.cpp
runcpp2 --create-script-template ./script.cpp # Embeds the build settings template as comment
runcpp2 --create-script-template ./script.yaml # Creates the build settings template as dedicated yaml file
runcpp2 -t ./script.cpp # Short form
```

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

8 changes: 7 additions & 1 deletion TODO.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,9 @@
TODO:
- Allow runcpp2 to be library
- Add the ability to specify different profiles for different source files
- Add the ability to specify different profiles(?)/defines for different source files
- Add the ability to use symlinks for local dependency
- Add the ability to append defines coming from the dependencies
- Add the ability for user to specify custom substitution options which applies to all fields
- Ability to compile runcpp2 as single cpp
- Ability to skip DefaultPlatform and DefaultProfile
- Async compile
Expand All @@ -26,3 +29,6 @@ TODO:
- Add version for user config and prompt for update
- Output compile_command.json
- Allow Languages to override FileExtensions in compiler profile (?)



Binary file added mkdocs/docs/Runcpp2Logo.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading