Skip to content

Commit

Permalink
Clean up emscripten build
Browse files Browse the repository at this point in the history
* 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 <[email protected]>
  • Loading branch information
csmartdalton and csmartdalton committed Feb 1, 2024
1 parent d67eaa0 commit 2080d11
Show file tree
Hide file tree
Showing 8 changed files with 40 additions and 29 deletions.
2 changes: 1 addition & 1 deletion .rive_head
Original file line number Diff line number Diff line change
@@ -1 +1 @@
acdaee21fea7a690e2db6d01b8a6d2cd150f1db7
ac0d97c1243ea3c2e473a319f4eb100fed52e1d5
27 changes: 21 additions & 6 deletions build/rive_build_config.lua
Original file line number Diff line number Diff line change
Expand Up @@ -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' })

Expand Down
12 changes: 7 additions & 5 deletions decoders/premake5_v2.lua
Original file line number Diff line number Diff line change
Expand Up @@ -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
7 changes: 1 addition & 6 deletions dependencies/premake5_harfbuzz_v2.lua
Original file line number Diff line number Diff line change
Expand Up @@ -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({
Expand Down
9 changes: 9 additions & 0 deletions dependencies/premake5_libpng_v2.lua
Original file line number Diff line number Diff line change
Expand Up @@ -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' })
Expand Down
5 changes: 0 additions & 5 deletions dependencies/premake5_sheenbidi_v2.lua
Original file line number Diff line number Diff line change
Expand Up @@ -15,11 +15,6 @@ do

linkoptions({ '-r' })

filter('system:emscripten')
do
buildoptions({ '-pthread' })
end

filter('options:config=debug')
do
files({
Expand Down
5 changes: 0 additions & 5 deletions premake5_v2.lua
Original file line number Diff line number Diff line change
Expand Up @@ -104,11 +104,6 @@ do
architecture('x64')
defines({ '_USE_MATH_DEFINES' })
end

filter('system:emscripten')
do
buildoptions({ '-pthread' })
end
end

newoption({
Expand Down
2 changes: 1 addition & 1 deletion viewer/build/premake5_viewer.lua
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
dofile 'rive_build_config.lua'
dofile('rive_build_config.lua')

dependencies = os.getenv('DEPENDENCIES')

Expand Down

0 comments on commit 2080d11

Please sign in to comment.