Skip to content
This repository was archived by the owner on Jul 27, 2022. It is now read-only.

Build System Configuration

Nick Bray edited this page Oct 9, 2013 · 1 revision

Note: configuring the build system to use pepper.js is currently a little complicated. The instructions will likely change in future versions. Expect that you may need to update your build when pulling a new version of pepper.js.

Building an example with V=1 TOOLCHAIN=emscripten will show the flags being passed to Emscripten. If you want to set up your own build system, there's a few flags you must pass to the linker to use pepper.js. Here's a flag-by-flag breakdown of what's going on when the examples are built.

-s RESERVED_FUNCTION_POINTERS=325

pepper.js creates function tables for each PPAPI interfaces at runtime. Emscripten requires that space for each function pointer is reserved at link time.

-s TOTAL_MEMORY=33554432

Emscripten defaults to a 16 MB address space, which may to be too small. Tune the size for your particular application.

-lppapi

The "ppapi" library contains boilerplate needed to bind the PPAPI plugin to JS.

-s EXPORTED_FUNCTIONS="['_DoPostMessage', '_DoChangeView', '_DoChangeFocus', '_NativeCreateInstance', '_HandleInputEvent']"

These functions are called by pepper.js, and they must be exported by your application.

To make pepper.js work Emscripten needs to include a number of files using the --pre-js flag. In all cases, ppapi_preamble.js must be included. Depending on what interfaces the program being compiled needs, the corresponding files in the wrappers/ directory must be included. If you are using the File IO API, you will also need to include third_party/idb.filesystem.js. This situation will hopefully be changed in the future to minimize the number of command line flags required.

--closure 1

Emscripten has a built-in option to use the Closure Compiler to minimize the JavaScript it generates. This option should only be used for release builds because minification obfuscates the generated code, similar to optimization passes in C compilers. The minimization process renames variables and methods. To maintain correctness, the Closure Compiler needs to avoid renaming variables and methods that are built in to the browser. If it renames built-in names, the resulting program breaks. pepper.js uses a number of relatively new APIs that Closure does not know about, yet. Closure will mangle these names unless it is explicitly told to preserve them. To prevent these APIs from being mangled, they can be declared "extern" in a JavaScript file and passed to Closure. Emcsripten calls Closure internally, and extern declarations must be tunneled to Closure through an environment variable rather than being passed on the command line.

EMCC_CLOSURE_ARGS=--externs $(PEPPERJS_SRC_ROOT)/externs.js --externs $(PEPPERJS_SRC_ROOT)/third_party/w3c_audio.js

Clone this wiki locally