@@ -75,7 +75,8 @@ mkdir native_build
7575cd native_build
7676cmake -DLLVM_ENABLE_PROJECTS=clang -DLLVM_TARGETS_TO_BUILD=host -DCMAKE_BUILD_TYPE=Release ../llvm/
7777cmake --build . --target llvm-tblgen clang-tblgen --parallel $( nproc --all)
78- export NATIVE_DIR=$PWD /bin/
78+ export NATIVE_LLVM_BUILD_DIR=$PWD
79+ export NATIVE_LLVM_BIN_DIR=$PWD /bin/
7980cd ..
8081mkdir build
8182cd build
@@ -97,7 +98,7 @@ emcmake cmake -DCMAKE_BUILD_TYPE=Release \
9798 -DLLVM_BUILD_TOOLS=OFF \
9899 -DLLVM_ENABLE_LIBPFM=OFF \
99100 -DCLANG_BUILD_TOOLS=OFF \
100- -DLLVM_NATIVE_TOOL_DIR=$NATIVE_DIR \
101+ -DLLVM_NATIVE_TOOL_DIR=$NATIVE_LLVM_BIN_DIR \
101102 -DCMAKE_C_FLAGS_RELEASE=" -Oz -g0 -DNDEBUG" \
102103 -DCMAKE_CXX_FLAGS_RELEASE=" -Oz -g0 -DNDEBUG" \
103104 -DLLVM_ENABLE_LTO=Full \
@@ -113,7 +114,8 @@ cd native_build
113114cmake -DLLVM_ENABLE_PROJECTS=clang -DLLVM_TARGETS_TO_BUILD=host -DCMAKE_BUILD_TYPE=Release -G Ninja ../llvm/
114115cmake --build . --target llvm-tblgen clang-tblgen --parallel $(nproc --all)
115116$env:PWD_DIR= $PWD.Path
116- $env:NATIVE_DIR="$env:PWD_DIR/bin/"
117+ $env:NATIVE_LLVM_BUILD_DIR="$env:PWD_DIR"
118+ $env:NATIVE_LLVM_BIN_DIR="$env:PWD_DIR/bin/"
117119cd ..
118120mkdir build
119121cd build
@@ -135,7 +137,7 @@ emcmake cmake -DCMAKE_BUILD_TYPE=Release `
135137 -DLLVM_BUILD_TOOLS=OFF `
136138 -DLLVM_ENABLE_LIBPFM=OFF `
137139 -DCLANG_BUILD_TOOLS=OFF `
138- -DLLVM_NATIVE_TOOL_DIR="$env:NATIVE_DIR " `
140+ -DLLVM_NATIVE_TOOL_DIR="$env:NATIVE_LLVM_BIN_DIR " `
139141 -G Ninja `
140142 -DCMAKE_C_FLAGS_RELEASE="-Oz -g0 -DNDEBUG" `
141143 -DCMAKE_CXX_FLAGS_RELEASE="-Oz -g0 -DNDEBUG" `
@@ -184,7 +186,42 @@ $env:CMAKE_PREFIX_PATH=$env:PREFIX
184186$env:CMAKE_SYSTEM_PREFIX_PATH=$env:PREFIX
185187```
186188
187- on Windows. Now to build and test your Emscripten build of CppInterOp using node on Linux and osx execute the following
189+ on Windows. efore building the Emscripten version of CppInterOp, we need
190+ to build `` cppinterop-tblgen `` natively. This tool generates `` .inc `` files
191+ from `` .td `` definitions and must run on the host (not under Emscripten).
192+ We use the native LLVM build from the earlier step since it has the required
193+ `` libLLVMTableGen `` library.
194+
195+ On Linux and osx:
196+
197+ ``` bash
198+ mkdir -p native_cppinterop_build && cd native_cppinterop_build
199+ cmake -DCMAKE_BUILD_TYPE=Release \
200+ -DLLVM_DIR=$NATIVE_LLVM_BUILD_DIR /lib/cmake/llvm \
201+ -DCMAKE_CXX_STANDARD=17 \
202+ -DCPPINTEROP_BUILD_TABLEGEN_ONLY=ON \
203+ ../
204+ cmake --build . --target cppinterop-tblgen -j $( nproc --all)
205+ export CPPINTEROP_TBLGEN_EXE=$( find $PWD -name cppinterop-tblgen -type f | head -1)
206+ cd ..
207+ ```
208+
209+ On Windows:
210+
211+ ``` powershell
212+ mkdir native_cppinterop_build
213+ cd native_cppinterop_build
214+ cmake -DCMAKE_BUILD_TYPE=Release `
215+ -DLLVM_DIR="$env:NATIVE_LLVM_BUILD_DIR\lib\cmake\llvm" `
216+ -DCMAKE_CXX_STANDARD=17 `
217+ -DCPPINTEROP_BUILD_TABLEGEN_ONLY=ON `
218+ ..\
219+ cmake --build . --target cppinterop-tblgen -j $(nproc --all)
220+ $env:CPPINTEROP_TBLGEN_EXE = (Get-ChildItem -Recurse -Filter "cppinterop-tblgen.exe" | Select-Object -First 1).FullName
221+ cd ..
222+ ```
223+
224+ Now to build and test your Emscripten build of CppInterOp using node on Linux and osx execute the following
188225(BUILD_SHARED_LIBS=ON is only needed if building xeus-cpp, as CppInterOp can be built as an Emscripten static library)
189226
190227``` bash
@@ -198,6 +235,7 @@ emcmake cmake -DCMAKE_BUILD_TYPE=Release \
198235 -DCMAKE_FIND_ROOT_PATH_MODE_PACKAGE=ON \
199236 -DCMAKE_INSTALL_PREFIX=$PREFIX \
200237 -DSYSROOT_PATH=$SYSROOT_PATH \
238+ -DCPPINTEROP_TABLEGEN_EXE=$CPPINTEROP_TBLGEN_EXE \
201239 ../
202240emmake make -j $( nproc --all) check-cppinterop
203241```
@@ -216,6 +254,7 @@ emcmake cmake -DCMAKE_BUILD_TYPE=Release `
216254 -DCMAKE_FIND_ROOT_PATH_MODE_PACKAGE=ON `
217255 -DLLVM_ENABLE_WERROR=On `
218256 -DSYSROOT_PATH="$env:SYSROOT_PATH" `
257+ -DCPPINTEROP_TABLEGEN_EXE="$env:CPPINTEROP_TBLGEN_EXE" `
219258 ..\
220259 emmake make -j $(nproc --all) check-cppinterop
221260```
0 commit comments