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 f81720849..a0e4c304e 100644 --- a/build/rive_build_config.lua +++ b/build/rive_build_config.lua @@ -145,6 +145,12 @@ if _OPTIONS['with_optick'] then RIVE_OPTICK_VERSION = '1.4.0.0' end +-- 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 +428,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 +565,43 @@ 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. +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'] == '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' }) + elseif _OPTIONS['arch'] == 'arm' and not host_arch:match('arm') then + buildoptions({ '--target=arm-linux-gnueabihf' }) + linkoptions({ '--target=arm-linux-gnueabihf' }) + 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({