prusa3d / PrusaSlicer

G-code generator for 3D printers (RepRap, Makerbot, Ultimaker etc.)
https://www.prusa3d.com/prusaslicer/
GNU Affero General Public License v3.0
7.64k stars 1.92k forks source link

compile the core to WebAssembly #8516

Open smallstepman opened 2 years ago

smallstepman commented 2 years ago

How feasable it would be to compile this to webassembly (leaving GUI aside - i.e. compiling only the core/backend)? Additional GUI in JS would have to get written.

This would setup a path which leads to having PrusaSlicer embedded inside other web clients, like octoprint, fluidd, mainsail etc.

Tristaan commented 1 year ago

Hello @smallstepman! I too am interested in this "feature-request". But as PrusaSlicer has many dependencies, which also need to be compiled to WebAssembly it is a hard task to do. Maybe someone could shed more light on the situation.

EDIT: So i've done some investigations compiling with emscripten and got some of the deps to build:

[  6%] Built target dep_EXPAT
[ 11%] Built target dep_ZLIB
[ 15%] Built target dep_Cereal
[ 15%] Built target dep_MPFR
[ 22%] Built target dep_GLEW
[ 27%] Built target dep_NLopt
[ 31%] Built target dep_Qhull
[ 35%] Built target dep_JPEG

The other deps don't build. After looking at them, the problem with some of them lies that a wrong CXX compiler config is used, or some other em++ issue. Some also throw errors.

The deps not configuring are:

The deps not building are:

EDIT: I Got Boost to build with .jam file modifications, a toolset for b2 called emscripten exists. GMP is also compileable after changing the host to none (--host=none) and modifying ./configure to execute a.wasm with wasm-shell. More deps working out of the box added. PNG building with PNG.cmake modifications. CURL is problematic as it requires OpenSSL, which is not built before it.