From f9d020bd84cdcd76a1b28ea8ab704abc3a65eb9b Mon Sep 17 00:00:00 2001 From: Bhagirath Mehta Date: Mon, 3 Aug 2026 12:34:13 -0500 Subject: [PATCH 1/5] Preserve sub-millisecond event timestamp precision Use precise wall-clock time where available and retain nanosecond-derived 100 ns ticks on POSIX so record.time no longer truncates every event to milliseconds. Add regression coverage for POSIX timestamp precision.\n\nCo-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>\nCopilot-Session: 05d1030e-75b0-447f-9856-65091d59a97f --- lib/pal/PAL.cpp | 25 ++++++++++++++++++++----- tests/unittests/PalTests.cpp | 16 ++++++++++++++++ 2 files changed, 36 insertions(+), 5 deletions(-) diff --git a/lib/pal/PAL.cpp b/lib/pal/PAL.cpp index 3e667653f..a5291b0e3 100644 --- a/lib/pal/PAL.cpp +++ b/lib/pal/PAL.cpp @@ -430,7 +430,23 @@ namespace PAL_NS_BEGIN { { #ifdef _WIN32 FILETIME tocks; - ::GetSystemTimeAsFileTime(&tocks); + // Resolve the precise API dynamically so the SDK retains its Windows 7 + // runtime compatibility and falls back when the API is unavailable. + using GetSystemTimePreciseAsFileTimeProc = VOID (WINAPI*)(LPFILETIME); + HMODULE kernel32 = ::GetModuleHandleW(L"kernel32.dll"); + auto getSystemTimePreciseAsFileTime = + kernel32 + ? reinterpret_cast( + ::GetProcAddress(kernel32, "GetSystemTimePreciseAsFileTime")) + : nullptr; + if (getSystemTimePreciseAsFileTime) + { + getSystemTimePreciseAsFileTime(&tocks); + } + else + { + ::GetSystemTimeAsFileTime(&tocks); + } ULONGLONG ticks = (ULONGLONG(tocks.dwHighDateTime) << 32) | tocks.dwLowDateTime; // number of days from beginning to 1601 multiplied by ticks per day return ticks + 0x701ce1722770000ULL; @@ -440,10 +456,9 @@ namespace PAL_NS_BEGIN { // This UTC epoch contract has been signed in blood since C++20 std::chrono::time_point now = std::chrono::system_clock::now(); auto duration = now.time_since_epoch(); - auto millis = std::chrono::duration_cast(duration).count(); - uint64_t ticks = millis; - ticks *= 10000; // convert millis to ticks (1 tick = 100ns) - ticks += 0x89F7FF5F7B58000ULL; // UTC time 0 in .NET ticks + auto nanos = std::chrono::duration_cast(duration).count(); + int64_t ticks = nanos / 100; // convert nanoseconds to .NET ticks (1 tick = 100ns) + ticks += static_cast(0x89F7FF5F7B58000ULL); // UTC time 0 in .NET ticks return ticks; #endif } diff --git a/tests/unittests/PalTests.cpp b/tests/unittests/PalTests.cpp index ddf1f6dd2..c931ff376 100644 --- a/tests/unittests/PalTests.cpp +++ b/tests/unittests/PalTests.cpp @@ -122,6 +122,22 @@ TEST_F(PalTests, SystemTime) EXPECT_THAT(t1, Lt(t0 + 1000)); } +#if !defined(_WIN32) && !defined(_WIN64) +TEST_F(PalTests, SystemTimeInTicksPreservesSubMillisecondPrecision) +{ + constexpr int64_t TicksPerMillisecond = 10000; + bool observedSubMillisecondTick = false; + + for (int i = 0; i < 1000 && !observedSubMillisecondTick; ++i) + { + observedSubMillisecondTick = + PAL::getUtcSystemTimeinTicks() % TicksPerMillisecond != 0; + } + + EXPECT_TRUE(observedSubMillisecondTick); +} +#endif + TEST_F(PalTests, FormatUtcTimestampMsAsISO8601) { EXPECT_THAT(PAL::formatUtcTimestampMsAsISO8601(0ll), Eq("1970-01-01T00:00:00.000Z")); From babeb981262cb88bdf74b036c0da95489c477450 Mon Sep 17 00:00:00 2001 From: Bhagirath Mehta Date: Mon, 3 Aug 2026 15:31:27 -0500 Subject: [PATCH 2/5] Cache precise Windows clock lookup Resolve GetSystemTimePreciseAsFileTime once instead of repeating module and symbol lookups for every event timestamp.\n\nCo-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>\nCopilot-Session: 05d1030e-75b0-447f-9856-65091d59a97f --- lib/pal/PAL.cpp | 15 +++++++++------ 1 file changed, 9 insertions(+), 6 deletions(-) diff --git a/lib/pal/PAL.cpp b/lib/pal/PAL.cpp index a5291b0e3..0fc28abfb 100644 --- a/lib/pal/PAL.cpp +++ b/lib/pal/PAL.cpp @@ -433,12 +433,15 @@ namespace PAL_NS_BEGIN { // Resolve the precise API dynamically so the SDK retains its Windows 7 // runtime compatibility and falls back when the API is unavailable. using GetSystemTimePreciseAsFileTimeProc = VOID (WINAPI*)(LPFILETIME); - HMODULE kernel32 = ::GetModuleHandleW(L"kernel32.dll"); - auto getSystemTimePreciseAsFileTime = - kernel32 - ? reinterpret_cast( - ::GetProcAddress(kernel32, "GetSystemTimePreciseAsFileTime")) - : nullptr; + static const GetSystemTimePreciseAsFileTimeProc getSystemTimePreciseAsFileTime = + []() -> GetSystemTimePreciseAsFileTimeProc + { + HMODULE kernel32 = ::GetModuleHandleW(L"kernel32.dll"); + return kernel32 + ? reinterpret_cast( + ::GetProcAddress(kernel32, "GetSystemTimePreciseAsFileTime")) + : nullptr; + }(); if (getSystemTimePreciseAsFileTime) { getSystemTimePreciseAsFileTime(&tocks); From b2bd27bae8e4f6122fc98b7ceecb5406ed1b409b Mon Sep 17 00:00:00 2001 From: Bhagirath Mehta Date: Thu, 6 Aug 2026 16:58:11 -0500 Subject: [PATCH 3/5] Align vcpkg iOS deployment target Ensure vcpkg-built Apple libraries match the consumer deployment target and avoid linker warnings. Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com> Copilot-Session: 5f341bc5-f8ae-4259-b03b-8eeb87c06837 --- tools/ports/cpp-client-telemetry/portfile.cmake | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/tools/ports/cpp-client-telemetry/portfile.cmake b/tools/ports/cpp-client-telemetry/portfile.cmake index b2fdab830..011c1c1f0 100644 --- a/tools/ports/cpp-client-telemetry/portfile.cmake +++ b/tools/ports/cpp-client-telemetry/portfile.cmake @@ -46,6 +46,14 @@ if(VCPKG_TARGET_IS_IOS) set(MATSDK_BUILD_IOS ON) endif() +# Keep the port's iOS deployment target aligned with the consumer test and the +# SDK's supported minimum instead of letting Clang default to the SDK version. +set(MATSDK_APPLE_DEPLOYMENT_OPTIONS) +if(VCPKG_TARGET_IS_IOS) + list(APPEND MATSDK_APPLE_DEPLOYMENT_OPTIONS + -DCMAKE_OSX_DEPLOYMENT_TARGET=12.0) +endif() + set(MATSDK_ANDROID_HTTP_CLIENT AUTO) if(VCPKG_TARGET_IS_ANDROID) file(READ "${SOURCE_PATH}/CMakeLists.txt" _matsdk_root_cmake) @@ -131,6 +139,7 @@ vcpkg_cmake_configure( -DBUILD_VERSION=${VERSION} -DBUILD_APPLE_HTTP=${MATSDK_BUILD_APPLE_HTTP} -DBUILD_IOS=${MATSDK_BUILD_IOS} + ${MATSDK_APPLE_DEPLOYMENT_OPTIONS} ) vcpkg_cmake_install() From ca440fcc40840174766dc7100120c11f53a65cd5 Mon Sep 17 00:00:00 2001 From: Bhagirath Mehta Date: Thu, 6 Aug 2026 17:27:11 -0500 Subject: [PATCH 4/5] Harden Apple packaging integration Propagate the resolved iOS sysroot to embedding builds and keep Apple vendored targets compatible with strict warning settings. Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com> Copilot-Session: 5f341bc5-f8ae-4257-b03b-8eeb87c06837 --- CMakeLists.txt | 4 ++++ lib/CMakeLists.txt | 11 ++++++++++- lib/http/HttpClient_Apple.mm | 2 +- 3 files changed, 15 insertions(+), 2 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index cc36e9da3..7b0906f8e 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -99,6 +99,10 @@ if(APPLE) OUTPUT_VARIABLE CMAKE_OSX_SYSROOT ERROR_QUIET OUTPUT_STRIP_TRAILING_WHITESPACE) + if(NOT CMAKE_OSX_SYSROOT) + message(FATAL_ERROR "Unable to resolve the Apple SDK sysroot for '${IOS_PLATFORM}'") + endif() + set(CMAKE_OSX_SYSROOT "${CMAKE_OSX_SYSROOT}" CACHE PATH "Apple SDK sysroot" FORCE) message(STATUS "CMAKE_OSX_SYSROOT ${CMAKE_OSX_SYSROOT}") message(STATUS "ARCHITECTURE: ${CMAKE_SYSTEM_PROCESSOR}") message(STATUS "PLATFORM: ${IOS_PLATFORM}") diff --git a/lib/CMakeLists.txt b/lib/CMakeLists.txt index 13b4d46d4..994fbf9b2 100644 --- a/lib/CMakeLists.txt +++ b/lib/CMakeLists.txt @@ -490,7 +490,12 @@ if(MATSDK_BUNDLE_SQLITE AND NOT TARGET sqlite3_bundled) else() # Unstripped vendored build (Android legacy): keep the existing narrower # warning suppression. -fno-finite-math-only guards the INFINITY macro. - target_compile_options(sqlite3_bundled PRIVATE -fno-finite-math-only -Wno-unused-function) + target_compile_options(sqlite3_bundled PRIVATE + -fno-finite-math-only + -Wno-unused-function + -Wno-shorten-64-to-32 + -Wno-ambiguous-macro + ) endif() endif() @@ -561,6 +566,10 @@ else() # real POSIX declarations for read/write/lseek/close instead of relying on # implicit (int-returning) declarations. target_compile_definitions(zlib_bundled PRIVATE Z_HAVE_UNISTD_H) + target_compile_options(zlib_bundled PRIVATE + -Wno-shorten-64-to-32 + -Wno-ambiguous-macro + ) target_link_libraries(mat PRIVATE sqlite3_bundled zlib_bundled ${LIBS}) elseif(PAL_IMPLEMENTATION STREQUAL "WIN32") diff --git a/lib/http/HttpClient_Apple.mm b/lib/http/HttpClient_Apple.mm index b7d6646a4..1a047f5d6 100644 --- a/lib/http/HttpClient_Apple.mm +++ b/lib/http/HttpClient_Apple.mm @@ -207,7 +207,7 @@ void HandleResponse(NSData* data, NSURLResponse* response, NSError* error) NSHTTPURLResponse *httpResp = static_cast(response); auto simpleResponse = new SimpleHttpResponse { NextRespId() }; - simpleResponse->m_statusCode = httpResp.statusCode; + simpleResponse->m_statusCode = static_cast(httpResp.statusCode); NSDictionary *responseHeaders = [httpResp allHeaderFields]; for (id key in responseHeaders) From c96f7de31bf4c4076b70ad6ea315e3fa039b7f75 Mon Sep 17 00:00:00 2001 From: Bhagirath Mehta Date: Thu, 6 Aug 2026 20:58:41 -0500 Subject: [PATCH 5/5] Migrate Apple builds to canonical CMake variables Remove legacy Apple architecture, platform, and deployment-target inputs so standalone scripts and embedding consumers share CMAKE_OSX_* configuration. Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com> Copilot-Session: 5f341bc5-f8ae-4257-b03b-8eeb87c06837 --- .github/workflows/build-ios-mac.yml | 4 +- CMakeLists.txt | 80 ++++++----------------------- build-gtest.sh | 3 +- build-ios.sh | 30 +++++------ build.sh | 21 ++++---- 5 files changed, 41 insertions(+), 97 deletions(-) diff --git a/.github/workflows/build-ios-mac.yml b/.github/workflows/build-ios-mac.yml index 7ca85012b..af77f8b35 100644 --- a/.github/workflows/build-ios-mac.yml +++ b/.github/workflows/build-ios-mac.yml @@ -61,8 +61,8 @@ jobs: - name: build run: | if [[ "${{ matrix.os }}" == "macos-14" ]]; then - export IOS_DEPLOYMENT_TARGET=13.0; + export CMAKE_OSX_DEPLOYMENT_TARGET=13.0; elif [[ "${{ matrix.os }}" == "macos-15" ]]; then - export IOS_DEPLOYMENT_TARGET=15.0; + export CMAKE_OSX_DEPLOYMENT_TARGET=15.0; fi ./build-tests-ios.sh ${{ matrix.config }} ${{ matrix.simulator }} diff --git a/CMakeLists.txt b/CMakeLists.txt index 7b0906f8e..69785b37c 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -47,92 +47,42 @@ if(APPLE) message(STATUS "BUILD_IOS: ${BUILD_IOS}") set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -fobjc-arc") - # iOS build options - option(BUILD_IOS "Build for iOS" NO) - option(FORCE_RESET_OSX_DEPLOYMENT_TARGET "Clear the OSX Deployment Target Set" YES) - if (DEFINED FORCE_RESET_DEPLOYMENT_TARGET) - set(FORCE_RESET_OSX_DEPLOYMENT_TARGET ${FORCE_RESET_DEPLOYMENT_TARGET}) - endif() + option(BUILD_IOS "Build for iOS-family Apple platforms" NO) # When building via vcpkg, the toolchain file handles architecture, sysroot, # deployment target, and platform flags. Skip manual flag configuration. if(NOT MATSDK_USE_VCPKG_DEPS) + if(CMAKE_SYSTEM_NAME MATCHES "^(iOS|visionOS)$") + set(BUILD_IOS ON) + endif() if(BUILD_IOS) set(TARGET_ARCH "APPLE") - set(IOS True) set(APPLE True) - if(FORCE_RESET_OSX_DEPLOYMENT_TARGET) - set(CMAKE_OSX_DEPLOYMENT_TARGET "" CACHE STRING "Force unset of the deployment target for iOS" FORCE) - if (${IOS_PLAT} STREQUAL "iphonesimulator") - set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -mios-simulator-version-min=${IOS_DEPLOYMENT_TARGET}") - set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -mios-simulator-version-min=${IOS_DEPLOYMENT_TARGET}") - else() - set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -miphoneos-version-min=${IOS_DEPLOYMENT_TARGET}") - set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -miphoneos-version-min=${IOS_DEPLOYMENT_TARGET}") - endif() - endif() - - if((${IOS_PLAT} STREQUAL "iphoneos") OR (${IOS_PLAT} STREQUAL "iphonesimulator") OR (${IOS_PLAT} STREQUAL "xros") OR (${IOS_PLAT} STREQUAL "xrsimulator")) - set(IOS_PLATFORM "${IOS_PLAT}") - else() - message(FATAL_ERROR "Unrecognized iOS platform '${IOS_PLAT}'") - endif() - - if(${IOS_ARCH} STREQUAL "x86_64") - set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -arch x86_64") - set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -arch x86_64") - set(CMAKE_SYSTEM_PROCESSOR x86_64) - elseif(${IOS_ARCH} STREQUAL "arm64") - set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -arch arm64") - set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -arch arm64") - set(CMAKE_SYSTEM_PROCESSOR arm64) - elseif(${IOS_ARCH} STREQUAL "arm64e") - set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -arch arm64e") - set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -arch arm64e") - set(CMAKE_SYSTEM_PROCESSOR arm64e) - else() - message(FATAL_ERROR "Unrecognized iOS architecture '${IOS_ARCH}'") + if(NOT CMAKE_OSX_SYSROOT) + message(FATAL_ERROR "CMAKE_OSX_SYSROOT must identify an Apple SDK") endif() - - execute_process(COMMAND xcodebuild -version -sdk ${IOS_PLATFORM} ONLY_ACTIVE_ARCH=NO Path + if(NOT IS_ABSOLUTE "${CMAKE_OSX_SYSROOT}") + execute_process(COMMAND xcodebuild -version -sdk "${CMAKE_OSX_SYSROOT}" Path OUTPUT_VARIABLE CMAKE_OSX_SYSROOT ERROR_QUIET OUTPUT_STRIP_TRAILING_WHITESPACE) - if(NOT CMAKE_OSX_SYSROOT) - message(FATAL_ERROR "Unable to resolve the Apple SDK sysroot for '${IOS_PLATFORM}'") + if(NOT CMAKE_OSX_SYSROOT) + message(FATAL_ERROR "Unable to resolve the Apple SDK sysroot") + endif() + set(CMAKE_OSX_SYSROOT "${CMAKE_OSX_SYSROOT}" CACHE PATH "Apple SDK sysroot" FORCE) endif() - set(CMAKE_OSX_SYSROOT "${CMAKE_OSX_SYSROOT}" CACHE PATH "Apple SDK sysroot" FORCE) message(STATUS "CMAKE_OSX_SYSROOT ${CMAKE_OSX_SYSROOT}") message(STATUS "ARCHITECTURE: ${CMAKE_SYSTEM_PROCESSOR}") - message(STATUS "PLATFORM: ${IOS_PLATFORM}") + message(STATUS "DEPLOYMENT TARGET: ${CMAKE_OSX_DEPLOYMENT_TARGET}") else() - if("${MAC_ARCH}" STREQUAL "x86_64") - set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -arch x86_64") - set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -arch x86_64") - set(CMAKE_SYSTEM_PROCESSOR x86_64) - set(TARGET_ARCH ${CMAKE_SYSTEM_PROCESSOR}) - set(CMAKE_OSX_ARCHITECTURES ${MAC_ARCH}) - set(APPLE True) - elseif("${MAC_ARCH}" STREQUAL "arm64") - set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -arch arm64") - set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -arch arm64") - set(CMAKE_SYSTEM_PROCESSOR arm64) - set(TARGET_ARCH ${CMAKE_SYSTEM_PROCESSOR}) - set(CMAKE_OSX_ARCHITECTURES ${MAC_ARCH}) - set(APPLE True) - else() - set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -arch x86_64 -arch arm64") - set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -arch x86_64 -arch arm64") - endif() - message(STATUS "MAC_ARCH: ${MAC_ARCH}") + message(STATUS "ARCHITECTURES: ${CMAKE_OSX_ARCHITECTURES}") endif() else() # vcpkg mode: just set internal flags from what the toolchain provides - if(BUILD_IOS OR CMAKE_SYSTEM_NAME STREQUAL "iOS") + if(BUILD_IOS OR CMAKE_SYSTEM_NAME MATCHES "^(iOS|visionOS)$") set(BUILD_IOS ON) set(TARGET_ARCH "APPLE") - set(IOS True) endif() message(STATUS "vcpkg toolchain managing architecture and platform flags") endif() diff --git a/build-gtest.sh b/build-gtest.sh index 4c73f3382..4dca08f06 100755 --- a/build-gtest.sh +++ b/build-gtest.sh @@ -39,9 +39,8 @@ if(BUILD_IOS) set(CMAKE_OSX_DEPLOYMENT_TARGET "12.2" CACHE STRING "Force set of the deployment target for iOS" FORCE) set(CMAKE_C_FLAGS "\${CMAKE_C_FLAGS} -miphoneos-version-min=10.0") set(CMAKE_CXX_FLAGS "\${CMAKE_CXX_FLAGS} -miphoneos-version-min=10.0 -std=c++11") - set(IOS_PLATFORM "iphonesimulator") set(CMAKE_SYSTEM_PROCESSOR x86_64) - execute_process(COMMAND xcodebuild -version -sdk \${IOS_PLATFORM} Path + execute_process(COMMAND xcodebuild -version -sdk iphonesimulator Path OUTPUT_VARIABLE CMAKE_OSX_SYSROOT_OUT ERROR_QUIET OUTPUT_STRIP_TRAILING_WHITESPACE) diff --git a/build-ios.sh b/build-ios.sh index d316fe2fa..be53816e2 100755 --- a/build-ios.sh +++ b/build-ios.sh @@ -25,51 +25,47 @@ elif [ "$1" == "debug" ]; then fi # Set Architecture: arm64, arm64e or x86_64 -IOS_ARCH=$(/usr/bin/uname -m) +APPLE_ARCH=$(/usr/bin/uname -m) if [ "$1" == "arm64" ]; then - IOS_ARCH="arm64" + APPLE_ARCH="arm64" shift elif [ "$1" == "arm64e" ]; then - IOS_ARCH="arm64e" + APPLE_ARCH="arm64e" shift elif [ "$1" == "x86_64" ]; then - IOS_ARCH="x86_64" + APPLE_ARCH="x86_64" shift fi # the last param is expected to specify the platform name: iphoneos|iphonesimulator|xros|xrsimulator # so if it is non-empty and it is not "device", we take it as a valid platform name # otherwise we fall back to old iOS logic which only supported iphoneos|iphonesimulator -IOS_PLAT="iphonesimulator" +APPLE_PLATFORM="iphonesimulator" if [ -n "$1" ] && [ "$1" != "device" ]; then - IOS_PLAT="$1" + APPLE_PLATFORM="$1" elif [ "$1" == "device" ]; then - IOS_PLAT="iphoneos" + APPLE_PLATFORM="iphoneos" fi -echo "IOS_ARCH = $IOS_ARCH, IOS_PLAT = $IOS_PLAT, BUILD_TYPE = $BUILD_TYPE" +echo "architecture = $APPLE_ARCH, platform = $APPLE_PLATFORM, build type = $BUILD_TYPE" -FORCE_RESET_DEPLOYMENT_TARGET=NO DEPLOYMENT_TARGET="" -if [ "$IOS_PLAT" == "iphoneos" ] || [ "$IOS_PLAT" == "iphonesimulator" ]; then +if [ "$APPLE_PLATFORM" == "iphoneos" ] || [ "$APPLE_PLATFORM" == "iphonesimulator" ]; then SYS_NAME="iOS" - DEPLOYMENT_TARGET="$IOS_DEPLOYMENT_TARGET" + DEPLOYMENT_TARGET="$CMAKE_OSX_DEPLOYMENT_TARGET" if [ -z "$DEPLOYMENT_TARGET" ]; then DEPLOYMENT_TARGET="12.0" - FORCE_RESET_DEPLOYMENT_TARGET=YES fi -elif [ "$IOS_PLAT" == "xros" ] || [ "$IOS_PLAT" == "xrsimulator" ]; then +elif [ "$APPLE_PLATFORM" == "xros" ] || [ "$APPLE_PLATFORM" == "xrsimulator" ]; then SYS_NAME="visionOS" - DEPLOYMENT_TARGET="$XROS_DEPLOYMENT_TARGET" + DEPLOYMENT_TARGET="$CMAKE_OSX_DEPLOYMENT_TARGET" if [ -z "$DEPLOYMENT_TARGET" ]; then DEPLOYMENT_TARGET="1.0" - FORCE_RESET_DEPLOYMENT_TARGET=YES fi fi echo "deployment target = $DEPLOYMENT_TARGET" -echo "force reset deployment target = $FORCE_RESET_DEPLOYMENT_TARGET" # Install build tools and recent sqlite3 FILE=".buildtools" @@ -92,7 +88,7 @@ cd out CMAKE_PACKAGE_TYPE=tgz -cmake_cmd="cmake -DCMAKE_OSX_SYSROOT=$IOS_PLAT -DCMAKE_SYSTEM_NAME=$SYS_NAME -DCMAKE_IOS_ARCH_ABI=$IOS_ARCH -DCMAKE_OSX_DEPLOYMENT_TARGET=$DEPLOYMENT_TARGET -DBUILD_IOS=YES -DIOS_ARCH=$IOS_ARCH -DIOS_PLAT=$IOS_PLAT -DIOS_DEPLOYMENT_TARGET=$DEPLOYMENT_TARGET -DCMAKE_BUILD_TYPE=$BUILD_TYPE -DCMAKE_PACKAGE_TYPE=$CMAKE_PACKAGE_TYPE -DFORCE_RESET_DEPLOYMENT_TARGET=$FORCE_RESET_DEPLOYMENT_TARGET $CMAKE_OPTS .." +cmake_cmd="cmake -DCMAKE_OSX_SYSROOT=$APPLE_PLATFORM -DCMAKE_SYSTEM_NAME=$SYS_NAME -DCMAKE_OSX_ARCHITECTURES=$APPLE_ARCH -DCMAKE_OSX_DEPLOYMENT_TARGET=$DEPLOYMENT_TARGET -DBUILD_IOS=YES -DCMAKE_BUILD_TYPE=$BUILD_TYPE -DCMAKE_PACKAGE_TYPE=$CMAKE_PACKAGE_TYPE $CMAKE_OPTS .." echo "${cmake_cmd}" eval $cmake_cmd diff --git a/build.sh b/build.sh index 52a5081b2..07dd19a6f 100755 --- a/build.sh +++ b/build.sh @@ -61,13 +61,13 @@ while [[ $# -gt 0 ]]; do echo "BUILD_TYPE = $BUILD_TYPE" ;; arm64|x86_64|universal) - if [[ -n "$MAC_ARCH" ]]; then - echo "Error: MAC_ARCH is already set to '$MAC_ARCH'. Cannot overwrite with $ARG." 1>&2 + if [[ -n "$APPLE_ARCH" ]]; then + echo "Error: APPLE_ARCH is already set to '$APPLE_ARCH'. Cannot overwrite with $ARG." 1>&2 exit 1 else - MAC_ARCH="$ARG" + APPLE_ARCH="$ARG" fi - echo "MAC_ARCH = $MAC_ARCH" + echo "APPLE_ARCH = $APPLE_ARCH" ;; CUSTOM_BUILD_FLAGS*) CUSTOM_CMAKE_CXX_FLAG="\"${ARG:19:999}\"" @@ -91,9 +91,9 @@ if [[ -z "$BUILD_TYPE" ]]; then echo "Assuming default BUILD_TYPE = Debug" fi -if [[ -z "$MAC_ARCH" ]]; then - MAC_ARCH=$(/usr/bin/uname -m) - echo "Using current machine MAC_ARCH = $MAC_ARCH" +if [[ -z "$APPLE_ARCH" ]]; then + APPLE_ARCH=$(/usr/bin/uname -m) + echo "Using current machine APPLE_ARCH = $APPLE_ARCH" fi # Evaluate switches @@ -137,7 +137,7 @@ if [ "$LINK_TYPE" == "shared" ]; then fi # Set target MacOS minver -default_mac_os_target=$([ "$MAC_ARCH" == "arm64" ] && echo "11.10" || echo "10.10") +default_mac_os_target=$([ "$APPLE_ARCH" == "arm64" ] && echo "11.10" || echo "10.10") [ -z $MACOSX_DEPLOYMENT_TARGET ] && export MACOSX_DEPLOYMENT_TARGET=${default_mac_os_target} echo "macosx deployment target="$MACOSX_DEPLOYMENT_TARGET @@ -147,7 +147,7 @@ OS_NAME=`uname -a` if [ ! -f $FILE ]; then case "$OS_NAME" in - *Darwin*) CMD="tools/setup-buildtools-apple.sh $MAC_ARCH" ;; + *Darwin*) CMD="tools/setup-buildtools-apple.sh $APPLE_ARCH" ;; *Linux*) CMD="tools/setup-buildtools.sh" ;; *) CMD=""; echo "WARNING: unsupported OS $OS_NAME, skipping build tools installation.." ;; esac @@ -185,8 +185,7 @@ fi # Fail on error set -e -# TODO: should this be improved to verify if the platform is Apple? Right now we unconditionally pass -DMAC_ARCH even if building for Windows or Linux. -cmake_cmd="cmake -DMAC_ARCH=$MAC_ARCH -DCMAKE_BUILD_TYPE=$BUILD_TYPE -DCMAKE_PACKAGE_TYPE=$CMAKE_PACKAGE_TYPE -DCMAKE_CXX_FLAGS="${CUSTOM_CMAKE_CXX_FLAG}" $CMAKE_OPTS .." +cmake_cmd="cmake -DCMAKE_OSX_ARCHITECTURES=$APPLE_ARCH -DCMAKE_OSX_DEPLOYMENT_TARGET=$MACOSX_DEPLOYMENT_TARGET -DCMAKE_BUILD_TYPE=$BUILD_TYPE -DCMAKE_PACKAGE_TYPE=$CMAKE_PACKAGE_TYPE -DCMAKE_CXX_FLAGS="${CUSTOM_CMAKE_CXX_FLAG}" $CMAKE_OPTS .." echo $cmake_cmd eval $cmake_cmd