Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Bump macOS version and fix iOS build #1326

Merged
merged 64 commits into from
Feb 10, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
64 commits
Select commit Hold shift + click to select a range
1048418
bump macos version
lalitb Sep 5, 2024
742fea4
Merge branch 'main' into bump-macos-12-14
lalitb Sep 5, 2024
10a2697
incorrect version
lalitb Sep 5, 2024
cb4d84d
check install prefix access
lalitb Sep 5, 2024
c89e0d9
Merge branch 'main' into bump-macos-12-14
mkoscumb Sep 10, 2024
fbf4c6a
Merge branch 'main' into bump-macos-12-14
ThomsonTan Oct 24, 2024
262a4e1
Merge branch 'main' into bump-macos-12-14
lalitb Jan 21, 2025
db048cf
fix the cmake to not exit if the write test fail
Jan 21, 2025
4e7e8cc
macos12 is deprecated. switch to macos13 and macos15
lalitb Jan 21, 2025
7dac26f
try to gracefully fail for write
lalitb Jan 21, 2025
0c7ff51
more cleaner check
lalitb Jan 22, 2025
c058ef3
update ci yaml
lalitb Jan 22, 2025
a500fcb
update the simulators
lalitb Jan 22, 2025
72bf84a
use iphone 16 as simulator
lalitb Jan 22, 2025
d1e8284
Merge branch 'main' into bump-macos-12-14
ThomsonTan Feb 6, 2025
2c4f2ba
Add debug code to build-gtest.sh
ThomsonTan Feb 6, 2025
3c7d85b
Add more log
ThomsonTan Feb 7, 2025
da2986b
Update checkout action
ThomsonTan Feb 7, 2025
200632a
Fix checkout submodules
ThomsonTan Feb 7, 2025
f6bd624
Fix build variable name
ThomsonTan Feb 7, 2025
ff8f3ad
Add more log
ThomsonTan Feb 7, 2025
2c5d740
Set architecture
ThomsonTan Feb 7, 2025
4729037
Set one more flag
ThomsonTan Feb 7, 2025
655fa47
Dump the arch of gtest library
ThomsonTan Feb 7, 2025
c7c5b83
Add optin for lipo
ThomsonTan Feb 7, 2025
7a1b68e
Log test target
ThomsonTan Feb 7, 2025
cc036d2
Add build entry/exit log
ThomsonTan Feb 7, 2025
32326b8
Build for active arch only
ThomsonTan Feb 7, 2025
9e0ec42
Log arch
ThomsonTan Feb 7, 2025
0e81432
Check variable cache
ThomsonTan Feb 7, 2025
f1d6321
Make CMAKE_OSX_SYSROOT as cache variable
ThomsonTan Feb 7, 2025
09c7c45
Add system name variable
ThomsonTan Feb 7, 2025
1fc2392
Add verbose log
ThomsonTan Feb 7, 2025
b5e47d9
Add verbose log to xcode
ThomsonTan Feb 8, 2025
6f3dcfa
Get dyld-info log
ThomsonTan Feb 8, 2025
ac75b72
Add verbose log to xcode test
ThomsonTan Feb 8, 2025
44c01ee
Install cctools
ThomsonTan Feb 8, 2025
37c4b95
Fix dyldinfo path
ThomsonTan Feb 8, 2025
b80465a
Comment out dyndinfo
ThomsonTan Feb 8, 2025
56f17d7
Add log of gtest path
ThomsonTan Feb 8, 2025
af7ccfa
Debug log
ThomsonTan Feb 8, 2025
fe5ae4e
Set find mode
ThomsonTan Feb 8, 2025
0f5aaab
Set find mode for functests
ThomsonTan Feb 8, 2025
d255b19
set target
ThomsonTan Feb 8, 2025
caa3838
Update IPHONEOS_DEPLOYMENT_TARGET
ThomsonTan Feb 8, 2025
d7bfd26
Add include path
ThomsonTan Feb 8, 2025
0a18645
Fix include
ThomsonTan Feb 8, 2025
21ddfc2
Add functests log
ThomsonTan Feb 8, 2025
97ff66a
Add include dir to xcode project
ThomsonTan Feb 8, 2025
9870c05
update iOS version
ThomsonTan Feb 8, 2025
eee6b7e
revert iOS version
ThomsonTan Feb 8, 2025
ac2c608
Set OS version for xcodebuild
ThomsonTan Feb 8, 2025
97efad0
Log destinations
ThomsonTan Feb 8, 2025
6b65f60
Add scheme
ThomsonTan Feb 8, 2025
98af7d2
Log sdk version
ThomsonTan Feb 8, 2025
e738e18
More logs
ThomsonTan Feb 8, 2025
a79200b
Update iOS versio in CI matrics
ThomsonTan Feb 8, 2025
2024398
Remove OS version
ThomsonTan Feb 8, 2025
ba36495
Remvoe macos-13
ThomsonTan Feb 8, 2025
69fcf70
Delete old workflow
ThomsonTan Feb 9, 2025
86e1d65
Cleanup
ThomsonTan Feb 9, 2025
bb61474
Add macos-13 to CI workflow
ThomsonTan Feb 9, 2025
c86addd
Remove unnecessary include
ThomsonTan Feb 9, 2025
ee32e40
Exclude unnecessary matrix
ThomsonTan Feb 9, 2025
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
54 changes: 54 additions & 0 deletions .github/workflows/build-ios-mac.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,54 @@
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-13, macos-15]
config: [release, debug]
simulator: ["'iPhone 15'", "'iPad Pro (11-inch) (4th generation)'", "'iPhone 16'", "'iPad Air 11-inch (M2)'"]
exclude:
- os: macos-13
simulator: "'iPhone 16'"
- os: macos-13
simulator: "'iPad Air 11-inch (M2)'"
- os: macos-15
simulator: "'iPhone 15'"
- os: macos-15
simulator: "'iPad Pro (11-inch) (4th 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'
continue-on-error: true
- name: build
run: |
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 }}
35 changes: 0 additions & 35 deletions .github/workflows/build-ios-mac11.yml

