Sygaldry
|
Copyright 2023 Travis J. West, https://traviswest.ca, Input Devices and Music Interaction Laboratory (IDMIL), Centre for Interdisciplinary Research in Music Media and Technology (CIRMMT), McGill University, Montréal, Canada, and Univ. Lille, Inria, CNRS, Centrale Lille, UMR 9189 CRIStAL, F-59000 Lille, France
SPDX-License-Identifier: MIT
This document describes the Sygaldry build system.
The build environment setup is automated using the Nix package manager. See Nix Shell Setup for a detailed description.
We set a variable allowing components to reach the root of the repository. This is mainly done so that components can reach the dependencies
directory unambiguously as ${SYGALDRY_ROOT}/dependencies
, rather than using a relative path that might break if the component is physically moved.
We require C++20 without extensions.
Catch2 is used for unit testing on platforms where it can run. Other platforms may use a different testing methodology.
Catch2 is not a good testing framework for ESP-IDF and Pico SDK, so the code to enable it is disabled for those platforms.
See the Catch2 CMake integration documentation for more detail.
Avendish is used to build Pd externals, and eventually perhaps for other bindings. It is currently incompatible with ESP-IDF and Pico SDK.
Boost PFR and Boost MP11 are required by the concepts library, and consequently by any bindings or components that make use of it. Several other components make use of specific libraries, such as liblo and Trill-Arduino
; some of these are also included as submodules, and some may be required to build the default test suite. Since many of these dependencies do not provide cmake support, they are handled on a case by case basis in the CMakeLists.txt
files of the components that use them. Those that can be included via CMake are made available here, when appropriate depending on the platform.
The project is physically structured as self-contained software components, in the sense described by John Lakos [lakos2019large-scale-cpp]. Each component lives in its own directory, with its own CMakeLists.txt file. The main CMakeLists.txt file's principal job is to include these components as subdirectories.
In an earlier version of the project, there was a directory structure resembling the following, where each leaf node was a directory containing a component as just described:
Components were correspondingly named e.g. sygaldry-sensors-esp32-adc
.
As well as being troublingly verbose when editing, this proved problematic when building on Windows, which at the time in the year 2023 enforced a limit of 260 characters on the length of a path when making a directory. Some instrument firmwares being built at the time would include the main repository root as a library, resulting in very long build artefact paths such as C:\Users\user\Github\sygaldry\sygaldry\instruments\instrument_name\instrument_name_platform\instrument\build\main\sygbuild\C_Users\user\Github\sygaldry\sensors\arduino\trill_craft\sygaldry-sensors-arduino-trill_craft.obj.d
that would eventually trip the path length limit. Although it was possible to modify registry keys and otherwise work around the issue, given the inconvenience entailed in editing and maintaining the long component names, it was decided to adopt an organizational scheme with better characteristics in terms of brevity.
The repository now contains two main content directories: sygaldry
and sygaldry-instruments
. The sygaldry
directory contains all of the software components in the library, except for the instruments, which are unsurprisingly found in the other directory. Rather than being named verbosely, in keeping with [lakos2019large-scale-cpp], packages and their components are given identifiers of the form sygXY
where XY
is the package identifier, with X
typically (currently always) referring to the broad type of components and Y
to the platform.
The authoritative list of components is automatically generated by generate_components_cmake.sh Automated CMake Component List and placed at sygaldry/CMakeLists.txt
. We add that subdirectory here, as well as instruments that should be built with the test suite.