stamen

Static Menu Generator
git clone git://git.dimitrijedobrota.com/stamen.git
Log | Files | Refs | README | LICENSE | HACKING | CONTRIBUTING | CODE_OF_CONDUCT | BUILDING

HACKING.md (5520B)


0 # Hacking 1 2 Here is some wisdom to help you build and test this project as a developer and 3 potential contributor. 4 5 If you plan to contribute, please read the [CONTRIBUTING](CONTRIBUTING.md) 6 guide. 7 8 ## Developer mode 9 10 Build system targets that are only useful for developers of this project are 11 hidden if the `stamen_DEVELOPER_MODE` option is disabled. Enabling this 12 option makes tests and other developer targets and options available. Not 13 enabling this option means that you are a consumer of this project and thus you 14 have no need for these targets and options. 15 16 Developer mode is always set to on in CI workflows. 17 18 ### Presets 19 20 This project makes use of [presets][1] to simplify the process of configuring 21 the project. As a developer, you are recommended to always have the [latest 22 CMake version][2] installed to make use of the latest Quality-of-Life 23 additions. 24 25 You have a few options to pass `stamen_DEVELOPER_MODE` to the configure 26 command, but this project prefers to use presets. 27 28 As a developer, you should create a `CMakeUserPresets.json` file at the root of 29 the project: 30 31 ```json 32 { 33 "version": 2, 34 "cmakeMinimumRequired": { 35 "major": 3, 36 "minor": 14, 37 "patch": 0 38 }, 39 "configurePresets": [ 40 { 41 "name": "dev", 42 "binaryDir": "${sourceDir}/build/dev", 43 "inherits": ["dev-mode", "vcpkg", "ci-<os>"], 44 "cacheVariables": { 45 "CMAKE_BUILD_TYPE": "Debug" 46 } 47 } 48 ], 49 "buildPresets": [ 50 { 51 "name": "dev", 52 "configurePreset": "dev", 53 "configuration": "Debug" 54 } 55 ], 56 "testPresets": [ 57 { 58 "name": "dev", 59 "configurePreset": "dev", 60 "configuration": "Debug", 61 "output": { 62 "outputOnFailure": true 63 } 64 } 65 ] 66 } 67 ``` 68 69 You should replace `<os>` in your newly created presets file with the name of 70 the operating system you have, which may be `win64`, `linux` or `darwin`. You 71 can see what these correspond to in the 72 [`CMakePresets.json`](CMakePresets.json) file. 73 74 `CMakeUserPresets.json` is also the perfect place in which you can put all 75 sorts of things that you would otherwise want to pass to the configure command 76 in the terminal. 77 78 > **Note** 79 > Some editors are pretty greedy with how they open projects with presets. 80 > Some just randomly pick a preset and start configuring without your consent, 81 > which can be confusing. Make sure that your editor configures when you 82 > actually want it to, for example in CLion you have to make sure only the 83 > `dev-dev preset` has `Enable profile` ticked in 84 > `File > Settings... > Build, Execution, Deployment > CMake` and in Visual 85 > Studio you have to set the option `Never run configure step automatically` 86 > in `Tools > Options > CMake` **prior to opening the project**, after which 87 > you can manually configure using `Project > Configure Cache`. 88 89 ### Dependency manager 90 91 The above preset will make use of the [vcpkg][vcpkg] dependency manager. After 92 installing it, make sure the `VCPKG_ROOT` environment variable is pointing at 93 the directory where the vcpkg executable is. On Windows, you might also want 94 to inherit from the `vcpkg-win64-static` preset, which will make vcpkg install 95 the dependencies as static libraries. This is only necessary if you don't want 96 to setup `PATH` to run tests. 97 98 [vcpkg]: https://github.com/microsoft/vcpkg 99 100 ### Configure, build and test 101 102 If you followed the above instructions, then you can configure, build and test 103 the project respectively with the following commands from the project root on 104 any operating system with any build system: 105 106 ```sh 107 cmake --preset=dev 108 cmake --build --preset=dev 109 ctest --preset=dev 110 ``` 111 112 If you are using a compatible editor (e.g. VSCode) or IDE (e.g. CLion, VS), you 113 will also be able to select the above created user presets for automatic 114 integration. 115 116 Please note that both the build and test commands accept a `-j` flag to specify 117 the number of jobs to use, which should ideally be specified to the number of 118 threads your CPU has. You may also want to add that to your preset using the 119 `jobs` property, see the [presets documentation][1] for more details. 120 121 ### Developer mode targets 122 123 These are targets you may invoke using the build command from above, with an 124 additional `-t <target>` flag: 125 126 #### `coverage` 127 128 Available if `ENABLE_COVERAGE` is enabled. This target processes the output of 129 the previously run tests when built with coverage configuration. The commands 130 this target runs can be found in the `COVERAGE_TRACE_COMMAND` and 131 `COVERAGE_HTML_COMMAND` cache variables. The trace command produces an info 132 file by default, which can be submitted to services with CI integration. The 133 HTML command uses the trace command's output to generate an HTML document to 134 `<binary-dir>/coverage_html` by default. 135 136 #### `docs` 137 138 Available if `BUILD_MCSS_DOCS` is enabled. Builds to documentation using 139 Doxygen and m.css. The output will go to `<binary-dir>/docs` by default 140 (customizable using `DOXYGEN_OUTPUT_DIRECTORY`). 141 142 #### `format-check` and `format-fix` 143 144 These targets run the clang-format tool on the codebase to check errors and to 145 fix them respectively. Customization available using the `FORMAT_PATTERNS` and 146 `FORMAT_COMMAND` cache variables. 147 148 #### `run-exe` 149 150 Runs the executable target `exe_exe`. 151 152 #### `spell-check` and `spell-fix` 153 154 These targets run the codespell tool on the codebase to check errors and to fix 155 them respectively. Customization available using the `SPELL_COMMAND` cache 156 variable. 157 158 [1]: https://cmake.org/cmake/help/latest/manual/cmake-presets.7.html 159 [2]: https://cmake.org/download/