This file was deleted.

45 changes: 45 additions & 0 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,6 +1,51 @@
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()


# Set installation prefix for Unix systems (macOS and Linux)
if(UNIX AND NOT DEFINED CMAKE_INSTALL_PREFIX)
ThomsonTan marked this conversation as resolved.
Show resolved Hide resolved
# 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()



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")
Expand Down
13 changes: 10 additions & 3 deletions build-gtest.sh
Original file line number Diff line number Diff line change
Expand Up @@ -27,19 +27,25 @@ fi
echo "Add ios and arm64 build steps for googletest"
cat > $GTEST_PATH/CMakeLists_temp.txt << EOF
# If building for iOS, set all the iOS options
if(BUILD_IOS)
if(BUILD_IOS)
message("-- Building for iOS simulator..")
message("-- CMAKE_OSX_DEPLOYMENT_TARGET \${CMAKE_OSX_DEPLOYMENT_TARGET}")
message("-- CMAKE_SYSTEM_NAME \${CMAKE_SYSTEM_NAME}")
message("-- CMAKE_OSX_ARCHITECTURES \${CMAKE_OSX_ARCHITECTURES}")
set(TARGET_ARCH "APPLE")
set(IOS True)
set(APPLE True)
set(CMAKE_OSX_DEPLOYMENT_TARGET "" CACHE STRING "Force unset of the deployment target for iOS" FORCE)
set(CMAKE_SYSTEM_NAME 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
OUTPUT_VARIABLE CMAKE_OSX_SYSROOT
OUTPUT_VARIABLE CMAKE_OSX_SYSROOT_OUT
ERROR_QUIET
OUTPUT_STRIP_TRAILING_WHITESPACE)
set(CMAKE_OSX_SYSROOT \${CMAKE_OSX_SYSROOT_OUT} CACHE STRING "Force set of the sysroot for iOS" FORCE)
message("-- CMAKE_OSX_SYSROOT \${CMAKE_OSX_SYSROOT}")
elseif(\${ARCH} STREQUAL "arm64")
set(CMAKE_C_FLAGS "\${CMAKE_C_FLAGS} -arch arm64")
Expand Down Expand Up @@ -67,6 +73,7 @@ cmake -Dgtest_build_samples=OFF \
-DARCH=$ARCH \
..
make

