Developer guide

Environment

To setup a local build configuration, for example if you are using VSCode's CMake integration, create a CMake user preset that in CMakeUserPresets.json in the root directory of the project. This user preset can inherit from one of the standard ones in CMakePresets.json and add its own variables. For example:

{
  "version": 3,
  "configurePresets": [
    {
      "name": "macos-local",
      "displayName": "macOS local",
      "generator": "Ninja",
      "inherits": [
        "macos-debug"
      ],
      "cacheVariables": {
        "CMAKE_PREFIX_PATH":  "/Users/jamie/llvm-project/install/bin",
        "CMAKE_BUILD_TYPE": "Debug",
        "ENABLE_PY_BINDINGS": ON,
        "CODE_COVERAGE": "OFF",
        "BUILD_DOCS": "OFF"
      }
    }
]
}

Then to use this preset:

cmake --preset macos-local
cmake --build build/macos-local --target install
ctest --test-dir build/macos-local --output-on-failure --no-tests=error

Report code coverage:

# Compile with -DCODE_COVERAGE=ON, then:
make ccov-run-netlist_unittests
make ccov-report

To build the documentation install the Python dependenices:

virtualenv venv
source venv/bin/activate
pip install requirements.txt
# Compile with -DBUILD_DOCS=ON

Pre commit

Pre-commit runs a set of lint checks on files when creating git commits, with the config in .pre-commit.

You can install the hooks explicity with:

pre-commit install

And you can run pre-commit checks on all files with:

pre-commit run -a

To update the verisons of the hooks used in the pre-commit configuration file:

pre-commit autoupdate

Ubuntu Docker environment

You can use Docker to create an Ubuntu development environment, eg:

docker build -t slang-netlist-dev docker/ubuntu
docker run -it slang-netlist-dev

This is useful to debug issues seen in CI, especially when developing on MacOS.