You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
The old instructions referred to 731264b0 version of LLVM. The binaries on the website provided for users were updated to 29b20829 and the install instructions were updated to reflect the preset examples.
fix#462
Create and go to the `third-party` directory, where we are going to download and install our custom dependencies:
17
+
Also create and go to the `third-party` directory, where we are going to download and install our dependencies:
21
18
22
19
[source,bash]
23
20
----
@@ -31,54 +28,168 @@ These instructions assume all dependencies are installed in the `third-party` di
31
28
Fell free to install them anywhere you want and adjust the main MrDocs configuration command later.
32
29
====
33
30
34
-
=== LLVM
35
-
36
-
MrDocs depends on a specific recent version of LLVM: https://github.com/llvm/llvm-project/tree/731264b0c2af7aa46bd39625202a99e06cfccff9[731264b0]
37
-
38
-
Because building LLVM may take many hours to complete, we provide pre-built binaries for Windows and Linux: https://mrdocs.com/llvm+clang/[LLVM Releases].
39
-
You can download the binaries and uncompress them in the `./third-party/llvm+clang` directory.
31
+
=== Installing LLVM
32
+
33
+
MrDocs uses LLVM to parse C++ code and extract documentation from it.
34
+
It depends on a recent version of LLVM: https://github.com/llvm/llvm-project/tree/29b20829cc6ce3e6d9c3809164994c1659e0da56[29b20829]
35
+
36
+
[#llvm-binaries]
37
+
**Binaries**:
38
+
39
+
Because building LLVM may take many hours to complete, we provide pre-built binaries for Windows and Linux:
IMPORTANT: The Linux binaries are built on Ubuntu 22.04 and may not work on other distributions.
102
+
103
+
You can download the binaries and uncompress them in the `./third-party/llvm+clang` directory we created in the previous step.
104
+
105
+
LLVM binaries are provided in a number of preset configurations.
106
+
Here is a brief description of each preset:
107
+
108
+
- `Release`: this is the preset users will typically use.
109
+
It is optimized for speed and does not include debug information.
110
+
- `Debug`: this is a preset developers can use.
111
+
It includes debug information and no optimizations.
112
+
However, using a `Debug` build of LLVM to debug MrDocs might be too slow.
113
+
In this case, you can link MrDocs with `RelWithDebInfo` or `DebWithOpt`.
114
+
- `RelWithDebInfo`: this is a release build with debug information.
115
+
It is optimized for speed and includes debug information.
116
+
However, if you are working with Windows+MSVC, this preset has a `Release` build type at the MSVC level.
117
+
This means you can have conflicts with MrDocs in `Debug` mode because of LLVM setting flags such as the `_ITERATOR_DEBUG_LEVEL` and `/MDd`.
118
+
In this case, you can use `DebWithOpt` instead to avoid the conflict and subsequent workarounds.
119
+
- `DebWithOpt`: this is a debug build with optimizations.
120
+
It includes all the default Debug flags for LLVM, it's optimized for speed, includes debug information, and causes no conflicts with MrDocs in `Debug` mode.
121
+
122
+
If you chose to use the provided binaries instead of building LLVM from source, you can skip to the <<duktape>> section.
123
+
124
+
**Download**:
40
125
41
126
Alternatively, if building LLVM from source, you can clone the project from the official repository:
We recommend using https://cmake.org/cmake/help/latest/manual/cmake-presets.7.html[CMake presets,window=_blank] to build LLVM.
144
+
Preset files contain a replicable set of CMake configuration values that can be used to configure a project.
145
+
146
+
Instead of passing all CMake configuration values on the command line, a template for the `CMakePresets.json` and `CMakeUserPresets.json` files is provided in the repository's `third-party/llvm` directory.
147
+
Copy these files to the `llvm-project/llvm` directory and run a command such as the following to configure LLVM:
As you can see from the step above, we configure a `RelWithDebInfo` version of LLVM for MrDocs by default.
67
-
This is a release build with debug information.
68
-
Other possible CMake configurations supported by LLVM are `Debug` (including debug information and no optimizations), `Release` (including optimizations and no debug information), and `MinSizeRel` (which optimizes for size).
154
+
In the example above, we configure a `RelWithDebInfo` version of LLVM for MrDocs: a release build with debug information.
155
+
156
+
Choose one of the presets from `CMakePresets.json` or edit the variants in `CMakeUserPresets.json` to customize the configurations.
157
+
The `CMakeUserPresets.json` file comes with presets for all the configurations described in the <<llvm-binaries,Binaries>> section.
69
158
70
159
[NOTE]
71
160
====
72
161
Developers might also want to build a custom `Debug` LLVM configuration including optimizations, which allows for faster execution of tests.
73
-
To create such an installation, set `CMAKE_CONFIGURATION_TYPES` or `CMAKE_BUILD_TYPE` to `Debug` and manually include the optimization flags to `-D CMAKE_CXX_FLAGS="/O2 /Zi"` (MSVC) or `-D CMAKE_CXX_FLAGS="-Og -g"`.
162
+
The `relwithdebinfo` and `debwithopt` presets are provided for this purpose.
163
+
Or if you prefer using the command line, set `CMAKE_CONFIGURATION_TYPES` or `CMAKE_BUILD_TYPE` to `Debug` and manually include the optimization flags to `-D CMAKE_CXX_FLAGS="/O2 /Zi"` (MSVC) or `-D CMAKE_CXX_FLAGS="-Og -g"`.
74
164
75
165
This should give you an optimized build with all debug features and flags, such as an appropriate https://learn.microsoft.com/en-us/cpp/standard-library/iterator-debug-level[`_ITERATOR_DEBUG_LEVEL`] and the `/MDd` flag in MSVC.
76
166
In other platforms, this should give you a release somewhat equivalent to `RelWithDebInfo` optimized for debugging experience. `-Og` offers a reasonable level of optimization while maintaining fast compilation and a good debugging experience.
77
-
78
-
This custom configuration can be installed in an alternative directory, such as `../llvm+clang/DebWithOpt`, to be used by the MrDocs `Debug` builds by developers.
79
167
====
80
168
81
-
Then build and install it:
169
+
[#llvm-configure-cmd-line]
170
+
_Configure with Command Line Arguments_:
171
+
172
+
You can also configure LLVM directly with the settings required by MrDocs:
173
+
174
+
Windows (from administrator `cmd.exe`, after running `vcvars64.bat`):
Unlike the <<llvm-configure-presets,CMake presets>>, this command does not a number of parameters that removes features that are not required by MrDocs, thus increasing the build time and size of the installation.
189
+
190
+
**Build**:
191
+
192
+
Build and install the configured version of LLVM with:
Return from `./third-party/llvm-project/build` to the parent `third-party` directory to install other dependencies:
91
211
92
212
[source,bash]
93
213
----
94
214
cd ../..
95
215
----
96
216
97
-
==== Duktape
217
+
[#duktape]
218
+
=== Downloading Duktape
98
219
99
-
Duktape is a JavaScript engine that is used by MrDocs to parse and evaluate JavaScript code.
220
+
MrDocs contains functionality to allow users to define their own templates for the documentation.
221
+
Duktape is a JavaScript engine that is used by MrDocs to parse and evaluate template helpers.
100
222
101
223
The release files can be obtained from the Duktape repository:
102
224
@@ -107,7 +229,8 @@ tar -xvf "duktape-2.7.0.tar.xz"
107
229
----
108
230
109
231
Duktape provides no CMake integration scripts.
110
-
The MrDocs configuration script needs direct access to the installed source files for Duktape so that's all you need to do.
232
+
For this reason, MrDocs needs direct access to the source files for Duktape.
233
+
This means that's all you need to do for `duktape`.
111
234
112
235
=== CMake dependencies
113
236
@@ -155,7 +278,7 @@ vcpkg has two operation modes with which you can install these dependencies: <<v
155
278
[#vcpkg-classic-mode]
156
279
_Classic mode_:
157
280
158
-
In vcpkg @https://learn.microsoft.com/en-us/vcpkg/users/classic-mode[classic mode,window=blank_], vcpkg maintains a central installed tree inside the vcpkg instance built up by individual vcpkg install and vcpkg remove commands.
281
+
In vcpkg https://learn.microsoft.com/en-us/vcpkg/users/classic-mode[classic mode,window=blank_], vcpkg maintains a central installed tree inside the vcpkg instance built up by individual `vcpkg install` and `vcpkg remove` commands.
159
282
This central set of packages can then be shared by any number of projects.
160
283
However, each instance of vcpkg (a separate git clone) will have its own set of packages installed.
161
284
@@ -178,16 +301,30 @@ Unix variants:
178
301
[#vcpkg-manifest-mode]
179
302
_Manifest mode_:
180
303
181
-
In @https://learn.microsoft.com/en-us/vcpkg/users/manifests[manifest mode,windows=blank_], you declare your project's direct dependencies in a manifest file named `vcpkg.json`.
304
+
In https://learn.microsoft.com/en-us/vcpkg/users/manifests[manifest mode,windows=blank_], you declare your project's direct dependencies in a manifest file named `vcpkg.json`.
182
305
MrDocs includes a `vcpkg.json.example` file you can duplicate or create a symlink as `vcpkg.json` to use this mode.
183
306
MrDocs is a CMake project that then already includes a `vcpkg.json` file, there's nothing else you need to run to install the dependencies.
184
307
185
308
In this mode, vcpkg will create separate installed trees for each project and configuration.
186
-
This is the recommended vcpkg mode for most users according to the @https://learn.microsoft.com/en-us/vcpkg/users/manifests[vcpkg documentation,window=blank_].
309
+
This is the recommended vcpkg mode for most users according to the https://learn.microsoft.com/en-us/vcpkg/users/manifests[vcpkg documentation,window=blank_].
187
310
188
311
=== MrDocs
189
312
190
-
Once the dependencies are available in `third-party`, you can configure MrDocs with:
313
+
Return from `./third-party/vcpkg` to the parent directory of `third-party` (the one containing the `mrdocs` directory) to build and install MrDocs:
314
+
315
+
[source,bash]
316
+
----
317
+
cd ../..
318
+
----
319
+
320
+
**Configure**:
321
+
322
+
You can also configure MrDocs with <<mrdocs-configure-cmd-line, command line arguments>> or <<mrdocs-configure-presets, CMake presets>>.
323
+
324
+
[#mrdocs-configure-cmd-line]
325
+
_Configure with Command Line Arguments_:
326
+
327
+
With the dependencies are available in `third-party`, you can configure MrDocs with:
The MrDocs repository also includes a `CMakePresets.json` file that contains the parameters to configure MrDocs with CMake.
209
347
210
348
To specify the installation directories, you can use the `LLVM_ROOT`, `DUKTAPE_SOURCE_ROOT`, `CMAKE_TOOLCHAIN_FILE` environment variables.
211
349
To specify a generator (`-G`) and platform name (`-A`), you can use the `CMAKE_GENERATOR` and `CMAKE_GENERATOR_PLATFORM` environment variables.
212
350
213
-
Alternatively, you can create a `CMakeUserPresets.json` file in the `mrdocs` directory with the specific values you want to override in each configuration.
214
-
This is typically more convenient than using environment variables when working on an IDE.
215
-
The repository includes a `CMakeUserPresets.json.example` file that can be used as a template.
216
-
====
351
+
You can also customize the presets by duplicating and editing the `CMakeUserPresets.json.example` file in the `mrdocs` directory.
352
+
This is typically more convenient than using environment variables.
353
+
354
+
**Build**:
217
355
218
-
Then build and install it with:
356
+
Then build and install MrDocs with:
219
357
220
358
[source,bash]
221
359
----
@@ -230,7 +368,7 @@ To customize the C and C++ compilers, use the `CMAKE_C_COMPILER` and `CMAKE_CXX_
230
368
[NOTE]
231
369
====
232
370
Developers should also enable `-D BUILD_TESTING=ON`.
233
-
If any custom build of LLVM is being used (such as `DebWithOpt`), the `LLVM_ROOT` variable should be set to the installation directory of that build.
371
+
If any custom build of LLVM other than `RelWithDebInfo` is being used, the `LLVM_ROOT` variable should be set to the installation directory of that build.
0 commit comments