-
Notifications
You must be signed in to change notification settings - Fork 0
Library Support
This page should outline the idea of making (common) libraries available to Emscripten users.
Provide commonly used libraries at a centralized location, so additional external libraries might be build without having to patch their build system for Emscripten.
Since Emscripten has not support for dynamic libraries and/or their file format a solution should not rely on the dynamic library infrastructure.
Building for Unix systems it is common for packages to provide the means to link to them via pkg-config
files. Similarly this mechanism could be adopted for Emscripten.
An example for building and linking with zlib in a Makefile
:
CFLAGS := $(shell pkg-config --cflags zlib)
# Some build command
LDFLAGS := $(shell pkg-config --libs zlib)
# Some link command
Utilizing this way of retrieving necessary information for zlib we could provide zlib to the user.
A new script empkg-config
would do the following:
- Download the
<package name>/versions
file from https://github.com/abergmeier/emscripten-libs or fail if no package directory is available. - Find the highest (latest) version in
versions
file. - Check in
EM_CACHE/build/<package name><latestversion>
whether there is a valid build-timestamp file. If there is go to 5. - Download the latest version from the
src
inversions
. - Attempt to execute the
build
command from the configuration. - Return failure or success depending whether build did work.
The versions
file is a JSON version of the pkg-config format with additional source information.
{ "name" : "zlib",
"description": "zlib compression library",
"src" : { "git": { "repo": "git://github.com/madler/zlib.git" }
},
"build" : "make EMSCRIPTEN=1",
"versions" : [ { "version": "1.2.7",
"libs" : "somestring",
"cflags" : "somestring",
"src" : { "git": { "tag": "1.2.7" }
}
},
{ "version": "1.2.6.1",
"libs" : "somestring",
"cflags" : "somestring",
"src" : { "git": { "tag": "1.2.6.1" }
}
}
]
}
- Less to no work for users
- Higher chances for pushing patches upstream
- Maintainance necessary
- Might not fit every usage scenario
- Library has to be available via sourcecode