Example showing how to use skir's C++ code generator in a project.
- Node.js - for running the Skir code generator
- CMake 3.20+ - for building the C++ code
- A C++17 compatible compiler (GCC, Clang, or MSVC)
If you use Homebrew on macOS:
brew install cmake nodegit clone https://github.com/gepheum/skir-cc-example.git
cd skir-cc-exampleGenerate the C++ code from Skir definitions:
npx skir genThe Skir compiler looks for a skir.yml file in the current directory.
This file contains the following information:
srcDir: path to the directory containing all the .skir filesgenerators: code generators to run; each generator targets one programming language
The compiler creates a skirout directory containing all the generated code.
Alternatively, you can run the compiler with watch mode on: npx skir gen -w.
While the process is running, every modification to a .skir file in the source
directory will trigger code generation.
The process won't stop until you terminate it.
CMake automatically fetches and builds all dependencies (Abseil, cpp-httplib, GoogleTest, and skir-client).
mkdir build
cd build
cmake ..
cmake --build .Or with parallel jobs for faster builds:
cmake --build . -j$(nproc) # Linux/macOS
cmake --build . -j8 # or specify number of cores# Run the example program
./example
# Run tests
ctest --output-on-failure
# Start a skir service
./service_start
# Send RPCs to the skir service (run in a different terminal)
./service_clientBUILD_TESTING(default: ON) - Build the test suite
To disable tests:
cmake -DBUILD_TESTING=OFF ..For release builds with optimizations:
cmake -DCMAKE_BUILD_TYPE=Release ..CMake generates a compile_commands.json file automatically, which provides excellent IDE integration.
If your C++ compiler is clang (recommended), install the clangd extension and disable Microsoft's C/C++ extension.
The compile_commands.json file provides:
- Code completion
- Compile errors and warnings
- Go-to-definition and cross references
- Hover information and inlay hints
- Include management
- Code formatting
- Simple refactorings