Going through CraftingInterpreters C part but implementing it in C++. Note: This code is written on a Mac and not tested on other systems. Therefore tooling is used out of this perspective as well.
- Site: https://cmake.org/
- Github: https://github.com/Kitware/CMake
Install on Mac (if not already present):
brew install cmake
- Site: https://llvm.org/
- Github: https://github.com/llvm/llvm-project
Tools from the LLVM toolchain are used. To install LLVM on Mac run:
brew install llvm
Tools used from the toolset:
- clang-tidy
- clang-format
To link these tools run:
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"
- Site: https://ninja-build.org/
- Github: https://github.com/ninja-build/ninja
You can install Ninja on Mac via brew:
brew install ninja
Clone the project with all submodules:
git clone --recurse-submodules -j8 git@github.com:MartinHelmut/cpplox.git
git pull && git submodule update --init
Build the configuration files with cmake:
cmake -GNinja -DDEBUG=1 -DCMAKE_BUILD_TYPE=Debug --build build/debug
Build the application with Ninja:
ninja -C build/debug
Build the configuration files with cmake:
cmake -GNinja -DDEBUG=0 -DCMAKE_BUILD_TYPE=Release --build build/release
Build the application with Ninja:
ninja -C build/release
After building the application you can either run the client in debug or release mode:
# Debug
./build/debug/lox/client/Client
# Release
./build/release/lox/client/Client
You can build the application as you like (e.g. in debug mode) and run unit tests via:
./build/debug/lox/tests/Tests
There is a special profiling build running cmake with PROFILE=1
:
# Create config files
cmake -GNinja -DDEBUG=0 -DPROFILE=1 -DCMAKE_BUILD_TYPE=Release --build build/profile
# Build profile runner
ninja -C build/profile
Running the profiler executable will generate a lox-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/lox/client/Client
Just to be sure, here a reference to the license model of crafting interpreters: https://github.com/munificent/craftinginterpreters/blob/master/LICENSE
List of externally used dependencies: