The commands to build the pipelines are:
pnpm emscripten-build
-> alias foremscripten-build:release
pnpm emscripten-build:release
-> build in releasepnpm emscripten-build:debug
-> build in debug
Vite will take the new built files into account using the plugin vite-plugin-static-copy
.
The built files will be copied as soon as itk-wasm is done building, thanks to the reloadPageOnChange
option of the plugin. This means that there is no need to restart the dev server every time you run an emscripten-build
.
Debuging directly from the wasm files generated by pnpm emscripten-build
is hard.
You can follow the instruction given in the itk-wasm documentation along with the command pnpm emscripten-build:debug
.
Example of path subsitution in Dwarf options on Windows: /work/
-> file:///C:/.../UPennContrast/itk/
.
It is hard to put a breakpoint when the pipeline is fast. There is no real solution to this problem except running the pipeline and pause the execution in the debugger with the right timming.
Debugging with DWARF in Chrome often fails with an error which says that the debug symbols can't be found. But after several tries (launch the pipeline several times), it founds the symbols and debugging works.
Go in the directory with the ITK sources and run a command that looks like this (change the last path):
python .\Utilities\Maintenance\WhatModulesITK.py . C:\dev\UPenn\UPennContrast\itk\MaskToBlob\main.cxx
Also add: WebAssemblyInterface
to the needed itk components (it is not found by the script).
Not working with the master version of ITK, but it works with ITK 5.2.1.
See this page of the documentation for information on how to build ITK and itk-wasm, and build natively.
To sum up, this is how to build and test ITK and itk-wasm:
# Build ITK
git clone https://github.com/InsightSoftwareConsortium/ITK
cmake -BITK-build -SITK -DBUILD_TESTING=OFF -DModule_MeshToPolyData=ON
cmake --build ITK-build
# Build the WebAssemblyInterface module from this module against ITK
git clone https://github.com/InsightSoftwareConsortium/itk-wasm
cmake -Bitk-wasm-build -Sitk-wasm -DBUILD_TESTING=ON -DITK_DIR=$PWD/ITK-build
cmake --build itk-wasm-build
# Run the tests
ctest --test-dir itk-wasm-build
Build the project (change the paths to match your setup):
cd C:\dev\UPenn\UPennContrast\itk
cmake -Bbuild -DITK_DIR=C:/dev/ITK-WASM/ITK-build
cmake --build build
On Windows, you can use the generated .sln
file to open the project in Visual Studio.
If you don't want to pollute your project folder with many VS files:
- Open this folder (
UPenn/itk
) in VS: Open VS -> Open a local folder - Specify ITK_DIR (build directory of ITK) to CMake: Right click CMakeLists.txt -> CMake Settings for ...
- To give cli arguments to your startup items: Debug -> Debug and launch settings for ... -> Add a line
"args": ["foo", "bar"]