From 2080d11ac8371ec2f54e8f785ff3506b69a4215d Mon Sep 17 00:00:00 2001 From: csmartdalton Date: Thu, 1 Feb 2024 03:54:32 +0000 Subject: [PATCH] Clean up emscripten build * Don't use an external premake extension for emscripten; just set up the environment ourselves to build with emscripten. * Delete the spots that turned on the '-pthread' flag for emscripten. * Get the WebGL and WebGPU builds compiling again and add a github workflow for them. * Delete the bubbles example. It didn't compile on android or wasm and caused confusion. It's in the git history if we want it back. Diffs= ac0d97c12 Clean up emscripten build (#6531) Co-authored-by: Chris Dalton <99840794+csmartdalton@users.noreply.github.com> --- .rive_head | 2 +- build/rive_build_config.lua | 27 ++++++++++++++++++++------ decoders/premake5_v2.lua | 12 +++++++----- dependencies/premake5_harfbuzz_v2.lua | 7 +------ dependencies/premake5_libpng_v2.lua | 9 +++++++++ dependencies/premake5_sheenbidi_v2.lua | 5 ----- premake5_v2.lua | 5 ----- viewer/build/premake5_viewer.lua | 2 +- 8 files changed, 40 insertions(+), 29 deletions(-) diff --git a/.rive_head b/.rive_head index 71b8716a..55fcd076 100644 --- a/.rive_head +++ b/.rive_head @@ -1 +1 @@ -acdaee21fea7a690e2db6d01b8a6d2cd150f1db7 +ac0d97c1243ea3c2e473a319f4eb100fed52e1d5 diff --git a/build/rive_build_config.lua b/build/rive_build_config.lua index 296a235d..713af550 100644 --- a/build/rive_build_config.lua +++ b/build/rive_build_config.lua @@ -362,13 +362,28 @@ if os.host() == 'macosx' then end if _OPTIONS['arch'] == 'wasm' or _OPTIONS['arch'] == 'js' then - -- Target emscripten via https://github.com/TurkeyMan/premake-emscripten.git - -- Premake doesn't properly load the _preload.lua for this module, so we load it here manually. - -- BUG: https://github.com/premake/premake-core/issues/1235 - require('premake-emscripten/_preload') - require('premake-emscripten/emscripten') + -- make a new system called "emscripten" so we don't try including host-os-specific files in the + -- web build. + premake.api.addAllowed('system', 'emscripten') + + -- clone the clang toolset into a custom one called "emsdk". + premake.tools.emsdk = {} + for k, v in pairs(premake.tools.clang) do + premake.tools.emsdk[k] = v + end + + -- update the emsdk toolset to use the appropriate binaries. + local emsdk_tools = { + cc = 'emcc', + cxx = 'em++', + ar = 'emar', + } + function premake.tools.emsdk.gettoolname(cfg, tool) + return emsdk_tools[tool] + end + system('emscripten') - toolset('emcc') + toolset('emsdk') linkoptions({ '-sALLOW_MEMORY_GROWTH' }) diff --git a/decoders/premake5_v2.lua b/decoders/premake5_v2.lua index bbf3bc30..7d35ee22 100644 --- a/decoders/premake5_v2.lua +++ b/decoders/premake5_v2.lua @@ -5,10 +5,12 @@ rive = path.getabsolute('../') dofile(rive .. '/dependencies/premake5_libpng_v2.lua') project('rive_decoders') -dependson('libpng') -kind('StaticLib') -flags({ 'FatalWarnings' }) +do + dependson('libpng') + kind('StaticLib') + flags({ 'FatalWarnings' }) -includedirs({ 'include', '../include', libpng }) + includedirs({ 'include', '../include', libpng }) -files({ 'src/**.cpp' }) + files({ 'src/**.cpp' }) +end diff --git a/dependencies/premake5_harfbuzz_v2.lua b/dependencies/premake5_harfbuzz_v2.lua index 0dbecaad..f5e41795 100644 --- a/dependencies/premake5_harfbuzz_v2.lua +++ b/dependencies/premake5_harfbuzz_v2.lua @@ -218,12 +218,7 @@ do defines({ 'HAVE_OT', 'HB_NO_FALLBACK_SHAPE', 'HB_NO_WIN1256' }) - filter('system:emscripten') - do - buildoptions({ '-pthread' }) - end - - filter('toolset:clang') + filter('toolset:not msc') do flags({ 'FatalWarnings' }) buildoptions({ diff --git a/dependencies/premake5_libpng_v2.lua b/dependencies/premake5_libpng_v2.lua index 325de38a..2c44808d 100644 --- a/dependencies/premake5_libpng_v2.lua +++ b/dependencies/premake5_libpng_v2.lua @@ -59,6 +59,15 @@ do zlib .. '/inflate.c', }) + filter('toolset:not msc') + do + flags({ 'FatalWarnings' }) + buildoptions({ + '-Wno-unknown-warning-option', + '-Wno-deprecated-non-prototype', + }) + end + filter('system:not windows') do defines({ 'HAVE_UNISTD_H' }) diff --git a/dependencies/premake5_sheenbidi_v2.lua b/dependencies/premake5_sheenbidi_v2.lua index 7f251bb8..f7410050 100644 --- a/dependencies/premake5_sheenbidi_v2.lua +++ b/dependencies/premake5_sheenbidi_v2.lua @@ -15,11 +15,6 @@ do linkoptions({ '-r' }) - filter('system:emscripten') - do - buildoptions({ '-pthread' }) - end - filter('options:config=debug') do files({ diff --git a/premake5_v2.lua b/premake5_v2.lua index 7a8c2708..a188abad 100644 --- a/premake5_v2.lua +++ b/premake5_v2.lua @@ -104,11 +104,6 @@ do architecture('x64') defines({ '_USE_MATH_DEFINES' }) end - - filter('system:emscripten') - do - buildoptions({ '-pthread' }) - end end newoption({ diff --git a/viewer/build/premake5_viewer.lua b/viewer/build/premake5_viewer.lua index 01a52393..1f7b2d93 100644 --- a/viewer/build/premake5_viewer.lua +++ b/viewer/build/premake5_viewer.lua @@ -1,4 +1,4 @@ -dofile 'rive_build_config.lua' +dofile('rive_build_config.lua') dependencies = os.getenv('DEPENDENCIES')