From 7f3d8d96bfe5ddde26e04756b92286cd45cbb2ac Mon Sep 17 00:00:00 2001 From: csmartdalton Date: Thu, 31 Jul 2025 00:27:07 +0000 Subject: [PATCH] build: Fix premake5 build on macOS Sequoia (#10263) b4298b861b It looks like the premake5 "v5.0.0-beta3" tag isn't compatible with Sequoia 15.4.1. Bump our tag to v5.0.0-beta7 and update the deprecated features we had been using. Also fix the script to rebuild if the premake5 binary doesn't exist. Before it only checked if the parent "premake-core" directory existed, so if a build had failed previously, build_rive.sh would fail forever without ever attempting to build premake5 again. Co-authored-by: Chris Dalton <99840794+csmartdalton@users.noreply.github.com> Co-authored-by: Jonathon Copeland --- .rive_head | 2 +- build/build_rive.sh | 24 +++++++++++++++++++----- build/rive_build_config.lua | 18 +++++++++++++++--- cg_renderer/premake5.lua | 2 +- decoders/build/premake5.lua | 2 +- decoders/premake5_v2.lua | 2 +- dependencies/premake5_harfbuzz.lua | 2 +- dependencies/premake5_harfbuzz_v2.lua | 2 +- dependencies/premake5_libpng_v2.lua | 2 +- dependencies/premake5_yoga.lua | 2 +- premake5_v2.lua | 2 +- renderer/premake5.lua | 4 ++-- renderer/premake5_pls_renderer.lua | 2 +- skia/renderer/build/premake5.lua | 2 +- skia/renderer/premake5_v2.lua | 2 +- src/text/font_hb_apple.mm | 11 +++++++---- tests/rive_tools_project.lua | 4 ++-- 17 files changed, 57 insertions(+), 28 deletions(-) diff --git a/.rive_head b/.rive_head index 3873588e..30278b9d 100644 --- a/.rive_head +++ b/.rive_head @@ -1 +1 @@ -f9b4941afd1c9afe133963de2542fd73edbfdf0a +b4298b861b5b5607bf91983ba8382bff134257f9 diff --git a/build/build_rive.sh b/build/build_rive.sh index 09af01a3..247a45ef 100755 --- a/build/build_rive.sh +++ b/build/build_rive.sh @@ -203,7 +203,13 @@ else fi RIVE_PREMAKE_ARGS="$RIVE_BUILD_SYSTEM --config=$RIVE_CONFIG --out=$RIVE_OUT $RIVE_PREMAKE_ARGS" - if [ ! -z "$RIVE_OS" ]; then RIVE_PREMAKE_ARGS="$RIVE_PREMAKE_ARGS --os=$RIVE_OS"; fi + if [[ $RIVE_OS = "android" ]]; then + # Premake stopped supporting "--os=android". + # Use our own custom "--for_android" flag instead. + RIVE_PREMAKE_ARGS="$RIVE_PREMAKE_ARGS --for_android" + elif [ ! -z "$RIVE_OS" ]; then + RIVE_PREMAKE_ARGS="$RIVE_PREMAKE_ARGS --os=$RIVE_OS" + fi if [ ! -z "$RIVE_VARIANT" ]; then RIVE_PREMAKE_ARGS="$RIVE_PREMAKE_ARGS --variant=$RIVE_VARIANT"; fi if [ ! -z "$RIVE_ARCH" ]; then RIVE_PREMAKE_ARGS="$RIVE_PREMAKE_ARGS --arch=$RIVE_ARCH"; fi @@ -215,10 +221,15 @@ fi mkdir -p "$SCRIPT_DIR/dependencies" pushd "$SCRIPT_DIR/dependencies" > /dev/null -# Setup premake5. -if [ ! -d premake-core ]; then +# Add premake5 to the $PATH. +# Install premake5 to a specific directory based on our current tag, to make +# sure we rebuild if this script runs for a different tag. +RIVE_PREMAKE_TAG="${RIVE_PREMAKE_TAG:-v5.0.0-beta7}" +PREMAKE_INSTALL_DIR="$SCRIPT_DIR/dependencies/premake-core/bin/${RIVE_PREMAKE_TAG}_release" +if [ ! -f "$PREMAKE_INSTALL_DIR/premake5" ]; then echo Building Premake... - git clone -b v5.0.0-beta3 https://github.com/premake/premake-core.git + rm -fr premake-core # Wipe out a prior checkout if it exists without a premake5 binary. + git clone --depth 1 --branch $RIVE_PREMAKE_TAG https://github.com/premake/premake-core.git pushd premake-core > /dev/null case "$HOST_MACHINE" in mac_arm64) make -f Bootstrap.mak osx PLATFORM=ARM ;; @@ -226,9 +237,12 @@ if [ ! -d premake-core ]; then windows) ./Bootstrap.bat ;; *) make -f Bootstrap.mak linux ;; esac + cp -r bin/release $PREMAKE_INSTALL_DIR popd > /dev/null fi -export PATH="$SCRIPT_DIR/dependencies/premake-core/bin/release/:$PATH" +export PATH="$PREMAKE_INSTALL_DIR:$PATH" + +# Add Rive's build scripts to the premake path. export PREMAKE_PATH="$SCRIPT_DIR" # Setup premake-ninja. diff --git a/build/rive_build_config.lua b/build/rive_build_config.lua index c1b7735f..fbd6b767 100644 --- a/build/rive_build_config.lua +++ b/build/rive_build_config.lua @@ -61,6 +61,12 @@ newoption({ default = 'host', }) +-- Premake stopped supporting "--os=android". Add our own flag for android. +newoption({ + trigger = 'for_android', + description = 'compile for android (supersedes --os)', +}) + newoption({ trigger = 'android_api', description = 'Target Android API version number', @@ -191,12 +197,17 @@ end filter({ 'options:config=release', 'options:not no-lto', 'system:not macosx', 'system:not ios' }) do - flags({ 'LinkTimeOptimization' }) + if linktimeoptimization then + linktimeoptimization('On') + else + -- Deprecated way of turning on LTO, for older versions of premake. + flags({ 'LinkTimeOptimization' }) + end end filter({ 'options:config=release', 'options:not no-lto', 'system:macosx or ios' }) do - -- The 'LinkTimeOptimization' flag attempts to use llvm-ar, which doesn't always exist on macos. + -- The 'linktimeoptimization' command attempts to use llvm-ar, which doesn't always exist on macos. buildoptions({ '-flto=full' }) linkoptions({ '-flto=full' }) end @@ -388,7 +399,8 @@ filter({}) -- Don't use filter() here because we don't want to generate the "android_ndk" toolset if not -- building for android. -if _OPTIONS['os'] == 'android' then +if _OPTIONS['for_android'] then + system('android') pic('on') -- Position-independent code is required for NDK libraries. -- Detect the NDK. diff --git a/cg_renderer/premake5.lua b/cg_renderer/premake5.lua index a4a60627..64889090 100644 --- a/cg_renderer/premake5.lua +++ b/cg_renderer/premake5.lua @@ -11,7 +11,7 @@ do files({ 'src/**.cpp' }) - flags({ 'FatalCompileWarnings' }) + fatalwarnings { "All" } filter('system:windows') do diff --git a/decoders/build/premake5.lua b/decoders/build/premake5.lua index 1fbf5e7c..3f24da45 100644 --- a/decoders/build/premake5.lua +++ b/decoders/build/premake5.lua @@ -14,7 +14,7 @@ language('C++') cppdialect('C++17') targetdir('%{cfg.buildcfg}') objdir('obj/%{cfg.buildcfg}') -flags({ 'FatalCompileWarnings' }) +fatalwarnings { "All" } includedirs({ '../include', '../../include', libpng }) diff --git a/decoders/premake5_v2.lua b/decoders/premake5_v2.lua index 1e2201dc..39f657e4 100644 --- a/decoders/premake5_v2.lua +++ b/decoders/premake5_v2.lua @@ -38,7 +38,7 @@ end project('rive_decoders') do kind('StaticLib') - flags({ 'FatalCompileWarnings' }) + fatalwarnings { "All" } includedirs({ 'include', diff --git a/dependencies/premake5_harfbuzz.lua b/dependencies/premake5_harfbuzz.lua index 4c472b57..9926489b 100644 --- a/dependencies/premake5_harfbuzz.lua +++ b/dependencies/premake5_harfbuzz.lua @@ -251,7 +251,7 @@ do filter('toolset:clang') do - flags({ 'FatalCompileWarnings' }) + fatalwarnings { "All" } buildoptions({ '-Werror=format', '-Wimplicit-int-conversion', diff --git a/dependencies/premake5_harfbuzz_v2.lua b/dependencies/premake5_harfbuzz_v2.lua index 6e01f1cb..49ee68f6 100644 --- a/dependencies/premake5_harfbuzz_v2.lua +++ b/dependencies/premake5_harfbuzz_v2.lua @@ -256,7 +256,7 @@ do filter('toolset:not msc') do - flags({ 'FatalCompileWarnings' }) + fatalwarnings { "All" } buildoptions({ '-Werror=format', '-Wimplicit-int-conversion', diff --git a/dependencies/premake5_libpng_v2.lua b/dependencies/premake5_libpng_v2.lua index 712eb015..1cc744a2 100644 --- a/dependencies/premake5_libpng_v2.lua +++ b/dependencies/premake5_libpng_v2.lua @@ -80,7 +80,7 @@ do filter('toolset:not msc') do - flags({ 'FatalCompileWarnings' }) + fatalwarnings { "All" } buildoptions({ '-Wno-unknown-warning-option', '-Wno-deprecated-non-prototype', diff --git a/dependencies/premake5_yoga.lua b/dependencies/premake5_yoga.lua index 75292326..f5e8b106 100644 --- a/dependencies/premake5_yoga.lua +++ b/dependencies/premake5_yoga.lua @@ -51,7 +51,7 @@ do filter('toolset:clang') do - flags({ 'FatalCompileWarnings' }) + fatalwarnings { "All" } buildoptions({ '-Werror=format', '-Wimplicit-int-conversion', diff --git a/premake5_v2.lua b/premake5_v2.lua index 32202301..5a2f2ce0 100644 --- a/premake5_v2.lua +++ b/premake5_v2.lua @@ -69,7 +69,7 @@ do filter('options:not for_unreal') do cppdialect('C++11') - flags({ 'FatalCompileWarnings' }) + fatalwarnings { "All" } end filter({ 'options:for_unreal' }) diff --git a/renderer/premake5.lua b/renderer/premake5.lua index c3694d98..5f83997d 100644 --- a/renderer/premake5.lua +++ b/renderer/premake5.lua @@ -27,7 +27,7 @@ if not _OPTIONS['with-webgpu'] then yoga, }) - flags({ 'FatalCompileWarnings' }) + fatalwarnings { "All" } defines({ 'YOGA_EXPORT=' }) @@ -188,7 +188,7 @@ if _OPTIONS['with-webgpu'] or _OPTIONS['with-dawn'] then 'include', RIVE_RUNTIME_DIR .. '/skia/dependencies/glfw/include', }) - flags({ 'FatalCompileWarnings' }) + fatalwarnings { "All" } defines({ 'YOGA_EXPORT=' }) diff --git a/renderer/premake5_pls_renderer.lua b/renderer/premake5_pls_renderer.lua index a2625ee7..2a70b17a 100644 --- a/renderer/premake5_pls_renderer.lua +++ b/renderer/premake5_pls_renderer.lua @@ -178,7 +178,7 @@ do '../include', pls_generated_headers, }) - flags({ 'FatalCompileWarnings' }) + fatalwarnings { "All" } files({ 'src/*.cpp', 'renderer/decoding/*.cpp' }) diff --git a/skia/renderer/build/premake5.lua b/skia/renderer/build/premake5.lua index 43f147bb..b917f1ec 100644 --- a/skia/renderer/build/premake5.lua +++ b/skia/renderer/build/premake5.lua @@ -32,7 +32,7 @@ do files({ '../src/**.cpp' }) - flags({ 'FatalCompileWarnings' }) + fatalwarnings { "All" } filter('system:windows') do diff --git a/skia/renderer/premake5_v2.lua b/skia/renderer/premake5_v2.lua index 5a41efa2..da9d2526 100644 --- a/skia/renderer/premake5_v2.lua +++ b/skia/renderer/premake5_v2.lua @@ -21,7 +21,7 @@ do files({ 'src/**.cpp' }) - flags({ 'FatalCompileWarnings' }) + fatalwarnings { "All" } filter({ 'system:macosx or linux or windows or ios' }) do diff --git a/src/text/font_hb_apple.mm b/src/text/font_hb_apple.mm index 0748f0a7..934828e2 100644 --- a/src/text/font_hb_apple.mm +++ b/src/text/font_hb_apple.mm @@ -8,6 +8,7 @@ #include // #endif +#include "rive/math/math_types.hpp" #include "rive/text_engine.hpp" #include "rive/text/font_hb.hpp" #include "rive/text/utf.hpp" @@ -297,7 +298,7 @@ void CoreTextHBFont::shapeFallbackRun( { CTRunRef run = (CTRunRef)CFArrayGetValueAtIndex(run_array, runIndex); - if (auto count = CTRunGetGlyphCount(run)) + if (CFIndex count = CTRunGetGlyphCount(run)) { rive::GlyphRun gr(count); @@ -349,15 +350,17 @@ void CoreTextHBFont::shapeFallbackRun( CTRunGetAdvances(run, {0, count}, advances.data()); CTRunGetStringIndices(run, {0, count}, indices.data()); - int reverseIndex = count - 1; + CFIndex reverseIndex = count - 1; for (CFIndex i = 0; i < count; ++i) { - int glyphIndex = isEvenLevel ? i : reverseIndex; + CFIndex glyphIndex = isEvenLevel ? i : reverseIndex; float advance = (float)(advances[i].width * scale) + textRun.letterSpacing; gr.xpos[glyphIndex] = gr.advances[glyphIndex] = advance; gr.textIndices[glyphIndex] = - textStart + indices[i]; // utf16 offsets, will fix-up later + rive::math::lossless_numeric_cast( + textStart + + indices[i]); // utf16 offsets, will fix-up later gr.offsets[glyphIndex] = rive::Vec2D(0.0f, 0.0f); reverseIndex--; diff --git a/tests/rive_tools_project.lua b/tests/rive_tools_project.lua index 440c88ee..a9ec9122 100644 --- a/tests/rive_tools_project.lua +++ b/tests/rive_tools_project.lua @@ -20,7 +20,7 @@ function rive_tools_project(name, project_kind) if project_kind == 'RiveTool' then kind( _OPTIONS['for_unreal'] and 'StaticLib' - or _OPTIONS['os'] == 'android' and 'SharedLib' + or _OPTIONS['for_android'] and 'SharedLib' or _OPTIONS['os'] == 'ios' and 'StaticLib' or 'ConsoleApp' ) @@ -53,7 +53,7 @@ function rive_tools_project(name, project_kind) kind(project_kind) end - flags({ 'FatalCompileWarnings' }) + fatalwarnings { "All" } defines({ 'SK_GL',