From 10484181dc150a6c3a1f8cb05386d9691f9b431b Mon Sep 17 00:00:00 2001 From: Lalit Kumar Bhasin Date: Thu, 5 Sep 2024 07:16:57 -0700 Subject: [PATCH 01/10] bump macos version --- .github/workflows/build-ios-mac.yml | 42 +++++++++++++++++++++++++++ .github/workflows/build-ios-mac11.yml | 35 ---------------------- 2 files changed, 42 insertions(+), 35 deletions(-) create mode 100644 .github/workflows/build-ios-mac.yml delete mode 100644 .github/workflows/build-ios-mac11.yml diff --git a/.github/workflows/build-ios-mac.yml b/.github/workflows/build-ios-mac.yml new file mode 100644 index 000000000..287838b0c --- /dev/null +++ b/.github/workflows/build-ios-mac.yml @@ -0,0 +1,42 @@ +name: C/C++ CI for iOS + +on: + push: + branches: + - master + - main + - dev + - dev/* + - release/* + - buildme/* + + pull_request: + branches: + - master + - main + - dev + + schedule: + - cron: 0 2 * * 1-5 + +jobs: + build: + strategy: + matrix: + os: [macos-11, macos-14] + config: [release, debug] + simulator: ["'iPhone 8'", "'iPad Air (3rd generation)'"] + runs-on: ${{ matrix.os }} + steps: + - uses: actions/checkout@v2 + with: + submodules: 'true' + continue-on-error: true + - name: build + run: | + if [[ "${{ matrix.os }}" == "macos-11" ]]; then + export IOS_DEPLOYMENT_TARGET=11.0; + elif [[ "${{ matrix.os }}" == "macos-14" ]]; then + export IOS_DEPLOYMENT_TARGET=14.0; + fi + ./build-tests-ios.sh ${{ matrix.config }} ${{ matrix.simulator }} diff --git a/.github/workflows/build-ios-mac11.yml b/.github/workflows/build-ios-mac11.yml deleted file mode 100644 index 9c60f195a..000000000 --- a/.github/workflows/build-ios-mac11.yml +++ /dev/null @@ -1,35 +0,0 @@ -name: C/C++ CI for iOS - -on: - push: - branches: - - master - - main - - dev - - dev/* - - release/* - - buildme/* - - pull_request: - branches: - - master - - main - - dev - - schedule: - - cron: 0 2 * * 1-5 - -jobs: - build: - runs-on: macOS-11 - strategy: - matrix: - config: [release, debug] - simulator: ["'iPhone 8'", "'iPad Air (3rd generation)'"] - steps: - - uses: actions/checkout@v2 - with: - submodules: 'true' - continue-on-error: true - - name: build - run: export IOS_DEPLOYMENT_TARGET=11.0 && ./build-tests-ios.sh ${{ matrix.config }} ${{ matrix.simulator }} From 10a2697cbdacedbab75067ad5448c7fa9ccfb22d Mon Sep 17 00:00:00 2001 From: Lalit Kumar Bhasin Date: Thu, 5 Sep 2024 07:38:37 -0700 Subject: [PATCH 02/10] incorrect version --- .github/workflows/build-ios-mac.yml | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/.github/workflows/build-ios-mac.yml b/.github/workflows/build-ios-mac.yml index 287838b0c..435c0ba0e 100644 --- a/.github/workflows/build-ios-mac.yml +++ b/.github/workflows/build-ios-mac.yml @@ -23,7 +23,7 @@ jobs: build: strategy: matrix: - os: [macos-11, macos-14] + os: [macos-12, macos-14] config: [release, debug] simulator: ["'iPhone 8'", "'iPad Air (3rd generation)'"] runs-on: ${{ matrix.os }} @@ -34,8 +34,8 @@ jobs: continue-on-error: true - name: build run: | - if [[ "${{ matrix.os }}" == "macos-11" ]]; then - export IOS_DEPLOYMENT_TARGET=11.0; + if [[ "${{ matrix.os }}" == "macos-12" ]]; then + export IOS_DEPLOYMENT_TARGET=12.0; elif [[ "${{ matrix.os }}" == "macos-14" ]]; then export IOS_DEPLOYMENT_TARGET=14.0; fi From cb4d84df0480351748477d5ee088d70fa7095cc8 Mon Sep 17 00:00:00 2001 From: Lalit Kumar Bhasin Date: Thu, 5 Sep 2024 08:49:05 -0700 Subject: [PATCH 03/10] check install prefix access --- CMakeLists.txt | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) diff --git a/CMakeLists.txt b/CMakeLists.txt index 285b8146d..bd1f2468d 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -1,6 +1,23 @@ cmake_minimum_required(VERSION 3.1.0) project(MSTelemetry) +# Set installation prefix for macOS and Linux +if(UNIX AND NOT DEFINED CMAKE_INSTALL_PREFIX) + set(CMAKE_INSTALL_PREFIX "/usr/local" CACHE PATH "Installation directory prefix" FORCE) +endif() + +# Check write access to prefix, fallback to user's home directory if needed (Unix only) +if(UNIX) + file(WRITE "${CMAKE_INSTALL_PREFIX}/.cmake_write_test" "") + if("${CMAKE_STATUS}" STREQUAL "0") + message(STATUS "Write access to ${CMAKE_INSTALL_PREFIX} confirmed.") + file(REMOVE "${CMAKE_INSTALL_PREFIX}/.cmake_write_test") + else() + set(CMAKE_INSTALL_PREFIX "$ENV{HOME}/mst_telemetry" CACHE PATH "Fallback installation directory prefix" FORCE) + message(STATUS "No write access to ${CMAKE_INSTALL_PREFIX}, installing to $HOME/mst_telemetry instead.") + endif() +endif() + set(INSTALL_BIN_DIR "${CMAKE_INSTALL_PREFIX}/bin" CACHE PATH "Installation directory for executables") set(INSTALL_LIB_DIR "${CMAKE_INSTALL_PREFIX}/lib" CACHE PATH "Installation directory for libraries") set(INSTALL_INC_DIR "${CMAKE_INSTALL_PREFIX}/include" CACHE PATH "Installation directory for headers") From db048cf98f51fd3feffb88c160a006945ed449d1 Mon Sep 17 00:00:00 2001 From: Lalit Bhasin Date: Tue, 21 Jan 2025 15:25:06 -0800 Subject: [PATCH 04/10] fix the cmake to not exit if the write test fail --- CMakeLists.txt | 9 +++++---- build-tests-ios.sh | 3 +++ 2 files changed, 8 insertions(+), 4 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index bd1f2468d..387d6bb72 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -6,12 +6,13 @@ if(UNIX AND NOT DEFINED CMAKE_INSTALL_PREFIX) set(CMAKE_INSTALL_PREFIX "/usr/local" CACHE PATH "Installation directory prefix" FORCE) endif() -# Check write access to prefix, fallback to user's home directory if needed (Unix only) if(UNIX) - file(WRITE "${CMAKE_INSTALL_PREFIX}/.cmake_write_test" "") - if("${CMAKE_STATUS}" STREQUAL "0") + # Test write access to CMAKE_INSTALL_PREFIX + set(TEST_FILE "${CMAKE_INSTALL_PREFIX}/.cmake_write_test") + file(WRITE "${TEST_FILE}" "") # Attempt to write the test file + if(EXISTS "${TEST_FILE}") message(STATUS "Write access to ${CMAKE_INSTALL_PREFIX} confirmed.") - file(REMOVE "${CMAKE_INSTALL_PREFIX}/.cmake_write_test") + file(REMOVE "${TEST_FILE}") # Cleanup the test file else() set(CMAKE_INSTALL_PREFIX "$ENV{HOME}/mst_telemetry" CACHE PATH "Fallback installation directory prefix" FORCE) message(STATUS "No write access to ${CMAKE_INSTALL_PREFIX}, installing to $HOME/mst_telemetry instead.") diff --git a/build-tests-ios.sh b/build-tests-ios.sh index fb48b4ea7..d0f7d428d 100755 --- a/build-tests-ios.sh +++ b/build-tests-ios.sh @@ -1,4 +1,7 @@ #!/bin/sh +// Add current user +current_user=`id` +echo "CURRENT USER:" $current_user cd ${0%/*} SKU=${1:-release} SIMULATOR=${2:-iPhone 8} From 4e7e8cc473f570bffbef5b69b733860b6d69d4b9 Mon Sep 17 00:00:00 2001 From: Lalit Kumar Bhasin Date: Tue, 21 Jan 2025 15:29:17 -0800 Subject: [PATCH 05/10] macos12 is deprecated. switch to macos13 and macos15 --- .github/workflows/build-ios-mac.yml | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/.github/workflows/build-ios-mac.yml b/.github/workflows/build-ios-mac.yml index 435c0ba0e..84b47523a 100644 --- a/.github/workflows/build-ios-mac.yml +++ b/.github/workflows/build-ios-mac.yml @@ -23,7 +23,7 @@ jobs: build: strategy: matrix: - os: [macos-12, macos-14] + os: [macos-13, macos-15] config: [release, debug] simulator: ["'iPhone 8'", "'iPad Air (3rd generation)'"] runs-on: ${{ matrix.os }} @@ -34,9 +34,9 @@ jobs: continue-on-error: true - name: build run: | - if [[ "${{ matrix.os }}" == "macos-12" ]]; then - export IOS_DEPLOYMENT_TARGET=12.0; - elif [[ "${{ matrix.os }}" == "macos-14" ]]; then - export IOS_DEPLOYMENT_TARGET=14.0; + if [[ "${{ matrix.os }}" == "macos-13" ]]; then + export IOS_DEPLOYMENT_TARGET=13.0; + elif [[ "${{ matrix.os }}" == "macos-15" ]]; then + export IOS_DEPLOYMENT_TARGET=15.0; fi ./build-tests-ios.sh ${{ matrix.config }} ${{ matrix.simulator }} From 7dac26ff9d46e14ca4538e14838c0b4e3ebecd06 Mon Sep 17 00:00:00 2001 From: Lalit Kumar Bhasin Date: Tue, 21 Jan 2025 15:39:51 -0800 Subject: [PATCH 06/10] try to gracefully fail for write --- CMakeLists.txt | 14 ++++++++++---- 1 file changed, 10 insertions(+), 4 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 387d6bb72..e4b1eaf0a 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -6,19 +6,25 @@ if(UNIX AND NOT DEFINED CMAKE_INSTALL_PREFIX) set(CMAKE_INSTALL_PREFIX "/usr/local" CACHE PATH "Installation directory prefix" FORCE) endif() + if(UNIX) - # Test write access to CMAKE_INSTALL_PREFIX set(TEST_FILE "${CMAKE_INSTALL_PREFIX}/.cmake_write_test") - file(WRITE "${TEST_FILE}" "") # Attempt to write the test file + + # Attempt to write a test file + file(WRITE "${TEST_FILE}" "" OUTPUT_VARIABLE WRITE_RESULT ERROR_VARIABLE WRITE_ERROR) + if(EXISTS "${TEST_FILE}") message(STATUS "Write access to ${CMAKE_INSTALL_PREFIX} confirmed.") - file(REMOVE "${TEST_FILE}") # Cleanup the test file + file(REMOVE "${TEST_FILE}") # Clean up the test file else() + # Fallback to a writable directory (e.g., user's home) set(CMAKE_INSTALL_PREFIX "$ENV{HOME}/mst_telemetry" CACHE PATH "Fallback installation directory prefix" FORCE) - message(STATUS "No write access to ${CMAKE_INSTALL_PREFIX}, installing to $HOME/mst_telemetry instead.") + message(STATUS "No write access to ${CMAKE_INSTALL_PREFIX}, using $ENV{HOME}/mst_telemetry instead.") endif() endif() + + set(INSTALL_BIN_DIR "${CMAKE_INSTALL_PREFIX}/bin" CACHE PATH "Installation directory for executables") set(INSTALL_LIB_DIR "${CMAKE_INSTALL_PREFIX}/lib" CACHE PATH "Installation directory for libraries") set(INSTALL_INC_DIR "${CMAKE_INSTALL_PREFIX}/include" CACHE PATH "Installation directory for headers") From 0c7ff51b3f40547109da04324c50e7659bca9554 Mon Sep 17 00:00:00 2001 From: Lalit Kumar Bhasin Date: Tue, 21 Jan 2025 16:00:13 -0800 Subject: [PATCH 07/10] more cleaner check --- CMakeLists.txt | 49 +++++++++++++++++++++++++++++++++++-------------- 1 file changed, 35 insertions(+), 14 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index e4b1eaf0a..ffd86c57a 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -7,20 +7,41 @@ if(UNIX AND NOT DEFINED CMAKE_INSTALL_PREFIX) endif() -if(UNIX) - set(TEST_FILE "${CMAKE_INSTALL_PREFIX}/.cmake_write_test") - - # Attempt to write a test file - file(WRITE "${TEST_FILE}" "" OUTPUT_VARIABLE WRITE_RESULT ERROR_VARIABLE WRITE_ERROR) - - if(EXISTS "${TEST_FILE}") - message(STATUS "Write access to ${CMAKE_INSTALL_PREFIX} confirmed.") - file(REMOVE "${TEST_FILE}") # Clean up the test file - else() - # Fallback to a writable directory (e.g., user's home) - set(CMAKE_INSTALL_PREFIX "$ENV{HOME}/mst_telemetry" CACHE PATH "Fallback installation directory prefix" FORCE) - message(STATUS "No write access to ${CMAKE_INSTALL_PREFIX}, using $ENV{HOME}/mst_telemetry instead.") - endif() +# Set installation prefix for Unix systems (macOS and Linux) +if(UNIX AND NOT DEFINED CMAKE_INSTALL_PREFIX) + # First try /usr/local + set(TEST_FILE "/usr/local/.ci_write_test") + + # Try to create a test file + execute_process( + COMMAND ${CMAKE_COMMAND} -E touch "${TEST_FILE}" + RESULT_VARIABLE WRITE_RESULT + ) + + # Check if write was successful + if(WRITE_RESULT EQUAL 0) + # We have write access to /usr/local + set(CMAKE_INSTALL_PREFIX "/usr/local" CACHE PATH "Installation directory prefix" FORCE) + message(STATUS "Using /usr/local as installation prefix (write access confirmed)") + # Clean up test file + execute_process(COMMAND ${CMAKE_COMMAND} -E remove "${TEST_FILE}") + else() + # No write access, fall back to HOME directory + set(FALLBACK_DIR "$ENV{HOME}/mst_telemetry") + + # Create the mst_telemetry directory + execute_process( + COMMAND ${CMAKE_COMMAND} -E make_directory "${FALLBACK_DIR}" + RESULT_VARIABLE CREATE_DIR_RESULT + ) + + if(NOT CREATE_DIR_RESULT EQUAL 0) + message(FATAL_ERROR "Failed to create directory: ${FALLBACK_DIR}") + endif() + + set(CMAKE_INSTALL_PREFIX "${FALLBACK_DIR}" CACHE PATH "Installation directory prefix" FORCE) + message(STATUS "No write access to /usr/local, created and using ${FALLBACK_DIR} instead") + endif() endif() From c058ef3f907aa7086ffc03c56957c4056540b5aa Mon Sep 17 00:00:00 2001 From: Lalit Date: Tue, 21 Jan 2025 22:17:01 -0800 Subject: [PATCH 08/10] update ci yaml --- .github/workflows/build-ios-mac.yml | 3 +++ 1 file changed, 3 insertions(+) diff --git a/.github/workflows/build-ios-mac.yml b/.github/workflows/build-ios-mac.yml index 84b47523a..a4b2d56fc 100644 --- a/.github/workflows/build-ios-mac.yml +++ b/.github/workflows/build-ios-mac.yml @@ -28,6 +28,9 @@ jobs: simulator: ["'iPhone 8'", "'iPad Air (3rd generation)'"] runs-on: ${{ matrix.os }} steps: + - name: Grant write permissions to /usr/local + run: | + sudo chown -R $USER:staff /usr/local - uses: actions/checkout@v2 with: submodules: 'true' From a500fcbf8e73efcaa5e135089cca7f33ec97084b Mon Sep 17 00:00:00 2001 From: Lalit Date: Tue, 21 Jan 2025 22:30:41 -0800 Subject: [PATCH 09/10] update the simulators --- .github/workflows/build-ios-mac.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/build-ios-mac.yml b/.github/workflows/build-ios-mac.yml index a4b2d56fc..dc517651e 100644 --- a/.github/workflows/build-ios-mac.yml +++ b/.github/workflows/build-ios-mac.yml @@ -25,7 +25,7 @@ jobs: matrix: os: [macos-13, macos-15] config: [release, debug] - simulator: ["'iPhone 8'", "'iPad Air (3rd generation)'"] + simulator: ["'iPhone 15'", "'iPad Air 11-inch (M2)'"] runs-on: ${{ matrix.os }} steps: - name: Grant write permissions to /usr/local From 72bf84aca452b3c7b30518538ed522218913ad5f Mon Sep 17 00:00:00 2001 From: Lalit Date: Tue, 21 Jan 2025 22:50:26 -0800 Subject: [PATCH 10/10] use iphone 16 as simulator --- .github/workflows/build-ios-mac.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/build-ios-mac.yml b/.github/workflows/build-ios-mac.yml index dc517651e..dae79812d 100644 --- a/.github/workflows/build-ios-mac.yml +++ b/.github/workflows/build-ios-mac.yml @@ -25,7 +25,7 @@ jobs: matrix: os: [macos-13, macos-15] config: [release, debug] - simulator: ["'iPhone 15'", "'iPad Air 11-inch (M2)'"] + simulator: ["'iPhone 16'", "'iPad Air 11-inch (M2)'"] runs-on: ${{ matrix.os }} steps: - name: Grant write permissions to /usr/local