Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Build wasm module #21

Open
jcfr opened this issue Dec 11, 2018 · 4 comments
Open

Build wasm module #21

jcfr opened this issue Dec 11, 2018 · 4 comments

Comments

@jcfr
Copy link
Member

jcfr commented Dec 11, 2018

@thewtex Based on your experience with itk-js, could you point us to relevant documentation/example to make this happen.

Here are the emscripten options we currently use:

dcmjs/CMakeLists.txt

Lines 85 to 99 in fea79b9

set(CMAKE_C_COMPILER "${EMSCRIPTEN_ROOT_PATH}/emcc")
set(CMAKE_CXX_COMPILER "${EMSCRIPTEN_ROOT_PATH}/em++")
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wno-warn-absolute-paths -s ALLOW_MEMORY_GROWTH=1 -s ASSERTIONS=1 --memory-init-file 0")
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -Wno-warn-absolute-paths -s ALLOW_MEMORY_GROWTH=1 -s ASSERTIONS=1 --memory-init-file 0")
# Emscripten toolchain options
set(EMSCRIPTEN_TOOLCHAIN_OPTIONS
-DCMAKE_MODULE_PATH:PATH=${EMSCRIPTEN_ROOT_PATH}/cmake/Modules
-DCMAKE_TOOLCHAIN_FILE:FILEPATH=${EMSCRIPTEN_ROOT_PATH}/cmake/Modules/Platform/Emscripten.cmake
-DCMAKE_CXX_COMPILER:FILEPATH=${CMAKE_CXX_COMPILER}
-DCMAKE_CXX_FLAGS:STRING=${CMAKE_CXX_FLAGS}
-DCMAKE_C_COMPILER:FILEPATH=${CMAKE_C_COMPILER}
-DCMAKE_C_FLAGS:STRING=${CMAKE_C_FLAGS}
-DCMAKE_BUILD_TYPE:STRING=${CMAKE_BUILD_TYPE}
)

@jcfr
Copy link
Member Author

jcfr commented Dec 12, 2018

@thewtex
Copy link

thewtex commented Dec 15, 2018

@jcfr The option is -s WASM=1.

I would recommend using itk.js. Among the benefits, it includes:

  1. Building both an asm.js and wasm module for you and using the asm.js on browsers that do not have wasm support transparently.
  2. Bundles and locates files so you do not have difficulty finding WASM assets (you will run into this issues if you try doing it without itk.js, and you will run into more issue if you try using the module outside of the dcm.js example).
  3. Execution in a web worker to improve interactivity in the main thread.

@jcfr
Copy link
Member Author

jcfr commented Dec 15, 2018

It would be neat to levrage itk-js infrastructure, are you suggesting we update itk-js project so that we can reuse its infrastructure ? Or adding dcmjs as an itk-js plugin ?

@thewtex
Copy link

thewtex commented Dec 15, 2018

@jcfr itk.js could be used as-is to perform the dcm.js build. The steps are

  1. Set up to use the insighttoolkit/itk-js dockcross image for the build.
  2. Slight tweaks to how the module execution is invoked.
  3. Maybe something else, but I will be happy to help if there are any issues :-)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Development

No branches or pull requests

2 participants