From 864abac52b4600293342ef66fb76c8599ed1e78a Mon Sep 17 00:00:00 2001 From: M4x1m3 Date: Sun, 10 Nov 2019 13:47:43 +0100 Subject: [PATCH 1/2] [ion/simulator] Allow web-simulator to be built. --- build/toolchain.emscripten.mak | 7 ++++++- ion/src/simulator/shared/main_sdl.cpp | 3 +++ ion/src/simulator/web/simulator.html | 2 +- 3 files changed, 10 insertions(+), 2 deletions(-) diff --git a/build/toolchain.emscripten.mak b/build/toolchain.emscripten.mak index 9ac1010a2..b2fa4b714 100644 --- a/build/toolchain.emscripten.mak +++ b/build/toolchain.emscripten.mak @@ -8,6 +8,8 @@ SAFE_HEAP_STORE \ _IonEventsEmscriptenKeyDown \ _IonEventsEmscriptenKeyUp \ _IonEventsEmscriptenPushEvent \ +_IonSimulatorCallbackDidScanKeyboard \ +__Z8ion_mainiPKPKc \ __Z8ion_mainiPPc \ __ZN10Invocation7performEPv \ __ZN11MicroPython20ExecutionEnvironment7runCodeEPKc \ @@ -108,8 +110,11 @@ EMFLAGS += --profiling-funcs EMFLAGS += -s ASSERTIONS=1 EMFLAGS += -s SAFE_HEAP=1 EMFLAGS += -s STACK_OVERFLOW_CHECK=1 +EMFLAGS += -s DEMANGLE_SUPPORT=1 endif +# EMFLAGS += -s ERROR_ON_UNDEFINED_SYMBOLS=0 + # Configure EMFLAGS EMFLAGS += -s WASM=0 @@ -120,4 +125,4 @@ EMSCRIPTEN_INIT_FILE ?= 0 LDFLAGS += --memory-init-file $(EMSCRIPTEN_INIT_FILE) SFLAGS += $(EMFLAGS) -LDFLAGS += $(EMFLAGS) -Oz -s EXPORTED_FUNCTIONS='["_main", "_IonSimulatorKeyboardKeyDown", "_IonSimulatorKeyboardKeyUp", "_IonSimulatorEventsPushEvent", "_IonSoftwareVersion", "_IonPatchLevel"]' -s EXTRA_EXPORTED_RUNTIME_METHODS='["UTF8ToString"]' +LDFLAGS += $(EMFLAGS) -Oz -s EXPORTED_FUNCTIONS='["_main", "_IonSimulatorKeyboardKeyDown", "_IonSimulatorKeyboardKeyUp", "_IonSimulatorEventsPushEvent", "_IonSoftwareVersion", "_IonPatchLevel"]' -s EXTRA_EXPORTED_RUNTIME_METHODS='["UTF8ToString", "Pointer_stringify"]' diff --git a/ion/src/simulator/shared/main_sdl.cpp b/ion/src/simulator/shared/main_sdl.cpp index d4aca04c3..06652578c 100644 --- a/ion/src/simulator/shared/main_sdl.cpp +++ b/ion/src/simulator/shared/main_sdl.cpp @@ -122,9 +122,12 @@ void init() { Display::init(sRenderer); + // No need to load background in web simulator. + #ifndef __EMSCRIPTEN__ if (!argument_screen_only) { sBackgroundTexture = IonSimulatorLoadImage(sRenderer, "background.jpg"); } + #endif relayout(); } diff --git a/ion/src/simulator/web/simulator.html b/ion/src/simulator/web/simulator.html index 5de5de636..d733dac5e 100644 --- a/ion/src/simulator/web/simulator.html +++ b/ion/src/simulator/web/simulator.html @@ -298,6 +298,6 @@ window.addEventListener("keydown", function(e) { } }, false); - + From d42a6c651486d5fd8a7e81bcf471efa383f5967d Mon Sep 17 00:00:00 2001 From: M4x1m3 Date: Sun, 10 Nov 2019 14:29:55 +0100 Subject: [PATCH 2/2] Added web simulator build instructions in README. --- README.md | 22 ++++++++++++++++++++++ 1 file changed, 22 insertions(+) diff --git a/README.md b/README.md index a270ac6b3..366e504a9 100644 --- a/README.md +++ b/README.md @@ -47,6 +47,28 @@ make USERNAME="{Your name, max 15 characters}" -j4 make epsilon_flash ``` +* Building the **web simulator** (works under linux): + +First, install emsdk : +``` +git clone https://github.com/emscripten-core/emsdk.git +cd emsdk +./emsdk install latest-fastcomp +./emsdk activate latest-fastcomp +source emsdk_env.sh +``` + +Then, compile Omega : +``` +git clone --recursive https://github.com/Omega-Numworks/Omega.git +cd Omega +make clean +make PLATFORM=simulator TARGET=web USERNAME="{Your name, max 15 characters}" -j4 +``` + +The simulator is now in `output/release/simulator/web/simulator.zip` + + Important: Don't forget the `--recursive` tag, because Omega relies on submodules. Also, you can change the number of processes that run in parallel during the build by changing the value of the `-j` flag.