Update examples to build on Emscripten Wasm. Add separate wasm and wasm2js targets.

This commit is contained in:
Jukka Jylänki
2020-05-16 11:16:29 +03:00
committed by Бранимир Караџић
parent 0de0fa8ab8
commit 8d1e6bbe75
2 changed files with 21 additions and 12 deletions

View File

@@ -9,6 +9,8 @@
#include "allocator.h" #include "allocator.h"
#include "mpscqueue.h" #include "mpscqueue.h"
#if BX_CONFIG_SUPPORTS_THREADING
namespace bx namespace bx
{ {
/// ///
@@ -87,4 +89,6 @@ namespace bx
} // namespace bx } // namespace bx
#endif
#endif // BX_THREAD_H_HEADER_GUARD #endif // BX_THREAD_H_HEADER_GUARD

View File

@@ -52,7 +52,8 @@ function toolchain(_buildDir, _libDir)
{ "android-arm", "Android - ARM" }, { "android-arm", "Android - ARM" },
{ "android-arm64", "Android - ARM64" }, { "android-arm64", "Android - ARM64" },
{ "android-x86", "Android - x86" }, { "android-x86", "Android - x86" },
{ "asmjs", "Emscripten/asm.js" }, { "wasm2js", "Emscripten/Wasm2JS" },
{ "wasm", "Emscripten/Wasm" },
{ "freebsd", "FreeBSD" }, { "freebsd", "FreeBSD" },
{ "linux-gcc", "Linux (GCC compiler)" }, { "linux-gcc", "Linux (GCC compiler)" },
{ "linux-gcc-afl", "Linux (GCC + AFL fuzzer)" }, { "linux-gcc-afl", "Linux (GCC + AFL fuzzer)" },
@@ -251,10 +252,10 @@ function toolchain(_buildDir, _libDir)
premake.gcc.llvm = true premake.gcc.llvm = true
location (path.join(_buildDir, "projects", _ACTION .. "-android-x86")) location (path.join(_buildDir, "projects", _ACTION .. "-android-x86"))
elseif "asmjs" == _OPTIONS["gcc"] then elseif "wasm2js" == _OPTIONS["gcc"] or "wasm" == _OPTIONS["gcc"] then
if not os.getenv("EMSCRIPTEN") then if not os.getenv("EMSCRIPTEN") then
print("Set EMSCRIPTEN environment variable.") print("Set EMSCRIPTEN environment variable to root directory of your Emscripten installation. (e.g. by entering the EMSDK command prompt)")
end end
premake.gcc.cc = "\"$(EMSCRIPTEN)/emcc\"" premake.gcc.cc = "\"$(EMSCRIPTEN)/emcc\""
@@ -262,7 +263,7 @@ function toolchain(_buildDir, _libDir)
premake.gcc.ar = "\"$(EMSCRIPTEN)/emar\"" premake.gcc.ar = "\"$(EMSCRIPTEN)/emar\""
premake.gcc.llvm = true premake.gcc.llvm = true
premake.gcc.namestyle = "Emscripten" premake.gcc.namestyle = "Emscripten"
location (path.join(_buildDir, "projects", _ACTION .. "-asmjs")) location (path.join(_buildDir, "projects", _ACTION .. "-" .. _OPTIONS["gcc"]))
elseif "freebsd" == _OPTIONS["gcc"] then elseif "freebsd" == _OPTIONS["gcc"] then
location (path.join(_buildDir, "projects", _ACTION .. "-freebsd")) location (path.join(_buildDir, "projects", _ACTION .. "-freebsd"))
@@ -932,22 +933,26 @@ function toolchain(_buildDir, _libDir)
"-target i686-none-linux-android", "-target i686-none-linux-android",
} }
configuration { "asmjs" } configuration { "wasm*" }
targetdir (path.join(_buildDir, "asmjs/bin"))
objdir (path.join(_buildDir, "asmjs/obj"))
libdirs { path.join(_libDir, "lib/asmjs") }
buildoptions { buildoptions {
"-Wunused-value", "-Wunused-value",
"-Wundef", "-Wundef",
} }
linkoptions { linkoptions {
-- "-s ASSERTIONS=2", "-s MAX_WEBGL_VERSION=2"
-- "-s EMTERPRETIFY=1",
-- "-s EMTERPRETIFY_ASYNC=1",
"-s PRECISE_F32=1",
} }
configuration { "wasm2js" }
targetdir (path.join(_buildDir, "wasm2js/bin"))
objdir (path.join(_buildDir, "wasm2js/obj"))
libdirs { path.join(_libDir, "lib/wasm2js") }
configuration { "wasm" }
targetdir (path.join(_buildDir, "wasm/bin"))
objdir (path.join(_buildDir, "wasm/obj"))
libdirs { path.join(_libDir, "lib/wasm") }
configuration { "freebsd" } configuration { "freebsd" }
targetdir (path.join(_buildDir, "freebsd/bin")) targetdir (path.join(_buildDir, "freebsd/bin"))
objdir (path.join(_buildDir, "freebsd/obj")) objdir (path.join(_buildDir, "freebsd/obj"))