This test if in preparation for writing a more fully fledged build module. But I need to sus out the basics first. The desire to: - build all the "object files" output to an output folder - link them into a distributable "wasm" binary and format an html page and output them to a "dist" folder.
I looked at the manual in:
https://kripken.github.io/emscripten-site/docs/tools_reference/emcc.html
It's not as intuitive or explicitly spelled out as one would want. Below is my current simple test build.
#!/bin/bash
# set emscripten toolchain paths in this shell
source "${HOME}/emsdk/emsdk_env.sh" --build=Release
BuildDir="./build" # root of output dir for built files
SrcDir="./src" # a source code directory
ObjDir="${BuildDir}/obj" # where intermediate "object" files are output to.
IncludeDir="./include" # an include directory
# start clean for this test
rm -fr "${BuildDir}"
mkdir -p "${ObjDir}" # also re-creates BuildDir
# compile source code out to ObjDir
emcc --default-obj-ext .bc -o "${ObjDir}/" -I "${IncludeDir}" \
"${SrcDir}/hello.cpp" "${SrcDir}/TestClass.cpp"`
Running the above gives me errors but works if there is only one source file.
Is a directory
Traceback (most recent call last):
File "/home/peterk/emsdk/emscripten/incoming/emcc.py", line 3107, in <module>
...
status 1
peterk@5a4a702ca3b5:~/didi-wasmtest/test$
The below works but puts all the output files in the src/ folder and also assigns them the .o suffix and not the .bc suffix: It also outputs a .out.js and a .out.wasm file in the directory the script is run from. I would like to suppress that until a final "link" phase where the results of several compiles would be linked together in a separate step.
emcc --default-obj-ext .bc -I "${IncludeDir}" \
"${SrcDir}/hello.cpp" "${SrcDir}/TestClass.cpp"`