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

Fix the AnyPIAJS tests: Recompile AnyPIAJS for NodeJS #209

Closed
thadk opened this issue Sep 2, 2020 · 0 comments · Fixed by #289
Closed

Fix the AnyPIAJS tests: Recompile AnyPIAJS for NodeJS #209

thadk opened this issue Sep 2, 2020 · 0 comments · Fixed by #289

Comments

@thadk
Copy link
Member

thadk commented Sep 2, 2020

Make another build of AnyPIAJS with the latest version for late 2020, and that works with NodeJS.

I used the below line to replace https://github.com/codeforboston/anypia-js/blob/master/anypiajs/CMakeLists.txt#L67 along with ./installbuild-emscripten-mac.sh to compile it for this project using the July 2020 version of Emscripten.

In this repo, I permanently cached a version of the generated 1.9mb web assembly binary file as /src/static/anypiajs.wasm (it is a special Gatsby folder like /public/). I also added the associated file https://github.com/codeforboston/windfall-elimination/blob/243a300b9ad7316bb6af586f6d15ec060b7610f9/src/library/anypiajs.mjs.

set_target_properties(${PROJECT_NAME} PROPERTIES COMPILE_FLAGS "-s USE_BOOST_HEADERS=1" LINK_FLAGS "-s USE_BOOST_HEADERS=1 -s EXPORT_ES6=1 -s USE_ES6_IMPORT_META=1 -s ENVIRONMENT=web -MODULARIZE=1 -s WASM=1 --bind ${EXPORTED_FUNCTIONS} ${EXPORTED_RUNTIME_METHODS}")

In the resulting anypiajs.mjs, I had to manually edit

var Module = (function() {
  var _scriptDir = import.meta.url;

to

var Module = (function() {
  var _scriptDir = "/anypiajs.wasm";

This ENVIRONMENT=web piece breaks nodejs testing though, so the tests I wrote in https://github.com/codeforboston/windfall-elimination/blob/243a300b9ad7316bb6af586f6d15ec060b7610f9/src/test/pia-index.test.ts cannot run yet.

If we make another version, we should make a new versioned name for this wasm filename (and update the path in the manual edit, since that one will be permanently cached once we merge it)

@thadk thadk changed the title Recompile AnyPIAJS for NodeJS Fix the AnyPIAJS tests: Recompile AnyPIAJS for NodeJS Sep 2, 2020
thadk added a commit to thadk/windfall-elimination that referenced this issue Aug 11, 2021
@thadk thadk linked a pull request Aug 11, 2021 that will close this issue
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant