You want to contribute to this repo? Nice! And of course: you are the best! Here is a guide on how to work with it and what to expect.
Build status:
- Required tools
- Setup
- Update
- Build
- Tests
- Formatting code
- Usage without Litr
- Run
- Files and Directories
CMake is an open-source, cross-platform family of tools designed to build, test and package software.
- Site: https://cmake.org/
- Github: https://github.com/Kitware/CMake
Install on macOS (if not already present):
brew install cmakeThe LLVM Project is a collection of modular and reusable compiler and toolchain technologies. Some tools from the LLVM toolchain are used.
- Site: https://llvm.org/
- Github: https://github.com/llvm/llvm-project
To install LLVM on macOS run:
brew install llvmTools used from the toolset:
- clang-tidy (linting)
- clang-format (formatting)
To link these tools run (may need to be run as root, you can also pick a different location in your PATH):
ln -s "$(brew --prefix llvm)/bin/clang-format" "/usr/local/bin/clang-format"
ln -s "$(brew --prefix llvm)/bin/clang-tidy" "/usr/local/bin/clang-tidy"Ninja is a small build system with a focus on speed.
- Site: https://ninja-build.org/
- Github: https://github.com/ninja-build/ninja
You can install Ninja on macOS via brew:
brew install ninjaThis repo uses Litr itself for its tasks. So installing it will make things easier (though, it is optional). To install Litr:
brew tap krieselreihe/litr
brew install litrClone the project:
git clone git@github.com:krieselreihe/litr.gitlitr updateFor a quick overview of build options run litr build --help.
Build a debug build:
litr buildRun Litr with the following options if needed:
- Enable detailed execution flow tracing including disassemble any parser statements
litr build --trace - Disable any logging via
litr build --nolog. - Set debug mode, even if build type differs (for debugging purposes)
litr build --debug
A debug build will always also produce profiling information. Running the executable directly will generate
a litr-profile.json file that can be used with any Chromium based browser tracing tool,
e.g. chrome://tracing. Just drag and drop the file into the tracing view. To generate the file run
the local build directly:
./build/release/src/client/ClientNevertheless, you can generate profiling data on other build targets as well, e.g. "release":
litr build --target=release --profileBuild a release version:
litr build --target=releaseFor a release that can be published, and the release process in full, visit the wiki.
After building the application you can run unit tests for the build output with ctest.
# Run all tests for debugging build
litr test
# Run all tests for release build
litr test --target=releaseUsing clang-format you can run Litr to format all project files:
litr formatClick to expand
git pullBuild the configuration files with cmake:
cmake -GNinja -DCMAKE_BUILD_TYPE=Debug -B build/debugBuild the application:
cmake --build build/debugRun cmake with the following options if needed:
- Disassemble any parser statements for debugging using
-DDISASSEMBLE=ON. - Disable any logging via
-DDEACTIVATE_LOGGING=ON. - Enable detailed execution flow tracing
-DTRACE=ON - Set debug mode, even if build type differs (for debugging purposes)
-DDEBUG=ON
Build the configuration files with cmake:
cmake -GNinja -DCMAKE_BUILD_TYPE=Release -B build/releaseBuild the application:
cmake --build build/releaseAfter building the application you can run unit tests for the build output with ctest.
Note: With CMake 3.20 it will be possible to specify the --test-dir option for
ctest [source], making test execution easier.
# Run all tests for debugging build
cd build/debug/src/tests && ctest && ../../../..
# Run all tests for release build
cd build/release/src/tests && ctest && ../../../..There is a profiling build you can generate running cmake with PROFILE=ON (build type is up to you, for real world
results use "Release"):
# Create config files
cmake -GNinja -DPROFILE=ON -DCMAKE_BUILD_TYPE=Release -B build/profile
# Build profile runner
cmake --build build/profileRunning the profiler executable will generate a litr-profile.json file that can be used with any Chromium based
browser tracing tool, e.g. chrome://tracing. Just drag and drop the file into the tracing view. To
generate the file run:
./build/profile/src/client/ClientTo create builds on a different compiler the variables CMAKE_C_COMPILER and CMAKE_CXX_COMPILER can be set,
specifying the path to the compiler.
Example for clang on macOS, creating a debug build:
cmake -GNinja -DCMAKE_BUILD_TYPE=Debug -DCMAKE_C_COMPILER=/usr/bin/clang -DCMAKE_CXX_COMPILER=/usr/bin/clang++ -B build/debug
cmake --build build/debugExample for gcc on macOS, creating a debug build:
cmake -GNinja -DCMAKE_BUILD_TYPE=Debug -DCMAKE_C_COMPILER=/usr/bin/gcc -DCMAKE_CXX_COMPILER=/usr/bin/g++ -B build/debug
cmake --build build/debugAfter building the application you can either run the local client:
# Debug
./build/debug/src/client/Client
# Release
./build/release/src/client/ClientHere an overview of a few important files and folders when working with the code.
What: Contains all client code to run the application inside the terminal.
What: The core library code.
src/core/Core/Debug: Code for debugging the application
src/core/Core/Error: Error handling related codesrc/core/Core/Error/BaseError.hpp: Base error class
src/core/Core/Config: All code related to loading and handling the configuration filesrc/core/Core/Config/Loader.hpp: Configuration file loadersrc/core/Core/Config/Command.hpp: Configuration command descriptionsrc/core/Core/Config/Parameter.hpp: Configuration parameter description
src/core/Core/CLI/Parser.hpp: Command line argument parsersrc/core/Core/CLI/Interpreter.cpp: Execute parsed instructionssrc/core/Core/CLI/Shell.hpp: Script runner
src/core/Core/Script/Compiler.cpp: Compile CLI instructions to a valid executable script
What: All test code for unit and integration tests.
src/tests/Fixtures: Tests fixtures, e.g. test configuration files for integration testssrc/tests/Helpers: Test helper functionssrc/tests/Tests: Test cases