|
1 | | -# nimbus |
2 | | -Nimbus is a modern, lightweight build system and package manager for C++. |
| 1 | +# Nimbus: A Modern C++ Build System and Package Manager |
| 2 | + |
| 3 | +**Nimbus** is a lightweight and modern C++ build system and package manager designed to streamline your C++ development workflow. With a simple command-line interface, easy configuration through `nimbus.toml`, and intelligent handling of build options, Nimbus helps you focus on writing code rather than wrestling with build files. |
| 4 | + |
| 5 | +## Features |
| 6 | + |
| 7 | +- **Initialize New Projects:** Quickly set up a new C++ project with sensible defaults using `nimbus init`. It automatically creates a source and include directory, generates a `nimbus.toml` configuration file. |
| 8 | + |
| 9 | +- **Build with Ease:** Compile your project using `nimbus build`. Nimbus leverages your compiler of choice and the settings defined in `nimbus.toml` to create an optimized or debug-friendly binary, depending on your specified build type. |
| 10 | + |
| 11 | +- **Intelligent Build Types:** Select from various build types such as `Debug`, `Release`, `RelWithDebInfo`, or `MinSizeRel`. Nimbus automatically applies the corresponding compiler flags and **preprocessor macros** (e.g., `DEBUG`, `RELEASE`, `RELWITHDEBINFO`, `MINSIZEREL`) at compile time, enabling or disabling certain debugging features, optimization levels, or size-reduction strategies as needed. |
| 12 | + |
| 13 | +- **Flexible Configuration:** Control your project’s compiler, standard, and build type directly from `nimbus.toml`. Easily tweak settings without touching build scripts, thanks to an intuitive TOML-based configuration. |
| 14 | + |
| 15 | +## Getting Started |
| 16 | + |
| 17 | +1. **Installation (Ensure you have a clang++/g++ supporting modules, as well as toml11 and CLI11 on your machine):** |
| 18 | + |
| 19 | + ```bash |
| 20 | + git clone https://github.com/nimbus-cpp/nimbus.git |
| 21 | + cd nimbus |
| 22 | + mkdir build && cd build |
| 23 | + |
| 24 | + # init module |
| 25 | + clang++ -std=c++20 ../src/commands/init.cppm --precompile -o init.pcm -I/path/to/includes/CLI11+toml11 |
| 26 | + clang++ -std=c++20 ../src/commands/init.cppm -c -o init.o -I/path/to/includes/CLI11+toml11 |
| 27 | + |
| 28 | + # build module |
| 29 | + clang++ -std=c++20 ../src/commands/build.cppm --precompile -o build.pcm -I/path/to/includes/CLI11+toml11 |
| 30 | + clang++ -std=c++20 ../src/commands/build.cppm -c -o build.o -I/path/to/includes/CLI11+toml11 |
| 31 | + |
| 32 | + # main |
| 33 | + clang++ -std=c++20 ../src/main.cpp -fprebuilt-module-path=. init.o build.o -o nimbus -I/path/to/includes/CLI11+toml11 |
| 34 | + ``` |
| 35 | +3. **Project initialization:** |
| 36 | + |
| 37 | + To initialize the current directory as a nimbus project (which will use the dir name as the name of the project in the generated `nimbus.toml`): |
| 38 | + ```bash |
| 39 | + nimbus init |
| 40 | + ``` |
| 41 | + To create a new project from scratch: |
| 42 | + ```bash |
| 43 | + nimbus init my_project |
| 44 | + ``` |
| 45 | + This sets up a basic directory structure: |
| 46 | + ```css |
| 47 | + my_project/ |
| 48 | + ├─ include/ |
| 49 | + ├─ src/ |
| 50 | + └─ nimbus.toml |
| 51 | + ``` |
| 52 | + Inside nimbus.toml, you'll find default values for your project's name, version, authors, and build configuration: |
| 53 | + ```toml |
| 54 | + [project] |
| 55 | + name = "my_project" |
| 56 | + version = "0.1.0" |
| 57 | + authors = [ "Your Name <[email protected]>"] |
| 58 | + |
| 59 | + [build] |
| 60 | + compiler = "clang++" |
| 61 | + standard = "c++20" |
| 62 | + build_type = "Debug" |
| 63 | + ``` |
| 64 | + Adjust these as needed. For example, changing build_type from "Debug" to "Release" switches your project from including debugging symbols and `DEBUG` macro to producing an optimized binary with the `RELEASE` preprocessing macro. |
| 65 | +4. **Building the project:** |
| 66 | + |
| 67 | + Once your project is initialized and configured, running: |
| 68 | + ```bash |
| 69 | + nimbus build |
| 70 | + ``` |
| 71 | + Will: |
| 72 | + - Create the `build` directory if it doesn’t exist. |
| 73 | + - Read configuration options from `nimbus.toml`. |
| 74 | + - Compile all `.cpp`, `.c`, or `.cxx` files in `src/` using the specified compiler and flags. |
| 75 | + - Apply the appropriate preprocessor definitions based on the selected build type. |
| 76 | + - Generate the output binary in `build/`, naming it using the name config from `nimbus.toml`. |
| 77 | + |
| 78 | + Supported `build_type` values and their generated preprocessor macros(available to use in-code): |
| 79 | + - Debug -> DEBUG |
| 80 | + - Release -> RELEASE |
| 81 | + - RelWithDebInfo -> RELWITHDEBINFO |
| 82 | + - MinSizeRel -> MINSIZEREL |
| 83 | + |
| 84 | + ```cpp |
| 85 | + #include <iostream> |
| 86 | + |
| 87 | + int main() { |
| 88 | + #ifdef DEBUG |
| 89 | + std::cout << "Build Mode: Debug\n"; |
| 90 | + #elif defined(RELEASE) |
| 91 | + std::cout << "Build Mode: Release\n"; |
| 92 | + #elif defined(RELWITHDEBINFO) |
| 93 | + std::cout << "Build Mode: RelWithDebInfo\n"; |
| 94 | + #elif defined(MINSIZEREL) |
| 95 | + std::cout << "Build Mode: MinSizeRel\n"; |
| 96 | + #else |
| 97 | + std::cout << "Build Mode: Unknown\n"; |
| 98 | + #endif |
| 99 | + return 0; |
| 100 | + } |
| 101 | + ``` |
0 commit comments