2024-12-28 22:13:21 +01:00
# About
2024-12-29 03:32:38 +01:00
This is a simple and easy to use C++ build system for Linux designed for use with C++20 modules in mind, it uses JSON based project files.
2024-12-28 22:13:21 +01:00
# Install
## Prerequisites:
```
2025-02-03 22:18:56 +01:00
lld
2024-12-28 22:13:21 +01:00
clang 18>
git
2025-06-10 00:10:48 +02:00
libpqxx
onetbb
boost
glslang
2024-12-28 22:13:21 +01:00
```
2025-02-03 22:18:56 +01:00
## Build from source
2024-12-28 22:13:21 +01:00
```bash
2024-12-30 22:08:31 +01:00
git clone https://github.com/Catcrafts/Crafter.Build.git
2024-12-28 22:13:21 +01:00
cd Crafter.Build
./build.sh
```
(optionally add to path)
# How to use
## Quickstart
2024-12-29 20:20:06 +01:00
create a ``project.json` ` in an empty folder, open it in your preferred text editor.
2024-12-28 22:13:21 +01:00
Create a basic project file, with a base configuration and debug and release configuration
```JSON
{
"name": "hello-world",
"configurations": [
{
"name": "base",
"standard": "c++26",
"source_files": ["main"],
"module_files": [],
"build_dir": "./build",
"output_dir": "./bin"
},
{
"name": "debug",
"extends": ["base"],
"optimization_level": "0"
}
{
"name": "release",
"extends": ["base"],
"optimization_level": "3"
}
]
}
```
Save and close the file, create a ``main.cpp` `
```cpp
#include <print>
int main() {
std::println("Hello World!");
}
```
2024-12-29 01:38:25 +01:00
Save and close, then run ``crafter-build -c debug` `. Now you can run the ` `hello-world` ` executable that has appeared in the ` `bin` ` folder
2024-12-28 22:13:21 +01:00
## CLI arguments
2024-12-29 03:13:14 +01:00
``--help` ` Displays a help message.
2024-12-28 22:13:21 +01:00
2024-12-29 00:51:02 +01:00
``-c` ` The name of the configuration to build.
2024-12-29 17:54:57 +01:00
``-p` ` The path to the project file, defaults to ` `project.json` `.
2024-12-28 22:13:21 +01:00
2024-12-29 00:51:02 +01:00
``-o` ` Overrides the output folder.
2024-12-28 22:13:21 +01:00
2025-02-03 22:06:54 +01:00
``-r` ` Runs the executable after building.
2024-12-29 03:13:14 +01:00
## configuration properties
``name` ` Name of the configuration.
2025-02-03 22:06:54 +01:00
``standard` ` C++ standard that this configuration uses, please refer to the [relevant clang documentation](https://clang.llvm.org/cxx_status.html), defaults to ` `c++26` `.
2024-12-29 03:13:14 +01:00
``source_files` ` All source files of the project ` `.cpp` ` extension is assumed.
``module_files` ` All C++ 20 module files of the project ` `.cppm` ` extension is assumed.
2025-01-02 02:53:39 +01:00
``additional_files` ` Files that will be copied to the output_dir.
2024-12-29 03:13:14 +01:00
``build_dir` ` The directory where intermediate files are stored.
``output_dir` ` The directory where the output files will be placed.
2025-02-03 22:11:27 +01:00
``type` ` The type of the project: ` `executable` `, ` `library` `, ` `shared-library` `, defaults to ` `executable` `.
2025-02-03 22:06:54 +01:00
2024-12-29 03:13:14 +01:00
``extends` ` An array of configuration names that this configuration extends, later elements in the array take priority over previous ones.
2025-02-03 22:06:54 +01:00
``optimization_level` ` Please refer to the [relevant clang documentation](https://clang.llvm.org/docs/CommandGuide/clang.html#code-generation-options), defaults to ` `0` `.
2024-12-29 03:13:14 +01:00
2024-12-29 20:16:53 +01:00
``dependencies` ` An object array of the dependencies of this project, example:
```json
2024-12-29 20:17:19 +01:00
"dependencies": [
2024-12-29 20:16:53 +01:00
{
"path":"/home/Crafter.Build/project.json",
2025-03-29 22:39:08 +01:00
"configuration":"debug-lib",
"commit":"af7eb61c3d92ab18f6aa6c139ac7211a908a24ee"
2024-12-29 20:16:53 +01:00
}
2025-02-03 22:06:54 +01:00
{
"path":"https://github.com/Catcrafts/Crafter.Build.git",
2025-03-29 22:39:08 +01:00
"configuration":"debug-lib",
"branch":"master"
2025-02-03 22:06:54 +01:00
}
2024-12-29 20:16:53 +01:00
]
```
2025-03-29 22:39:08 +01:00
This will now link the library of Crafter.Build in the configuration you use this in. ``commit` ` and ` `branch` ` are optional parameters, if omitted the latest commit on the default branch is used.
2024-12-29 20:16:53 +01:00
2024-12-29 03:13:14 +01:00
``target` ` Clang triplet this configuration uses, please refer to the [relevant clang documentation ](https://clang.llvm.org/docs/CrossCompilation.html#target-triple ).
2024-12-29 03:30:22 +01:00
Note: the WASI SDK needs to be installed to compile to webassmbly, and ``$WASI_SDK_PATH` ` needs to be set, please refer to the [wasi-sdk installation guide ](https://github.com/WebAssembly/wasi-sdk?tab=readme-ov-file#install ).