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

Attempt to fix the iOS CI build #176

Draft
wants to merge 7 commits into
base: master
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
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
17 changes: 16 additions & 1 deletion CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -166,7 +166,22 @@ elseif(UNIX)
if(APPLE)
set(CORRADE_TARGET_APPLE 1)

if(CMAKE_OSX_SYSROOT MATCHES "/iPhoneOS[0-9.]*\\.sdk")
# Since CMake 3.14, setting CMAKE_SYSTEM_NAME to iOS and not using any
# explicit toolchain file is the builtin way to build for iOS, not by
# overriding CMAKE_OSX_SYSROOT. For backwards compatiblity the
# CMAKE_OSX_SYSROOT check is present as well, but it isn't expected to
# be set anymore.
#
# CMAKE_OSX_SYSROOT originally also used to be used for switching
# between a device and a simulator build. Nowadays, an iOS binary is
# often made "fat", containing both device and simulator code, and
# building for either a device or the simulator is controlled via a
# -sdk option passed at the *build* time, i.e. there's no way to know
# whether it'll be a simulator at the *configure* time. Thus
# CORRADE_TARGET_IOS_SIMULATOR is no longer set.
if(CMAKE_SYSTEM_NAME STREQUAL iOS)
set(CORRADE_TARGET_IOS 1)
elseif(CMAKE_OSX_SYSROOT MATCHES "/iPhoneOS[0-9.]*\\.sdk")
set(CORRADE_TARGET_IOS 1)
elseif(CMAKE_OSX_SYSROOT MATCHES "/iPhoneSimulator[0-9.]*\\.sdk")
set(CORRADE_TARGET_IOS 1)
Expand Down
24 changes: 13 additions & 11 deletions modules/UseCorrade.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -450,18 +450,20 @@ function(corrade_add_test test_name)
${test_runner_file})
xctest_add_bundle(${test_name}Runner ${test_name} ${test_runner_file})
if(CORRADE_TARGET_IOS)
# The EFFECTIVE_PLATFORM_NAME variable is not expanded when using
# TARGET_* generator expressions on iOS, we need to hardcode it
# manually. See http://public.kitware.com/pipermail/cmake/2016-March/063049.html
# In case we redirect the runtime output directory, use that (and
# assume there's no TARGET_* generator expression). This will of
# course break when someone sets the LIBRARY_OUTPUT_DIRECTORY
# property of the target, but that didn't work before either.
if(CMAKE_LIBRARY_OUTPUT_DIRECTORY)
add_test(NAME ${test_name} COMMAND ${XCTest_EXECUTABLE} ${CMAKE_LIBRARY_OUTPUT_DIRECTORY}/${test_name}Runner.xctest)
else()
add_test(NAME ${test_name} COMMAND ${XCTest_EXECUTABLE} ${CMAKE_CURRENT_BINARY_DIR}/$<CONFIG>${_CORRADE_EFFECTIVE_PLATFORM_NAME}/${test_name}Runner.xctest)
if(NOT CORRADE_TESTSUITE_XCTEST_DESTINATION)
message(FATAL_ERROR "On iOS with CORRADE_TESTSUITE_TARGET_XCTEST enabled you need to set CORRADE_TESTSUITE_XCTEST_DESTINATION to a destination on which the tests should be run, such as \"platform=iOS Simulator,name=iPhone 12\"")
endif()
add_test(NAME ${test_name}
# TODO Running build-for-testing and then
# xcodebuild -xctestrun ${test_name}Runner.*.xctestrun
# with the generated files is significantly faster (probably
# because it doesn't need to parse the whole project every
# time), but so far I don't see how to run that as part of the
# build for all schemes
COMMAND xcodebuild test-without-building -scheme ${test_name}Runner -configuration $<CONFIG> -destination "${CORRADE_TESTSUITE_XCTEST_DESTINATION}" -only-testing:${test_name}Runner
# Has to be run in the directory where the xcodeproj is
# generated
WORKING_DIRECTORY ${CMAKE_BINARY_DIR})
else()
xctest_add_test(${test_name} ${test_name}Runner)
endif()
Expand Down
74 changes: 37 additions & 37 deletions package/ci/circleci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -444,40 +444,40 @@ workflows:
# if they pass, the rest of the jobs gets gradually executed, with further
# dependencies especially for the macOS jobs that take the most credits.
jobs:
- linux
- linux-nondeprecated
- linux-arm64:
requires:
- linux
- linux-nondeprecated
- linux-static:
requires:
- linux
- linux-nondeprecated
- linux-sanitizers:
requires:
- linux
- linux-nondeprecated
- linux-threadsanitizer:
requires:
- linux-sanitizers
- macos:
requires:
- linux
- linux-nondeprecated
- macos-static:
requires:
- macos
- linux-static
- emscripten:
requires:
- linux-static
- android-x86:
requires:
- linux-static
- linux-arm64
- ios:
requires:
- macos-static
- linux-arm64
- acme
# - linux
# - linux-nondeprecated
# - linux-arm64:
# requires:
# - linux
# - linux-nondeprecated
# - linux-static:
# requires:
# - linux
# - linux-nondeprecated
# - linux-sanitizers:
# requires:
# - linux
# - linux-nondeprecated
# - linux-threadsanitizer:
# requires:
# - linux-sanitizers
# - macos:
# requires:
# - linux
# - linux-nondeprecated
# - macos-static:
# requires:
# - macos
# - linux-static
# - emscripten:
# requires:
# - linux-static
# - android-x86:
# requires:
# - linux-static
# - linux-arm64
- ios
# requires:
# - macos-static
# - linux-arm64
# - acme
15 changes: 11 additions & 4 deletions package/ci/ios-simulator.sh
Original file line number Diff line number Diff line change
Expand Up @@ -19,17 +19,24 @@ cd ..
# Crosscompile
mkdir build-ios && cd build-ios
cmake .. \
-DCMAKE_TOOLCHAIN_FILE=../toolchains/generic/iOS.cmake \
-DCMAKE_OSX_SYSROOT=/Applications/Xcode.app/Contents/Developer/Platforms/iPhoneSimulator.platform/Developer/SDKs/iPhoneSimulator.sdk \
-DCMAKE_SYSTEM_NAME=iOS \
-DCMAKE_OSX_ARCHITECTURES="x86_64" \
-DCMAKE_OSX_SYSROOT=iphonesimulator \
-DCORRADE_RC_EXECUTABLE=$HOME/deps-native/bin/corrade-rc \
-DCMAKE_INSTALL_PREFIX=$HOME/deps \
-DCORRADE_BUILD_STATIC=ON \
-DCORRADE_BUILD_TESTS=ON \
-DCORRADE_TESTSUITE_TARGET_XCTEST=ON \
-DCORRADE_TESTSUITE_XCTEST_DESTINATION="platform=iOS Simulator,name=iPhone 8" \
-G Xcode
set -o pipefail && cmake --build . --config Release -j$XCODE_JOBS | xcbeautify
set -o pipefail && cmake --build . --config Release -j$XCODE_JOBS -- -sdk iphonesimulator | xcbeautify

