Files
Arthur Pacaud b1039c6146 Add support for asynchronous actions in extensions in the editor (#4819)
* By marking an action as asynchronous, the actions and sub-events following it will wait for it to end. This is similar to the "Wait X seconds" action.
* Don't forget to use the action *"End asynchronous function"* in the events to mark the end of the action. Otherwise, the action will never end.
2023-02-02 12:30:17 +01:00
..

GDevelop.js

This is the port of GDevelop core classes to WebAssembly+JavaScript. This allows GDevelop Core libraries to run in a browser or on Node.js.

🎮 GDevelop is a full-featured, cross-platform, open-source game development software requiring no programming skills. Download it on the official website.

How to build

👋 Usually, if you're working on the GDevelop editor or extensions in JavaScript, you don't need to rebuild GDevelop.js. If you want to make changes in C++ extensions or classes, read this section.

  • Prerequisite tools installed:

    • CMake 3.17+ (3.5+ should work on Linux/macOS). On macOS, you can install it via Homebrew (recommended for Apple M1 Architectures).
    • Node.js. (We recommend using nvm to be able to switch between Node versions easily).
    • Python (via pyenv for versions management).
  • Install Emscripten, as explained below or on the Emscripten installation instructions:

Linux/macOS Windows
git clone https://github.com/juj/emsdk.git git clone https://github.com/juj/emsdk.git
cd emsdk cd emsdk
git pull git pull
./emsdk install 1.39.6 emsdk install 1.39.6
./emsdk activate 1.39.6 emsdk activate 1.39.6
source ./emsdk_env.sh emsdk_env.bat

⚠️ If you are on Apple M1, this version of emsdk may not be available for this architecture and you will get an error when installing it, indicating a missing binary. If this is the case, a workaround is to modify the emsdk.py line 132 with machine = 'x86_64' to ensure a correct binary is downloaded.

  • Launch the build from GDevelop.js folder:
    cd GDevelop.js
    npm install
    npm run build

⚠️ If the npm install fails, relaunch it in a different terminal using a recent Node.js and npm version (to avoid using the old npm version from Emscripten).

ℹ️ Output is created in /path/to/GD/Binaries/embuild/GDevelop.js/ and also copied to GDevelop 5 IDE (newIDE folder).

-> ⏱ The linking (last step) of the build can be made a few seconds faster by specifying -- --dev. Be sure to remove it before building a release version, as this disable "link-time optimizations" of the generated WebAssembly module.

  • You can then launch GDevelop 5 that will use your build of GDevelop.js:
    cd ..
    cd newIDE/app
    npm install
    npm start

More information in GDevelop 5 readme.

Tests

npm test

About the internal steps of compilation

The npm build task:

  • Creates Binaries/embuild directory,
  • Launches CMake inside to compile GDevelop with emconfigure to use Emscripten toolchain,
  • Updates the glue.cpp and glue.js from Bindings.idl using Emscripten WebIDL Binder,
  • Launches the compilation with make (or ninja on Windows with CMake 3.17+) (you can also compile using MinGW-32 using npm run build-with-MinGW).

See the CMakeLists.txt for the arguments passed to the Emscripten linker. For instance, if you want to see the function names in stacks or for profiling, the compilation flags can be changed.

Documentation