This is my current solution:
I have a linux Makefile with the usual target, it links a previously generated static library and outputs an executable.
The code acts upon the WEB define with ifdefs.
The Makefile for the library acts upon the TARGET enviroment variable for the platform specific sources:
ifeq ($(TARGET),WEB)
MODULES = RenderingEngine2.o RenderingEngine1.o WebApp.o main.o
else
MODULES = RenderingEngine2.o RenderingEngine1.o LinuxApp.o main.o
endif
- Along the Makefile there is a bash script called emscripten.sh with the following content:
#!/bin/bash
make TARGET="WEB" CXX="em++ -DWEB" AR="emar" modules
make TARGET="WEB" CXX="em++ -DWEB" AR="emar"
emcc --preload-file assets -o bin/helloArrow.html bin/helloArrow bin/lib.o
firefox bin/helloArrow.html
- Compile and execute with ./emscripten.sh
NOTE: emscripten doesn't seem to like .a extension in static libraries so name you library with .o extension.