- Install the necessary prerequesites for Dahlia.
- Install the Emscripten compiler toolchain
- For more details, see the HVCC Javascript - Getting Started documentation and Mozilla's Compiling a New C/C++ Module to WebAssembly documentation.
- Initialize the Emscripten compiler and configure the environment variables:
# If using Git Bash for Windows, first add 'alias python3=python' to bash aliases
# Don't use the *.bat Windows files as Dahlia isn't configured to run things in cmd
$ ./lib/emsdk/emsdk install latest
$ ./lib/emsdk/emsdk activate latest
# run once per terminal session (automatically handled by 'dahlia.sh')
$ source ./lib/emsdk/emsdk_env.sh
# output should give no warnings and look as below
$ emcc --check
emcc (Emscripten gcc/clang-like replacement + linker emulating GNU ld) <version>
shared:INFO: (Emscripten: Running sanity checks)
- If there's no errors from the above, then everything Dahlia needs for Javascript is ready to go. As a test, return to the
dahlia
root directory and generate for Javascript using HVCC:
# generate for a target (e.g. Javascript/WebAudio) from pd source using HVCC only
$ source ./dahlia.sh js
- If HVCC returns
Error c2js: [WinError 193] %1 is not a valid Win32 application
, there may be an issue with your Python environment or path configuration... or there may not. A (not ideal, possibly terrible) hotfix it is to open the Python scriptc2js.py
located indahlia/.venv/Lib/site-packages/hvcc/generators/c2js/
. Find the three instances wheresubprocess.check_output()
is called in that script, and appendshell=True
as a second argument to all of those calls. Example:
# First instance, around Line 101 in HVCC v0.9
subprocess.check_output(cmd, shell=True)
# Second instance, around Line 108 in HVCC v0.9
subprocess.check_output(cmd, shell=True)
# First instance, around Line 140 in HVCC v0.9
subprocess.check_output( # WASM
cmd + [ # type: ignore
"-s", "WASM=1",
"-s", f"EXPORT_NAME='{output_name}_Module'",
"-o", wasm_js_path
], shell=True)
- Run
source ./dahlia.sh js
again and see if that fixes the issue. If it does, and you suspect the error is due to a bad Python path configuration, it may be possible to identify by adding atraceback
call in anexcept
block following the first call tosubprocess.check_output()
, as follows:
# First call to 'subprocess.check_output()', around Line 101 in HVCC v0.9
try:
subprocess.check_output(cmd) # run emscripten
except Exception:
print(traceback.format_exc())
return
NB: This is tracked by the following Dahlia issue: Javascript/WebAudio generation requires editing HVCC python source #15