From c32aabf13df74bfe616a0628a06ace6cb8e49ffe Mon Sep 17 00:00:00 2001 From: JCash Date: Fri, 14 Nov 2025 15:01:25 +0100 Subject: [PATCH 1/3] Added way to build only libraries --- build/rive_build_config.lua | 46 +++++++++++++++++++++++++++++- renderer/premake5.lua | 6 ++-- renderer/premake5_pls_renderer.lua | 5 ++++ 3 files changed, 53 insertions(+), 4 deletions(-) diff --git a/build/rive_build_config.lua b/build/rive_build_config.lua index f81720849..e7ab906fc 100644 --- a/build/rive_build_config.lua +++ b/build/rive_build_config.lua @@ -145,6 +145,19 @@ if _OPTIONS['with_optick'] then RIVE_OPTICK_VERSION = '1.4.0.0' end +-- Optional sysroot for cross builds (primarily Linux) +newoption({ + trigger = 'sysroot', + value = 'PATH', + description = 'Path to a sysroot for cross-compiling (adds --sysroot=PATH to compile and link options)', +}) + +-- Optional pthread enabling (used e.g. for Emscripten wagyu builds) +newoption({ + trigger = 'with_pthread', + description = 'Enable pthread compile/link flags (-pthread)', +}) + location(RIVE_BUILD_OUT) targetdir(RIVE_BUILD_OUT) objdir(RIVE_BUILD_OUT .. '/obj') @@ -422,7 +435,7 @@ if _OPTIONS['for_android'] then -- Detect the NDK. local EXPECTED_NDK_VERSION = 'r27c' - local NDK_LONG_VERSION_STRING = "27.2.12479018" + local NDK_LONG_VERSION_STRING = "25.2.9519653" if _OPTIONS['for_unreal'] then EXPECTED_NDK_VERSION = '25.1.8937393' NDK_LONG_VERSION_STRING = '25.1.8937393' @@ -559,6 +572,37 @@ end filter({}) +-- Cross-compilation helpers for Linux. When targeting a Linux architecture that does not match +-- the host, add an explicit target triple so clang uses the correct backend. Optionally honor a +-- provided --sysroot for both compilation and linking. +if os.target() == 'linux' then + local host_arch = os.outputof('uname -m') or '' + + -- Apply target triple if host arch doesn't match requested arch + if _OPTIONS['arch'] == 'x64' and host_arch ~= 'x86_64' then + buildoptions({ '--target=x86_64-linux-gnu' }) + linkoptions({ '--target=x86_64-linux-gnu' }) + elseif _OPTIONS['arch'] == 'arm64' and host_arch ~= 'aarch64' then + buildoptions({ '--target=aarch64-linux-gnu' }) + linkoptions({ '--target=aarch64-linux-gnu' }) + elseif _OPTIONS['arch'] == 'arm' and not host_arch:match('arm') then + buildoptions({ '--target=arm-linux-gnueabihf' }) + linkoptions({ '--target=arm-linux-gnueabihf' }) + end + + -- Optional sysroot + if _OPTIONS['sysroot'] ~= nil then + buildoptions({ '--sysroot=' .. _OPTIONS['sysroot'] }) + linkoptions({ '--sysroot=' .. _OPTIONS['sysroot'] }) + end +end + +-- Apply pthread flags when requested +if _OPTIONS['with_pthread'] then + buildoptions({ '-pthread' }) + linkoptions({ '-pthread' }) +end + filter('system:macosx') do defines({ 'RIVE_MACOSX' }) diff --git a/renderer/premake5.lua b/renderer/premake5.lua index 57d5a28d1..bd629f1ac 100644 --- a/renderer/premake5.lua +++ b/renderer/premake5.lua @@ -6,11 +6,11 @@ dofile(RIVE_RUNTIME_DIR .. '/decoders/premake5_v2.lua') dofile(RIVE_RUNTIME_DIR .. '/dependencies/premake5_glfw_v2.lua') newoption({ trigger = 'with-skia', description = 'use skia' }) -if _OPTIONS['with-skia'] then +if _OPTIONS['with-skia'] and not _OPTIONS['with-libs-only'] then dofile(RIVE_RUNTIME_DIR .. '/skia/renderer/premake5_v2.lua') end -if not _OPTIONS['with-webgpu'] then +if not _OPTIONS['with-webgpu'] and not _OPTIONS['with-libs-only'] then project('path_fiddle') do dependson('rive') @@ -179,7 +179,7 @@ if not _OPTIONS['with-webgpu'] then end end -if _OPTIONS['with-webgpu'] or _OPTIONS['with-dawn'] then +if (_OPTIONS['with-webgpu'] or _OPTIONS['with-dawn']) and not _OPTIONS['with-libs-only'] then project('webgpu_player') do kind('ConsoleApp') diff --git a/renderer/premake5_pls_renderer.lua b/renderer/premake5_pls_renderer.lua index 266b3ed45..9d7b55073 100644 --- a/renderer/premake5_pls_renderer.lua +++ b/renderer/premake5_pls_renderer.lua @@ -68,6 +68,11 @@ do defines({ 'RIVE_WEBGPU=' .. _OPTIONS['webgpu-version'] }) end +newoption({ + trigger = 'with-libs-only', + description = 'only builds the libraries', +}) + filter({}) newoption({ From 7355545bb5c3d1415a6871bdc6387b1377b17ba5 Mon Sep 17 00:00:00 2001 From: Mathias Westerdahl Date: Sat, 22 Nov 2025 11:52:31 +0100 Subject: [PATCH 2/3] review changes --- .gitignore | 1 + build/rive_build_config.lua | 16 +++------------- 2 files changed, 4 insertions(+), 13 deletions(-) diff --git a/.gitignore b/.gitignore index 45d41876b..2b08d4e62 100644 --- a/.gitignore +++ b/.gitignore @@ -56,6 +56,7 @@ dev/analysis_report build/bin dev/test/build/bin rivinfo/build/macosx +renderer/out # Skia dependencies skia/dependencies/skia_recorder diff --git a/build/rive_build_config.lua b/build/rive_build_config.lua index e7ab906fc..37c91538d 100644 --- a/build/rive_build_config.lua +++ b/build/rive_build_config.lua @@ -145,13 +145,6 @@ if _OPTIONS['with_optick'] then RIVE_OPTICK_VERSION = '1.4.0.0' end --- Optional sysroot for cross builds (primarily Linux) -newoption({ - trigger = 'sysroot', - value = 'PATH', - description = 'Path to a sysroot for cross-compiling (adds --sysroot=PATH to compile and link options)', -}) - -- Optional pthread enabling (used e.g. for Emscripten wagyu builds) newoption({ trigger = 'with_pthread', @@ -582,6 +575,9 @@ if os.target() == 'linux' then if _OPTIONS['arch'] == 'x64' and host_arch ~= 'x86_64' then buildoptions({ '--target=x86_64-linux-gnu' }) linkoptions({ '--target=x86_64-linux-gnu' }) + elseif _OPTIONS['arch'] == 'x86' and host_arch ~= 'i686' and host_arch ~= 'i386' then + buildoptions({ '--target=i686-linux-gnu' }) + linkoptions({ '--target=i686-linux-gnu' }) elseif _OPTIONS['arch'] == 'arm64' and host_arch ~= 'aarch64' then buildoptions({ '--target=aarch64-linux-gnu' }) linkoptions({ '--target=aarch64-linux-gnu' }) @@ -589,12 +585,6 @@ if os.target() == 'linux' then buildoptions({ '--target=arm-linux-gnueabihf' }) linkoptions({ '--target=arm-linux-gnueabihf' }) end - - -- Optional sysroot - if _OPTIONS['sysroot'] ~= nil then - buildoptions({ '--sysroot=' .. _OPTIONS['sysroot'] }) - linkoptions({ '--sysroot=' .. _OPTIONS['sysroot'] }) - end end -- Apply pthread flags when requested From 8a6cca2b9dde555f4f781e05e09734bf1e6adeb6 Mon Sep 17 00:00:00 2001 From: Mathias Westerdahl Date: Mon, 24 Nov 2025 14:16:12 +0100 Subject: [PATCH 3/3] readded -fPIC to linux --- build/rive_build_config.lua | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/build/rive_build_config.lua b/build/rive_build_config.lua index 37c91538d..a0e4c304e 100644 --- a/build/rive_build_config.lua +++ b/build/rive_build_config.lua @@ -565,6 +565,15 @@ end filter({}) +-- Always build position independent code on Linux +-- Ensures static libs can link into shared objects without relocation errors. +filter({ 'system:linux' }) +do + pic('on') + buildoptions({ '-fPIC' }) + linkoptions({ '-fPIC' }) +end + -- Cross-compilation helpers for Linux. When targeting a Linux architecture that does not match -- the host, add an explicit target triple so clang uses the correct backend. Optionally honor a -- provided --sysroot for both compilation and linking.