SWI-Prolog / swipl-devel

SWI-Prolog Main development repository
http://www.swi-prolog.org
Other
974 stars 175 forks source link

Generate `swipl.wasm` and `swipl.data` #1163

Open jeswr opened 1 year ago

jeswr commented 1 year ago

Currently there is a PR open in npm-swipl-wasm to properly use swipl.js for node rather than copying swipl-web.js to swipl.js (see https://github.com/SWI-Prolog/npm-swipl-wasm/pull/101).

As can be seen in the CI; this is currently failing because there is no swipl.wasm or swipl.data available; and it would appear that they are not being generated by https://github.com/SWI-Prolog/swipl-devel/blob/master/cmake/EmscriptenTargets.cmake in the way that https://github.com/SWI-Prolog/swipl-devel/blob/a5116396306d5107bb9ba6c319a239f9fc9f9733/cmake/EmscriptenTargets.cmake#L50-L61 is.

So my question is; are swipl.wasm and swipl.data going to be the same as the swipl-web.wasm and swipl-web.data; in which case we can just take a short term solution of duplicating those files; or patching the lookup paths in the generated .js files. Or do we need to generate distinct swipl.wasm and swipl.data from EmscriptenTargets.cmake - in which case I'd ask someone else with more expertise to take it on as I am going to be time poor for the next couple of months.

JanWielemaker commented 1 year ago

I don't know that much about the WASM build. AFAIK though, we build swipl.js/wasm such that it uses the native filesystem, which you can see if you run node src/swipl.js in the build directory. We need such a version to perform the Prolog build steps, producing home/boot.prc and the various .qlf (Quick Load File) files.

jeswr commented 1 year ago

So does this mean an update to the cmake file is required?

JanWielemaker commented 1 year ago

I don't know what to think about swipl.js/wasm. I am inclined to consider it just an intermediate build product. We could also distribute it along with a the libraries as a file hierarchy, so you get something similar to the normal distributions that consist of the executable and the libraries. Wasn't it true that swipl-web.js and the bundles also run under Node? If that is true the only thing wrong seems the misleading "web" in the name?