# Boot a simulator before running tests. It's not required, but makes the tests
# run significantly faster (apparently because it then doesn't have to boot and
# shutdown a simulator every time?? ugh)
xcrun simctl boot "iPhone 8"

CORRADE_TEST_COLOR=ON ctest -V -C Release

# Test install, after running the tests as for them it shouldn't be needed
set -o pipefail && cmake --build . --config Release --target install -j$XCODE_JOBS | xcbeautify
set -o pipefail && cmake --build . --config Release --target install -j$XCODE_JOBS -- -sdk iphonesimulator | xcbeautify
7 changes: 7 additions & 0 deletions src/Corrade/Utility/Test/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -423,6 +423,13 @@ if(CORRADE_BUILD_STATIC AND NOT CORRADE_TARGET_EMSCRIPTEN AND NOT CORRADE_TARGET
add_library(UtilityGlobalStateAcrossLibrariesLibrary SHARED
GlobalStateAcrossLibrariesLibrary.cpp
${ResourceTestData})
if(CMAKE_GENERATOR STREQUAL Xcode)
# Xcode's "new build system" doesn't like when the same (generated)
# source file is used by two different targets (ResourceTestDataLib and
# UtilityGlobalStateAcrossLibrariesLibrary) that don't have any other
# dependency between them. WTF.
add_dependencies(UtilityGlobalStateAcrossLibrariesLibrary ResourceTestDataLib)
endif()
target_link_libraries(UtilityGlobalStateAcrossLibrariesLibrary PRIVATE CorradeUtility)

corrade_add_test(UtilityGlobalStateAcrossLibrariesTest
Expand Down
2 changes: 1 addition & 1 deletion src/Corrade/Utility/Test/ConfigurationTest.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -416,7 +416,7 @@ void ConfigurationTest::readonly() {

void ConfigurationTest::readError() {
#if defined(CORRADE_TARGET_IOS) && defined(CORRADE_TESTSUITE_TARGET_XCTEST)
if(!std::getenv("SIMULATOR_UDID"))
if(std::getenv("SIMULATOR_MAINSCREEN_SCALE"))
CORRADE_SKIP("iOS (in a simulator) thinks all paths are files, can't abuse a directory to simulate a read error.");
#endif

Expand Down
42 changes: 21 additions & 21 deletions src/Corrade/Utility/Test/DirectoryTest.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -378,7 +378,7 @@ DirectoryTest::DirectoryTest() {
if(System::isSandboxed()
#if defined(CORRADE_TARGET_IOS) && defined(CORRADE_TESTSUITE_TARGET_XCTEST)
/** @todo Fix this once I persuade CMake to run XCTest tests properly */
&& std::getenv("SIMULATOR_UDID")
&& !std::getenv("SIMULATOR_MAINSCREEN_SCALE")
#endif
) {
_testDir = Directory::join(Directory::path(Directory::executableLocation()), "PathTestFiles");
Expand Down Expand Up @@ -575,7 +575,7 @@ void DirectoryTest::existsUtf8() {
void DirectoryTest::isDirectory() {
{
#if defined(CORRADE_TARGET_IOS) && defined(CORRADE_TESTSUITE_TARGET_XCTEST)
CORRADE_EXPECT_FAIL_IF(!std::getenv("SIMULATOR_UDID"),
CORRADE_EXPECT_FAIL_IF(std::getenv("SIMULATOR_MAINSCREEN_SCALE"),
"iOS (in a simulator) thinks all paths are files.");
#endif
CORRADE_VERIFY(Directory::isDirectory(Directory::join(_testDir, "dir")));
Expand All @@ -599,7 +599,7 @@ void DirectoryTest::isDirectorySymlink() {
CORRADE_EXPECT_FAIL("Symlink support is implemented on Unix systems and Emscripten only.");
#endif
#if defined(CORRADE_TARGET_IOS) && defined(CORRADE_TESTSUITE_TARGET_XCTEST)
CORRADE_EXPECT_FAIL_IF(!std::getenv("SIMULATOR_UDID"),
CORRADE_EXPECT_FAIL_IF(std::getenv("SIMULATOR_MAINSCREEN_SCALE"),
"iOS (in a simulator) thinks all paths are files.");
#endif
CORRADE_VERIFY(Directory::isDirectory(Directory::join(_testDirSymlink, "dir-symlink")));
Expand Down Expand Up @@ -646,7 +646,7 @@ void DirectoryTest::isDirectoryNoPermission() {
void DirectoryTest::isDirectoryUtf8() {
{
#if defined(CORRADE_TARGET_IOS) && defined(CORRADE_TESTSUITE_TARGET_XCTEST)
CORRADE_EXPECT_FAIL_IF(!std::getenv("SIMULATOR_UDID"),
CORRADE_EXPECT_FAIL_IF(std::getenv("SIMULATOR_MAINSCREEN_SCALE"),
"iOS (in a simulator) thinks all paths are files.");
#endif
CORRADE_VERIFY(Directory::isDirectory(Directory::join(_testDirUtf8, "šňůra")));
Expand Down Expand Up @@ -1144,7 +1144,7 @@ void DirectoryTest::executableLocation() {
#ifdef CORRADE_TARGET_APPLE
if(System::isSandboxed()) {
#if defined(CORRADE_TARGET_IOS) && defined(CORRADE_TESTSUITE_TARGET_XCTEST)
CORRADE_EXPECT_FAIL_IF(!std::getenv("SIMULATOR_UDID"),
CORRADE_EXPECT_FAIL_IF(std::getenv("SIMULATOR_MAINSCREEN_SCALE"),
"CTest is not able to run XCTest executables properly in the simulator.");
#endif

Expand Down Expand Up @@ -1314,7 +1314,7 @@ void DirectoryTest::tmp() {
#if defined(CORRADE_TARGET_UNIX) || defined(CORRADE_TARGET_EMSCRIPTEN)
{
#if defined(CORRADE_TARGET_IOS) && defined(CORRADE_TESTSUITE_TARGET_XCTEST)
CORRADE_EXPECT_FAIL_IF(!std::getenv("SIMULATOR_UDID"),
CORRADE_EXPECT_FAIL_IF(std::getenv("SIMULATOR_MAINSCREEN_SCALE"),
"CTest is not able to run XCTest executables properly in the simulator.");
#endif
CORRADE_VERIFY(Directory::exists(dir));
Expand Down Expand Up @@ -1350,7 +1350,7 @@ void DirectoryTest::tmp() {
/* Verify that it's possible to write stuff there */
{
#if defined(CORRADE_TARGET_IOS) && defined(CORRADE_TESTSUITE_TARGET_XCTEST)
CORRADE_EXPECT_FAIL_IF(!std::getenv("SIMULATOR_UDID"),
CORRADE_EXPECT_FAIL_IF(std::getenv("SIMULATOR_MAINSCREEN_SCALE"),
"CTest is not able to run XCTest executables properly in the simulator.");
#endif
/* PathTest writes a file named 'a', and often these two tests get run
Expand All @@ -1371,7 +1371,7 @@ void DirectoryTest::tmpUtf8() {

void DirectoryTest::list() {
#if defined(CORRADE_TARGET_IOS) && defined(CORRADE_TESTSUITE_TARGET_XCTEST)
CORRADE_EXPECT_FAIL_IF(!std::getenv("SIMULATOR_UDID"),
CORRADE_EXPECT_FAIL_IF(std::getenv("SIMULATOR_MAINSCREEN_SCALE"),
"CTest is not able to run XCTest executables properly in the simulator.");
#endif

Expand All @@ -1382,7 +1382,7 @@ void DirectoryTest::list() {

void DirectoryTest::listSkipDirectories() {
#if defined(CORRADE_TARGET_IOS) && defined(CORRADE_TESTSUITE_TARGET_XCTEST)
CORRADE_EXPECT_FAIL_IF(!std::getenv("SIMULATOR_UDID"),
CORRADE_EXPECT_FAIL_IF(std::getenv("SIMULATOR_MAINSCREEN_SCALE"),
"CTest is not able to run XCTest executables properly in the simulator.");
#endif

Expand All @@ -1393,7 +1393,7 @@ void DirectoryTest::listSkipDirectories() {

void DirectoryTest::listSkipDirectoriesSymlinks() {
#if defined(CORRADE_TARGET_IOS) && defined(CORRADE_TESTSUITE_TARGET_XCTEST)
CORRADE_EXPECT_FAIL_IF(!std::getenv("SIMULATOR_UDID"),
CORRADE_EXPECT_FAIL_IF(std::getenv("SIMULATOR_MAINSCREEN_SCALE"),
"CTest is not able to run XCTest executables properly in the simulator.");
#endif

Expand All @@ -1409,7 +1409,7 @@ void DirectoryTest::listSkipDirectoriesSymlinks() {

void DirectoryTest::listSkipFiles() {
#if defined(CORRADE_TARGET_IOS) && defined(CORRADE_TESTSUITE_TARGET_XCTEST)
CORRADE_EXPECT_FAIL_IF(!std::getenv("SIMULATOR_UDID"),
CORRADE_EXPECT_FAIL_IF(std::getenv("SIMULATOR_MAINSCREEN_SCALE"),
"CTest is not able to run XCTest executables properly in the simulator.");
#endif

Expand All @@ -1420,7 +1420,7 @@ void DirectoryTest::listSkipFiles() {

void DirectoryTest::listSkipFilesSymlinks() {
#if defined(CORRADE_TARGET_IOS) && defined(CORRADE_TESTSUITE_TARGET_XCTEST)
CORRADE_EXPECT_FAIL_IF(!std::getenv("SIMULATOR_UDID"),
CORRADE_EXPECT_FAIL_IF(std::getenv("SIMULATOR_MAINSCREEN_SCALE"),
"CTest is not able to run XCTest executables properly in the simulator.");
#endif

Expand All @@ -1436,7 +1436,7 @@ void DirectoryTest::listSkipFilesSymlinks() {

void DirectoryTest::listSkipSpecial() {
#if defined(CORRADE_TARGET_IOS) && defined(CORRADE_TESTSUITE_TARGET_XCTEST)
CORRADE_EXPECT_FAIL_IF(!std::getenv("SIMULATOR_UDID"),
CORRADE_EXPECT_FAIL_IF(std::getenv("SIMULATOR_MAINSCREEN_SCALE"),
"CTest is not able to run XCTest executables properly in the simulator.");
#endif

Expand All @@ -1447,7 +1447,7 @@ void DirectoryTest::listSkipSpecial() {

void DirectoryTest::listSkipSpecialSymlink() {
#if defined(CORRADE_TARGET_IOS) && defined(CORRADE_TESTSUITE_TARGET_XCTEST)
CORRADE_EXPECT_FAIL_IF(!std::getenv("SIMULATOR_UDID"),
CORRADE_EXPECT_FAIL_IF(std::getenv("SIMULATOR_MAINSCREEN_SCALE"),
"CTest is not able to run XCTest executables properly in the simulator.");
#endif

Expand All @@ -1459,7 +1459,7 @@ void DirectoryTest::listSkipSpecialSymlink() {

void DirectoryTest::listSkipDotAndDotDot() {
#if defined(CORRADE_TARGET_IOS) && defined(CORRADE_TESTSUITE_TARGET_XCTEST)
CORRADE_EXPECT_FAIL_IF(!std::getenv("SIMULATOR_UDID"),
CORRADE_EXPECT_FAIL_IF(std::getenv("SIMULATOR_MAINSCREEN_SCALE"),
"CTest is not able to run XCTest executables properly in the simulator.");
#endif

Expand All @@ -1470,7 +1470,7 @@ void DirectoryTest::listSkipDotAndDotDot() {

void DirectoryTest::listSort() {
#if defined(CORRADE_TARGET_IOS) && defined(CORRADE_TESTSUITE_TARGET_XCTEST)
CORRADE_EXPECT_FAIL_IF(!std::getenv("SIMULATOR_UDID"),
CORRADE_EXPECT_FAIL_IF(std::getenv("SIMULATOR_MAINSCREEN_SCALE"),
"CTest is not able to run XCTest executables properly in the simulator.");
#endif

Expand Down Expand Up @@ -1523,7 +1523,7 @@ void DirectoryTest::listUtf8() {

#ifdef CORRADE_TARGET_APPLE
#if defined(CORRADE_TARGET_IOS) && defined(CORRADE_TESTSUITE_TARGET_XCTEST)
CORRADE_EXPECT_FAIL_IF(!std::getenv("SIMULATOR_UDID"),
CORRADE_EXPECT_FAIL_IF(std::getenv("SIMULATOR_MAINSCREEN_SCALE"),
"CTest is not able to run XCTest executables properly in the simulator.");
#endif

Expand Down Expand Up @@ -1588,7 +1588,7 @@ void DirectoryTest::fileSizeEarlyEof() {

void DirectoryTest::fileSizeDirectory() {
#if defined(CORRADE_TARGET_IOS) && defined(CORRADE_TESTSUITE_TARGET_XCTEST)
if(!std::getenv("SIMULATOR_UDID"))
if(std::getenv("SIMULATOR_MAINSCREEN_SCALE"))
CORRADE_SKIP("iOS (in a simulator) thinks all paths are files, can't test.");
#endif

Expand Down Expand Up @@ -1674,7 +1674,7 @@ void DirectoryTest::readEarlyEof() {

void DirectoryTest::readDirectory() {
#if defined(CORRADE_TARGET_IOS) && defined(CORRADE_TESTSUITE_TARGET_XCTEST)
if(!std::getenv("SIMULATOR_UDID"))
if(std::getenv("SIMULATOR_MAINSCREEN_SCALE"))
CORRADE_SKIP("iOS (in a simulator) thinks all paths are files, can't test.");
#endif

Expand Down Expand Up @@ -1945,7 +1945,7 @@ void DirectoryTest::copyEmpty() {

void DirectoryTest::copyDirectory() {
#if defined(CORRADE_TARGET_IOS) && defined(CORRADE_TESTSUITE_TARGET_XCTEST)
if(!std::getenv("SIMULATOR_UDID"))
if(std::getenv("SIMULATOR_MAINSCREEN_SCALE"))
CORRADE_SKIP("iOS (in a simulator) thinks all paths are files, can't test.");
#endif

Expand Down Expand Up @@ -2230,7 +2230,7 @@ void DirectoryTest::mapReadEmpty() {

void DirectoryTest::mapReadDirectory() {
#if defined(CORRADE_TARGET_IOS) && defined(CORRADE_TESTSUITE_TARGET_XCTEST)
if(!std::getenv("SIMULATOR_UDID"))
if(std::getenv("SIMULATOR_MAINSCREEN_SCALE"))
CORRADE_SKIP("iOS (in a simulator) thinks all paths are files, can't test.");
#endif

Expand Down
Loading