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
Copy file name to clipboardExpand all lines: scripts/mrbind/README-generating.md
+17-17Lines changed: 17 additions & 17 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -104,39 +104,37 @@ The resulting Python modules are created next to the MeshLib shared libraries, i
104
104
105
105
***`--trace` — enable verbose logs.** Remove to get quieter logs.
106
106
107
-
***`-B` — force a full rebuild of the bindings.**Incremental builds are not very useful, because they're not perfect and can miss changes. Use incremental builds only e.g. when you're fixing linker errors.
107
+
***`-B` — force a full rebuild of the bindings.**Don't remove this flag. Doing so causes Make to attempt an incremental build instead of a full rebuild, but we don't have those configured correctly, so the binding generation might be skipped even when the input headers were changed. There's one valid usecase for removing this flag: making changes to fix linker errors, such as correcting `MESHLIB_SHLIB_DIR` or `VS_MODE`; in those cases removing `-B` will redo linking instead of rebuilding the entire bindings.
108
108
109
109
***`MODE=...` — optimization** setting for the Python module:
110
110
111
-
*`release` (default) — Enable optimization, disable debug symbols. Same as what goes into the production.
111
+
*`release` (default) — Enable optimization, disable debug symbols. This is what goes into the production.
112
112
113
113
*`debug` — disable optimizations, enable debug symbols. Use this to debug the bindings.
114
114
115
115
*`none` — neither enable optimizations nor enable the debug symbols. This gives the fastest build times, useful for testing bindings locally.
116
116
117
-
You can also et entirely custom C++ compiler flags, by setting `EXTRA_CFLAGS` and `EXTRA_LDFLAGS`.
118
-
119
-
The `EXTRA_...` flags are ignored for C#, and `MODE=none` is replaced with `MODE=debug` there.
117
+
You can also use entirely custom C++ compiler flags, by setting `EXTRA_CFLAGS` and `EXTRA_LDFLAGS`.
120
118
121
119
***`NUM_FRAGMENTS=?? -j??` — adjust RAM usage vs build speed tradeoff.**
122
120
123
121
If you're running out of RAM, reduce `-j...`.
124
122
125
-
`NUM_FRAGMENTS=??` is how many translation units the bindings are split into. `-j??` is the number of parallel build threads/processes. We have some heuristics to guess good values for this, they are printed when the script starts.
123
+
`NUM_FRAGMENTS=??` is how many translation units the bindings are split into. `-j??` is the number of parallel build threads/processes. We have some heuristics to guess good values for this, those values are printed when the script starts.
126
124
127
125
Guessing the fastest combination isn't trivial. Usually you want to maximize threads (up to the number of cores), and then minimize the number of fragments as much as your RAM allows. The number of fragments should normally be a multiple of the number of threads.
128
126
129
127
***`PYTHON_PKGCONF_NAME=python-3.??-embed` — select Python version.** We try to guess this one. You can set this to `python3-embed` to use whatever your OS considers to be the default version.
130
128
131
-
***`ENABLE_CUDA=??` — enable or disable Cuda.** If you're building MeshLib without Cuda support, pass `ENABLE_CUDA=0` to skip the Cuda bindings too. It defaults to `1` everywhere except MacOS, where Cuda doesn't work.
129
+
***`ENABLE_CUDA=??` — enable or disable Cuda.** If you're building MeshLib without Cuda support, pass `ENABLE_CUDA=0` to skip the Cuda bindings. It defaults to `1` everywhere except MacOS, where Cuda doesn't work.
132
130
133
-
When this is disabled, a stub Cuda bindings are still generated, with a single function that reports that Cuda is not available.
131
+
When this is disabled, stub Cuda bindings are still generated, with a single function that reports that Cuda is not available.
134
132
135
133
***`BUILD_SHIMS=1` — support multiple Python versions.** This enables support for all Python versions found on the system, as opposed a single default one. See the relevant section in the [troubleshooting guide](#troubleshooting-python-bindings).
136
134
137
135
***`shims` — add support for multiple Python versions.** Same effect as `BUILD_SHIMS=1`, but instead of regenerating the bindings, this just adds the missing version support to existing bindings. This is great if you forgot the flag during the initial compilation.
138
136
139
-
***`FOR_WHEEL=1` — build for wheel packaging.** This is primarily for CI, not for local use. Indicates that you want to package the resulting module into a wheel (a Python module archive for distribution), instead of using it locally. Enabling this might prevent the module from working locally.
137
+
***`FOR_WHEEL=1` — build for wheel packaging.** This is primarily for CI, not for local use. Indicates that you want to package the resulting module into a wheel (a Python module archive for distribution), instead of using it locally. Enabling this might prevent the module from functioning until packaged into a wheel.
140
138
141
139
This automatically enables `BUILD_SHIMS=1`, among other things.
142
140
@@ -148,19 +146,19 @@ The resulting Python modules are created next to the MeshLib shared libraries, i
148
146
149
147
* When built locally, Python bindings only support one speific Python version by default. If you try to import them from another version, you will get errors such as the one above.
150
148
151
-
* To check which version you built for, look for shared libraried named `pybind11nonlimitedapi_meshlib_3.??` next to the Python modules. On Windows, those should be in `source/x64/Release/meshlib` (or `.../Debug/...`). The number in the filename is the Python version.
149
+
* To check what version you built for, look for shared libraried named `pybind11nonlimitedapi_meshlib_3.??` next to the Python modules. On Windows, those should be in `source/x64/Release/meshlib` (or `.../Debug/...`). The number in the filename is the Python version.
152
150
153
151
* The easiest fix to use that Python version.
154
152
155
-
* On Windows, run e.g. `py -3.12` to use that specific version (`3.12` is our default for the bindings at the time of writing). You might need to install it first from [here](https://www.python.org/downloads/windows/).
153
+
* On Windows, run e.g. `py -3.12` to use that specific version (`3.12` is our default for the bindings at the time of writing). You might need to install that version first, from [here](https://www.python.org/downloads/windows/).
156
154
157
155
* On Linux, just running `python3` without specifying the minor version should use the correct version by default.
158
156
159
157
* Alternatively, you can add the missing shared libraries to support your preferred Python version.
160
158
161
-
* You can build them by rerunning the generation script with additional flag `shims`. This will build the libraries for all Python versions found on your system.
159
+
* You can build them by rerunning the generation script with the additional flag `shims`. This will build the libraries for all Python versions found on your system.
162
160
163
-
This commands only builds the libraries and does nothing else. You can use `BUILD_SHIMS=1` instead of `shims` to regenerate the bindings and build those libraries at the same time.
161
+
This command only builds the libraries and does nothing else. You can use `BUILD_SHIMS=1` instead of `shims` to both regenerate the bindings and build those libraries at the same time.
164
162
165
163
* You can also download the prebuilt libraries from [here](https://pypi.org/project/meshlib/#files). Download the archive for your OS and extract the `pybind11nonlimitedapi_meshlib_...` shared libraries next to yours.
166
164
@@ -170,7 +168,7 @@ The resulting Python modules are created next to the MeshLib shared libraries, i
170
168
171
169
***`machine type x86 conflicts with x64`**
172
170
173
-
* You opened `x86 ...` VS developer command prompt, but we need `x64 Native`. Rebuild the bindings in x64 prompt.
171
+
* You opened `x86 ...` VS developer command prompt, but we need `x64 Native`. Rebuild the bindings in the x64 prompt.
@@ -182,7 +180,7 @@ The resulting Python modules are created next to the MeshLib shared libraries, i
182
180
183
181
* You likely used a non-default compiler when compiling MeshLib. Pass this compiler to `CXX_FOR_ABI=...` when generating Python bindings to fix the issue (e.g. `CXX_FOR_ABI=clang++-22` or `g++-15`).
184
182
185
-
MeshLib is usually compiled using a different compiler than the Python bindings (for the bindings we use a specific version of Clang, the same that is used by the parser; using the same compiler for the bindings on all platforms makes writing them easier). Therefore, we must ensure that the two compilers use the same ABI. `CXX_FOR_ABI` should be set to the compiler the ABI of which we're trying to match. (Defaults to `CXX` environment variable, or `g++` if not set.) At the moment, if `CXX_FOR_ABI` is GCC 13 or older or Clang 17 or older (note that Apple Clang uses a [different version numbering scheme](https://en.wikipedia.org/wiki/Xcode#Xcode_15.0_-_(since_visionOS_support)_2)), we pass `-fclang-abi-compat=17` to our Clang 18 or newer (which is used to compile the bindings). This flag *disables* mangling of `requires` constraints into function names. If we guess incorrectly, you'll get undefined references to functions with `requires` constraints on them.
183
+
MeshLib is usually compiled using a different compiler than the Python bindings (for the bindings we use a specific version of Clang, the same that is used by the parser; using the same compiler for the bindings on all platforms makes writing them easier). Therefore, we must ensure that the two compilers use the same ABI. `CXX_FOR_ABI` should be set to the compiler the ABI of which we're trying to match. (Defaults to the `CXX` environment variable, or `g++` if not set.) At the moment, if `CXX_FOR_ABI` is GCC 13 or older or Clang 17 or older (note that Apple Clang uses a [different version numbering scheme](https://en.wikipedia.org/wiki/Xcode#Xcode_15.0_-_(since_visionOS_support)_2)), we pass `-fclang-abi-compat=17` to our Clang 18 or newer (which is used to compile the bindings). This flag *disables* mangling of `requires` constraints into the function names. If we guess incorrectly, you'll get undefined references to functions with `requires` constraints on them.
186
184
187
185
***Importing the wheel segfaults on MacOS**
188
186
@@ -203,7 +201,7 @@ The resulting Python modules are created next to the MeshLib shared libraries, i
203
201
204
202
Running our script generates the code for the bindings, at `source/MeshLibC2` and `source/MeshLibC2Cuda`.
205
203
206
-
Then you must build MeshLib with a special CMake flag, which will build the generated bindings.
204
+
Then you must build MeshLib with a special CMake flag, which will build the generated bindings in addition to the rest of the MeshLib.
207
205
208
206
### Windows
209
207
@@ -271,8 +269,10 @@ The steps below both generate the C# code (at `MeshLib/source/MRDotNet2`) and co
271
269
272
270
### Less common flags for the generator script
273
271
274
-
***Selecting MRBind installation:** if you installed MRBind to a non-default location (the default is `./MeshLib/mrbind`), you must pass this location to `MRBIND_SOURCE=path/to/mrbind`.
272
+
***Selecting MRBind installation:** if you installed MRBind to a non-default location (the default is `./thirdparty/mrbind`), you must pass this location to `MRBIND_SOURCE=path/to/mrbind`.
275
273
276
274
Additionally, if the MRBind binary is not at `$MRBIND_SOURCE/build/mrbind`, you must pass `MRBIND_EXE=...` (path to the executable itself, not its directory).
277
275
276
+
For C and C# (but not Python), if you set `MRBIND_EXE`, then you can skip `MRBIND_SOURCE`.
277
+
278
278
You can find more undocumented flags/variables in `generate.mk`.
0 commit comments