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 <joshua@rive.app>
This commit is contained in:
JoshJRive
2025-10-21 21:11:40 +00:00
parent e1494304d6
commit c18e964c42
5 changed files with 19 additions and 6 deletions

View File

@@ -1 +1 @@
39741ac0c89ef4af6214bf2ec0f2130e489d8ed0
c7a0379ab3bd3ec3fb9b2ed26d5b238b93a26976

View File

@@ -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' })

View File

@@ -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',
})

View File

@@ -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',
})

View File

@@ -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',
})