Skip to content
abergmeier edited this page Apr 15, 2013 · 25 revisions

This page should outline the idea of making (common) libraries available to Emscripten users.

Idea

Provide commonly used libraries at a centralized location, so additional external libraries might be build without having to patch their build system for Emscripten.

Prototype

Since Emscripten has not support for dynamic libraries and/or their file format a solution should not rely on the dynamic library infrastructure. On Debian systems installing a library usually is done via dpkg or apt tools. Arguments necessary for linking with a library are commonly provided by invoking pkg-config.

These mechanism could be adopted for Emscripten in a simplified manner.

empkg-get - a tool for downloading libraries working with Emscripten

empkg-get <package name> <package name> ...
  1. Downloads the <package name>/versions file from https://github.com/abergmeier/emscripten-libs for every package.
  2. Finds the highest/latest version.
  3. Checks whether the directory EM_CACHE/build/<package name>/<version> is available and warns for overwrite if it is.
  4. On success downloads (and overwrites) the version to EM_CACHE/build/<package name>/<version>.

empkg-build - a tool to build downloaded library sources

empkg-build [--ensure] <package name> <package name>
  1. If --ensure argument is present, tries to invoke empkg-get first and fail if it fails.
  2. If a valid build timestamp is found return successfully.
  3. Invoke EM_CACHE/build/<package name>/<version>/.emscripten/build for building.
  4. If building succeeds, create new build timestamp file.

empkg-config - a tool for getting building/linking configuration of library

empkg-config [--cflags] [--libs] [--ensure] <package name> <package name>
  1. If --ensure argument is present, tries to invoke empkg-build first and fail if it fails.
  2. Returns the contents of config section in versions.
Format of versions:

The versions file is a JSON version of the pkg-config format with additional source information. Entries in the upper section are derived by the version sections. Properties in config are substituted with the current Environment and prefix is set to build directory.

{ "name"       : "zlib",
  "description": "zlib compression library",
  "maintainers": [ { "name" : "Alon Zakai",
                     "email": "[email protected]"
                   }
  ],
  "config"     : { "cflags": "-I${prefix}/include",
                   "libs"  : "-L${prefix}"
  },  
  "versions"   : [ { "version": "1.2.7",
                     "src"    : "https://github.com/madler/zlib/archive/v1.2.7.zip"
                   },
                   { "version": "1.2.5",
                     "src"    : "https://raw.github.com/kripken/emscripten/master/tests/zlib/1.2.5.zip"
                   }
  ]
}

Pro

  • Less to no work for users
  • Higher chances for pushing patches upstream
  • Maintainance necessary

Contra

  • Might not fit every usage scenario
  • Library has to be available via sourcecode