popd
# CTEST_OUTPUT_ON_FAILURE=1 make test
# make install
7 changes: 7 additions & 0 deletions build-tests-ios.sh
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,16 @@ SKU=${1:-release}
SIMULATOR=${2:-iPhone 8}

set -e

./build-ios.sh ${SKU}

# dyld_info /Users/runner/work/cpp_client_telemetry/cpp_client_telemetry/out/lib/libmat.a

cd tests/unittests

xcrun simctl list devices available
echo 'End of xcrun simctl list devices available'

xcodebuild test -scheme iOSUnitTests -destination "platform=iOS Simulator,name=$SIMULATOR"

cd ../functests
Expand Down
2 changes: 2 additions & 0 deletions tests/functests/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -108,6 +108,8 @@ else()
message("Current Dir: ${CMAKE_CURRENT_SOURCE_DIR}")
message("Binary Dir: ${CMAKE_BINARY_DIR}")

set(CMAKE_FIND_ROOT_PATH_MODE_INCLUDE NEVER)

find_file(LIBGTEST
NAMES libgtest.a
PATHS
Expand Down
6 changes: 4 additions & 2 deletions tests/functests/functests-ios.xcodeproj/project.pbxproj
Original file line number Diff line number Diff line change
Expand Up @@ -317,6 +317,7 @@
GCC_WARN_UNUSED_VARIABLE = YES;
HEADER_SEARCH_PATHS = (
../,
../..,
../../lib/,
../../lib/include/,
../../lib/include/mat/,
Expand All @@ -326,7 +327,7 @@
../../third_party/googletest/googlemock/include/,
../common/,
);
IPHONEOS_DEPLOYMENT_TARGET = 11.2;
IPHONEOS_DEPLOYMENT_TARGET = 12.2;
MTL_ENABLE_DEBUG_INFO = INCLUDE_SOURCE;
MTL_FAST_MATH = YES;
ONLY_ACTIVE_ARCH = NO;
Expand Down Expand Up @@ -380,6 +381,7 @@
GCC_WARN_UNUSED_VARIABLE = YES;
HEADER_SEARCH_PATHS = (
../,
../..,
../../lib/,
../../lib/include/,
../../lib/include/mat/,
Expand All @@ -389,7 +391,7 @@
../../third_party/googletest/googlemock/include/,
../common/,
);
IPHONEOS_DEPLOYMENT_TARGET = 11.2;
IPHONEOS_DEPLOYMENT_TARGET = 12.2;
MTL_ENABLE_DEBUG_INFO = NO;
MTL_FAST_MATH = YES;
ONLY_ACTIVE_ARCH = YES;
Expand Down
5 changes: 5 additions & 0 deletions tests/unittests/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -147,6 +147,8 @@ else()

include_directories( ${CMAKE_CURRENT_SOURCE_DIR}/../../lib/ )

set(CMAKE_FIND_ROOT_PATH_MODE_INCLUDE NEVER)

find_file(LIBGTEST
NAMES libgtest.a
PATHS
Expand All @@ -159,6 +161,9 @@ else()
${CMAKE_CURRENT_SOURCE_DIR}/../../third_party/googletest/build/lib/
)

message("GTEST: ${LIBGTEST}")
message("GMOCK: ${LIBGMOCK}")

target_link_libraries(UnitTests
${LIBGTEST}
${LIBGMOCK}
Expand Down
Loading