From 725788de33f42f4d471fc4656ab764e6648f6dae Mon Sep 17 00:00:00 2001 From: csmartdalton Date: Thu, 8 Aug 2024 16:24:27 +0000 Subject: [PATCH] Add Xcode support to build_rive.sh Add an "xcode" option that generates and builds an xcode workspace. Add -Wshorten-64-to-32 to non-Xcode builds and fix more warnings. Diffs= f0da6a7a0 Add Xcode support to build_rive.sh (#7780) Co-authored-by: Chris Dalton <99840794+csmartdalton@users.noreply.github.com> --- .rive_head | 2 +- build/build_rive.sh | 23 +++++++++++++++++++---- include/rive/math/math_types.hpp | 4 ++-- skia/renderer/include/to_skia.hpp | 3 ++- 4 files changed, 24 insertions(+), 8 deletions(-) diff --git a/.rive_head b/.rive_head index b7f15159..5ee07534 100644 --- a/.rive_head +++ b/.rive_head @@ -1 +1 @@ -c12b0bb24d1abff5b8df6f9b3a4053fbc5096668 +f0da6a7a097a782df5839390097254bbfb8d9a00 diff --git a/build/build_rive.sh b/build/build_rive.sh index 48ad9503..9bef073c 100755 --- a/build/build_rive.sh +++ b/build/build_rive.sh @@ -13,6 +13,7 @@ # build_rive.sh # debug build # build_rive.sh release # release build # build_rive.sh release clean # clean, followed by a release build +# build_rive.sh xcode # generate and build an xcode workspace # build_rive.sh ninja # use ninja (experimental) for a debug build # build_rive.sh ninja release # use ninja (experimental) for a release build # build_rive.sh ninja --with_vulkan # extra parameters get forwarded to premake @@ -140,6 +141,7 @@ else "universal") RIVE_ARCH="${RIVE_ARCH:-universal}" ;; "wasm") RIVE_ARCH="${RIVE_ARCH:-wasm}" ;; "ninja") RIVE_BUILD_SYSTEM="${RIVE_BUILD_SYSTEM:-ninja}" ;; + "xcode") RIVE_BUILD_SYSTEM="${RIVE_BUILD_SYSTEM:-xcode4}" ;; "clean") RIVE_CLEAN="${RIVE_CLEAN:-true}" ;; "compdb") RIVE_BUILD_SYSTEM="${RIVE_BUILD_SYSTEM:-export-compile-commands}" @@ -267,15 +269,28 @@ case "$RIVE_BUILD_SYSTEM" in echo ninja -C $RIVE_OUT $@ ninja -C $RIVE_OUT $@ ;; + xcode4) + if [[ $# = 0 ]]; then + echo 'No targets specified for xcode: Attempting to grok them from "xcodebuild -list".' + XCODE_SCHEMES=$(for f in $(xcodebuild -list -workspace $RIVE_OUT/rive.xcworkspace | grep '^ '); do printf " $f"; done) + echo " -> groked:$XCODE_SCHEMES" + else + XCODE_SCHEMES="$@" + fi + for SCHEME in $XCODE_SCHEMES; do + echo xcodebuild -workspace $RIVE_OUT/rive.xcworkspace -scheme $SCHEME + xcodebuild -workspace $RIVE_OUT/rive.xcworkspace -scheme $SCHEME + done + ;; vs2022) for TARGET in $@; do - RIVE_MSVC_TARGETS="$RIVE_MSVC_TARGETS -t:$TARGET" + MSVC_TARGETS="$MSVC_TARGETS -t:$TARGET" done - echo msbuild.exe "./$RIVE_OUT/rive.sln" -p:UseMultiToolTask=true -m:$NUM_CORES $RIVE_MSVC_TARGETS - msbuild.exe "./$RIVE_OUT/rive.sln" -p:UseMultiToolTask=true -m:$NUM_CORES $RIVE_MSVC_TARGETS + echo msbuild.exe "./$RIVE_OUT/rive.sln" -p:UseMultiToolTask=true -m:$NUM_CORES $MSVC_TARGETS + msbuild.exe "./$RIVE_OUT/rive.sln" -p:UseMultiToolTask=true -m:$NUM_CORES $MSVC_TARGETS ;; *) - print "Unsupported buildsystem $RIVE_BUILD_SYSTEM" + echo "Unsupported buildsystem $RIVE_BUILD_SYSTEM" exit -1 ;; esac diff --git a/include/rive/math/math_types.hpp b/include/rive/math/math_types.hpp index b706afd1..b34adc35 100644 --- a/include/rive/math/math_types.hpp +++ b/include/rive/math/math_types.hpp @@ -114,11 +114,11 @@ RIVE_ALWAYS_INLINE static uint32_t rotateleft32(uint32_t x, int y) // Returns x rounded up to the next multiple of N. // If x is already a multiple of N, returns x. -template RIVE_ALWAYS_INLINE constexpr size_t round_up_to_multiple_of(size_t x) +template RIVE_ALWAYS_INLINE constexpr T round_up_to_multiple_of(T x) { static_assert(N != 0 && (N & (N - 1)) == 0, "math::round_up_to_multiple_of<> only supports powers of 2."); - return (x + (N - 1)) & ~(N - 1); + return (x + (N - 1)) & ~static_cast(N - 1); } // Behaves better with NaN than std::clamp(). (Matching simd::clamp().) diff --git a/skia/renderer/include/to_skia.hpp b/skia/renderer/include/to_skia.hpp index cc49d249..0cf8920d 100644 --- a/skia/renderer/include/to_skia.hpp +++ b/skia/renderer/include/to_skia.hpp @@ -12,6 +12,7 @@ #include "include/core/SkPathTypes.h" #include "include/core/SkTileMode.h" +#include "rive/math/math_types.hpp" #include "rive/math/mat2d.hpp" #include "rive/math/raw_path.hpp" #include "rive/math/vec2d.hpp" @@ -89,7 +90,7 @@ class ToSkia const auto pts = rp.points(); const auto vbs = rp.verbsU8(); return SkPath::Make((const SkPoint*)pts.data(), pts.size(), - vbs.data(), vbs.size(), + vbs.data(), math::lossless_numeric_cast(vbs.size()), nullptr, 0, SkPathFillType::kWinding); } // clang-format off