From c18e964c4253575f8b983b14f1a7b0205114c43a Mon Sep 17 00:00:00 2001 From: JoshJRive Date: Tue, 21 Oct 2025 21:11:40 +0000 Subject: [PATCH] fix(build): Correct tracking of intended target OS in premake (#10853) c7a0379ab3 We've been testing _TARGET_OS in a lot of places in our build, but that is not actually updated in Android/Emscripten builds (it would continue to report, say, Windows). Among other things, this meant that we would build D3D12 shaders for every Android build, even though they were not needed. This adds a `rive_target_os` value to `rive_build_config.lua` which is updated manually for those two projects, so that scripts won't do the Windows/mac things when building for android/emscripten on those platforms. Co-authored-by: Josh Jersild --- .rive_head | 2 +- build/rive_build_config.lua | 13 +++++++++++++ renderer/premake5.lua | 2 +- renderer/premake5_pls_renderer.lua | 6 +++--- tests/rive_tools_project.lua | 2 +- 5 files changed, 19 insertions(+), 6 deletions(-) diff --git a/.rive_head b/.rive_head index e798425f..a79b7db7 100644 --- a/.rive_head +++ b/.rive_head @@ -1 +1 @@ -39741ac0c89ef4af6214bf2ec0f2130e489d8ed0 +c7a0379ab3bd3ec3fb9b2ed26d5b238b93a26976 diff --git a/build/rive_build_config.lua b/build/rive_build_config.lua index d4336ed9..b1ae1456 100644 --- a/build/rive_build_config.lua +++ b/build/rive_build_config.lua @@ -403,10 +403,21 @@ end filter({}) +-- os.target() does not seem to be getting updated when system( ) is changed (for instance, when +-- building on Windows, it stays 'windows' even after we do system('android') which means if we +-- use it directly, we will include more things than are strictly necessary. +-- +-- Instead, make an alias that we can use instead that we set manually based on calls to system() +-- Additionally, premake deprecated `--os=android` which is why the custom system() call is +-- needed in the first place (otherwise the build script would just be passing it in) +rive_target_os = os.target() + -- Don't use filter() here because we don't want to generate the "android_ndk" toolset if not -- building for android. if _OPTIONS['for_android'] then system('android') + rive_target_os = 'android' + pic('on') -- Position-independent code is required for NDK libraries. -- Detect the NDK. @@ -766,6 +777,8 @@ if _OPTIONS['arch'] == 'wasm' or _OPTIONS['arch'] == 'js' then end system('emscripten') + rive_target_os = 'emscripten' + toolset('emsdk') linkoptions({ '-sALLOW_MEMORY_GROWTH=1', '-sDYNAMIC_EXECUTION=0' }) diff --git a/renderer/premake5.lua b/renderer/premake5.lua index 7dffb712..57d5a28d 100644 --- a/renderer/premake5.lua +++ b/renderer/premake5.lua @@ -94,7 +94,7 @@ if not _OPTIONS['with-webgpu'] then externalincludedirs({ optick .. '/src'}) end - if _TARGET_OS == 'windows' then + if rive_target_os == 'windows' then externalincludedirs({ dx12_headers .. '/include/directx', }) diff --git a/renderer/premake5_pls_renderer.lua b/renderer/premake5_pls_renderer.lua index c7359254..84ce433b 100644 --- a/renderer/premake5_pls_renderer.lua +++ b/renderer/premake5_pls_renderer.lua @@ -22,7 +22,7 @@ if _OPTIONS['with_vulkan'] then }) end -if _TARGET_OS == 'windows' then +if rive_target_os == 'windows' then dx12_headers = dependency.github('microsoft/DirectX-Headers', 'v1.615.0') end @@ -143,7 +143,7 @@ if os.host() == 'macosx' then end end -if _TARGET_OS == 'windows' then +if rive_target_os == 'windows' then makecommand = makecommand .. ' d3d' end @@ -210,7 +210,7 @@ do files({ 'src/vulkan/*.cpp' }) end - if _TARGET_OS == 'windows' then + if rive_target_os == 'windows' then externalincludedirs({ dx12_headers .. '/include/directx', }) diff --git a/tests/rive_tools_project.lua b/tests/rive_tools_project.lua index 2ec9f3cd..6534cb89 100644 --- a/tests/rive_tools_project.lua +++ b/tests/rive_tools_project.lua @@ -361,7 +361,7 @@ do RIVE_PLS_DIR .. '/shader_hotload/**.cpp', }) - if _TARGET_OS == 'windows' then + if rive_target_os == 'windows' then externalincludedirs({ dx12_headers .. '/include/directx', })