commontk / dcmjs

dcmjs is a javascript cross-compile of dcmtk (dcmtk.org).
http://dcmjs.org
Other
108 stars 20 forks source link

Build wasm module #21

Open jcfr opened 5 years ago

jcfr commented 5 years ago

@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:

https://github.com/commontk/dcmjs/blob/fea79b9c3c2b77aaa078012e1f8335b79f82b39a/CMakeLists.txt#L85-L99

jcfr commented 5 years ago

See https://kripken.github.io/talks/wasm.html and https://github.com/WebAssembly/binaryen

thewtex commented 5 years ago

@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 commented 5 years ago

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 commented 5 years ago

@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 :-)