kripken/emscripten — pull request #2809 by NWilson (2014-09-19 17:51:28+00:00)
Title: Add support for placing JavaScript libraries in static libs

This patch makes our build process massively, massively simpler!

Our code is split into a few dozen libraries, and some of them now have accompanying files needing `--js-library`. This is a problem for our cmake setup, which can't easily pass the filenames through from a base library to the final link commandline.

This commit makes emscripten behave a bit more like a standard compiler, but allowing `.jso` files to be "compiled" to `.jso.o` files and included in static libraries. They get used at the link stage.

emcc myfile.c -c -o myfile.c.o
# pretend to "compile" it to make the build system happy, really just copies it:
emcc myjslib.jso -c -o myjslib.jso.o
emar rc libtest.a myfile.c.o myjslib.jso.o
emcc app.c -c -o app.c.o
# uses the js files inside libtest.a as if passed with --js-library
emcc -o app.html app.c.o libtest.a

This also makes dependency management for incremental builds very simple since it looks to the build system just like a standard source file. Much nicer than the hacky dependency stuff in the existing emscripten cmake module.

If you have an idea for implementing this sort of build setup without this extension I'd be grateful, but this seems like the path of least resistance to me!