From add796c49c0251a86ba08b4bc6859c77d2c49310 Mon Sep 17 00:00:00 2001 From: nikitalita <69168929+nikitalita@users.noreply.github.com> Date: Wed, 15 Nov 2023 01:47:37 -0800 Subject: [PATCH 1/3] fix test build on macos --- test/CMakeLists.txt | 27 +++++++++++++++++++++++++-- 1 file changed, 25 insertions(+), 2 deletions(-) diff --git a/test/CMakeLists.txt b/test/CMakeLists.txt index e2380340..a4136a47 100644 --- a/test/CMakeLists.txt +++ b/test/CMakeLists.txt @@ -5,6 +5,29 @@ else() message(STATUS "Found pybind11 v${pybind11_VERSION}: ${pybind11_INCLUDE_DIRS} and ${pybind11_INCLUDE_DIR}") endif() +# set up the include paths for macos if necessary +if(CMAKE_HOST_SYSTEM_NAME MATCHES "Darwin") + # try running xcrun --show-sdk-path to get the SDK path + execute_process(COMMAND xcrun --show-sdk-path + RESULT_VARIABLE _XCRUN_RESULT + OUTPUT_VARIABLE _XCRUN_OUTPUT + ERROR_QUIET + OUTPUT_STRIP_TRAILING_WHITESPACE) + if (NOT _XCRUN_RESULT EQUAL 0) + set(APPLE_ISYSROOT_DIR "/Library/Developer/CommandLineTools") + else() + set(APPLE_ISYSROOT_DIR ${_XCRUN_OUTPUT}) + endif() + set(APPLE_BASE_C_INCLUDE_PATH "/usr/include/") + set(APPLE_BASE_CPP_INCLUDE_PATH "/usr/include/c++/v1/") + set(APPLE_BASE_SYSTEM_HEADERS "/System/Library/Frameworks/Kernel.framework/Headers") + set(APPLE_C_AND_CPP_INCLUDE_PATH "${APPLE_ISYSROOT_DIR}/${APPLE_BASE_CPP_INCLUDE_PATH}:${APPLE_ISYSROOT_DIR}/${APPLE_BASE_C_INCLUDE_PATH}:${LibClang_INCLUDE_DIR}") + string(REGEX MATCH "^[0-9]+\\.[0-9]+\\.[0-9]+" _CLANG_COMPILER_VERSION ${CMAKE_CXX_COMPILER_VERSION}) + message(STATUS "CLANG_COMPILER_VERSION: ${_CLANG_COMPILER_VERSION}") + message(STATUS "APPLE_ISYSROOT_DIR: ${APPLE_ISYSROOT_DIR}") + message(STATUS "APPLE_C_AND_CPP_INCLUDE_PATH: ${APPLE_C_AND_CPP_INCLUDE_PATH}") +endif() + macro( binder_src stestname) string(REPLACE "." "_" stestnamenodot ${stestname}) message( STATUS "binder test: building ${stestnamenodot}.cpp for ${stestname}" ) @@ -23,10 +46,10 @@ else() if(CMAKE_HOST_SYSTEM_NAME MATCHES "Darwin") ADD_CUSTOM_TARGET(target${stestnamenodot}cpp #The first two expressions below are for older clang - COMMAND C_INCLUDE_PATH=${LibClang_INCLUDE_DIR}:/Library/Developer/CommandLineTools/usr/include/c++/v1/ CPLUS_INCLUDE_PATH=${LibClang_INCLUDE_DIR}:/Library/Developer/CommandLineTools/usr/include/c++/v1/ + COMMAND C_INCLUDE_PATH=${APPLE_C_AND_CPP_INCLUDE_PATH} CPLUS_INCLUDE_PATH=${APPLE_C_AND_CPP_INCLUDE_PATH} ${CMAKE_BINARY_DIR}/source/binder --bind "" -max-file-size=100000 --root-module ${stestnamenodot} --prefix ${CMAKE_CURRENT_BINARY_DIR}/ ${${stestname}_config_flag} --single-file --annotate-includes ${CMAKE_CURRENT_BINARY_DIR}/${stestname}.hpp.include ${${stestname}_cli_flags} - -- -x c++ -std=c++11 -I . -I ${CMAKE_CURRENT_SOURCE_DIR} -isystem / -I ${CLANG_INCLUDE_DIRS} -iwithsysroot${LibClang_INCLUDE_DIR} + -- -x c++ -std=c++11 -I . -I ${CMAKE_CURRENT_SOURCE_DIR} -isystem / -I ${CLANG_INCLUDE_DIRS} -isysroot${APPLE_ISYSROOT_DIR} -iwithsysroot${APPLE_BASE_CPP_INCLUDE_PATH} -iwithsysroot${APPLE_BASE_C_INCLUDE_PATH} -isystem${LibClang_INCLUDE_DIR} WORKING_DIRECTORY "${CMAKE_CURRENT_SOURCE_DIR}" VERBATIM) else() ADD_CUSTOM_TARGET(target${stestnamenodot}cpp From ad13dfad3fcdca6c7bcaef0e811c037830bb5cc9 Mon Sep 17 00:00:00 2001 From: nikitalita <69168929+nikitalita@users.noreply.github.com> Date: Wed, 15 Nov 2023 00:54:06 -0800 Subject: [PATCH 2/3] Skip Python 2 tests if pybind11 > 2.9 2.9 was the last version to support python 2 --- test/CMakeLists.txt | 14 ++++++++++++++ 1 file changed, 14 insertions(+) diff --git a/test/CMakeLists.txt b/test/CMakeLists.txt index a4136a47..ad04b9f9 100644 --- a/test/CMakeLists.txt +++ b/test/CMakeLists.txt @@ -3,6 +3,13 @@ if("0" STREQUAL ${BINDER_TEST_PYTHON_VERSIONS}) else() find_package(pybind11 CONFIG REQUIRED) message(STATUS "Found pybind11 v${pybind11_VERSION}: ${pybind11_INCLUDE_DIRS} and ${pybind11_INCLUDE_DIR}") + string(REGEX REPLACE "^v" "" _pybind11_VERSION "${pybind11_VERSION}") + if(_pybind11_VERSION VERSION_LESS "2.10") # 2.9 was the last version to support Python 2 + set(TEST_PYTHON_2 TRUE) + else() + message(WARNING "pybind11 version ${pybind11_VERSION} does not have support for Python 2. Python 2 tests will be disabled." ) + set(TEST_PYTHON_2 FALSE) + endif() endif() # set up the include paths for macos if necessary @@ -160,6 +167,13 @@ foreach ( tests ${binder_tests} ) endforeach ( tests ${binder_tests} ) foreach( pver ${TESTVERSIONS} ) + string(SUBSTRING ${pver} 0 1 FIRSTCHAR) + if (${FIRSTCHAR} STREQUAL "2") + if (NOT TEST_PYTHON_2) + message(STATUS "Skipping Python ${pver} tests.") + continue() + endif() + endif() string(REPLACE "." ";" MAJMIN "${pver}.X.Y") list(GET MAJMIN 0 MAJ) list(GET MAJMIN 1 MIN) From 6e262595d8da030104f6f73eaf102951fb493ded Mon Sep 17 00:00:00 2001 From: nikitalita <69168929+nikitalita@users.noreply.github.com> Date: Wed, 15 Nov 2023 01:07:06 -0800 Subject: [PATCH 3/3] CI: Actually fail on failed macos tests --- .github/workflows/osx/entrypoint.sh | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/.github/workflows/osx/entrypoint.sh b/.github/workflows/osx/entrypoint.sh index f32cd528..39ec3532 100755 --- a/.github/workflows/osx/entrypoint.sh +++ b/.github/workflows/osx/entrypoint.sh @@ -9,5 +9,9 @@ export PATH=$PATH:clang+llvm-11.0.0-x86_64-apple-darwin/bin cmake CMakeLists.txt make otool -L source/binder -ctest . --output-on-failure +ctest . --output-on-failure +out=$? cat Testing/Temporary/LastTest.log +if [ $out -ne 0 ]; then + exit $out +fi \ No newline at end of file