Skip to content

CMake Emscripten (Linux) setup

fredakilla edited this page Jul 15, 2018 · 7 revisions

Install Emscripten

See: https://kripken.github.io/emscripten-site/docs/getting_started/downloads.html

Set emscripten build environment

Open a terminal:

cd EMSCRIPTEN_INSTALL_DIR (your emscripten root directory)
source emsdk_env.sh

Install submodules dependencies

Some thirdparty libraries are registered as submodules, you need to install them before compiling.

cd GPlayEngine
git submodule init
git submodule update

First step : Building third-party libraries

Third-party libraries are built independently of GPlayEngine and must be builded before anything.
This step is also necessary to prepare output directories.
Run the following from the top-level directory of your GPlayEngine repository:

cd thirdparty
mkdir BUILD
cd BUILD
emcmake cmake ..
make -j12 (X number should be 1.5x the number of cores you have)

Second step : Prepare game data for emscripten

Game data need to be embedded in a file that will be preloaded into Emscripten’s virtual file system. Game data file is created at build time from content of "emdata" directory: (or adjust path in CMakeList.txt)

  • Before compiling, in the output/bin directory, create a new dir named "emdata"
  • Copy inside the GPlayEngine "res" directory
  • Remove default data directory and create a new one.
  • Copy inside only required assets your game need.

Final step : Building GPlayEngine library and samples

Run the following from the top-level directory of your GPlayEngine repository:

mkdir BUILD
cd BUILD
emcmake cmake ..
make -j12 (X number should be 1.5x the number of cores you have)

Running a sample (Ex. sample-minimal)

In the output/bin directory, open the minimal.sample.html file with your web browser.