From 0ab350f5de8745b1e50d07e33f84c3b5c69098fe Mon Sep 17 00:00:00 2001 From: Bas Hendri Date: Mon, 4 May 2020 13:26:50 -0700 Subject: [PATCH 1/3] enables iOS and Android testing --- .github/workflows/main.yml | 94 ++++++++++++++++++++++++++++++++++++++ 1 file changed, 94 insertions(+) create mode 100644 .github/workflows/main.yml diff --git a/.github/workflows/main.yml b/.github/workflows/main.yml new file mode 100644 index 0000000..8a9ca62 --- /dev/null +++ b/.github/workflows/main.yml @@ -0,0 +1,94 @@ +name: CI +on: + push: + branches: [ master ] + pull_request: + branches: [ master ] + +jobs: + iOS: + runs-on: macos-latest + defaults: + run: + working-directory: build + steps: + - uses: actions/checkout@v2 + + - name: Create build directory + run: mkdir -p build + working-directory: . + + - name: Configure + run: | + cmake \ + -GXcode \ + -DCMAKE_SYSTEM_NAME=iOS \ + "-DCMAKE_OSX_ARCHITECTURES=arm64;x86_64" \ + -DCMAKE_OSX_DEPLOYMENT_TARGET=8 \ + -DCMAKE_TRY_COMPILE_TARGET_TYPE=STATIC_LIBRARY \ + "-DMACOSX_BUNDLE_GUI_IDENTIFIER=GSL.\$(EXECUTABLE_NAME)" \ + -DMACOSX_BUNDLE_BUNDLE_VERSION=3.0.1 \ + -DMACOSX_BUNDLE_SHORT_VERSION_STRING=3.0.1 \ + .. + + - name: Build + run: cmake --build . --parallel `sysctl -n hw.ncpu` --config Release -- -sdk iphonesimulator + + - name: Start simulator + run: | + RUNTIME=`xcrun simctl list runtimes iOS -j|jq '.runtimes|last.identifier'` + UDID=`xcrun simctl list devices iPhone available -j|jq -r ".devices[$RUNTIME]|last.udid"` + xcrun simctl bootstatus $UDID -b + + - name: Test + run: | + for TEST in `find tests/Release-iphonesimulator -depth 1 -name "*.app"` + do + xcrun simctl install booted $TEST + TEST_ID=`plutil -convert json -o - $TEST/Info.plist|jq -r ".CFBundleIdentifier"` + xcrun simctl launch --console booted $TEST_ID + xcrun simctl uninstall booted $TEST_ID + done + + Android: + runs-on: macos-latest + defaults: + run: + working-directory: build + steps: + - uses: actions/checkout@v2 + + - name: Create build directory + run: mkdir -p build + working-directory: . + + - name: Start emulator + run: | + echo "y" | $ANDROID_HOME/tools/bin/sdkmanager --install 'system-images;android-24;default;x86_64' + echo "no" | $ANDROID_HOME/tools/bin/avdmanager create avd -n xamarin_android_emulator -k 'system-images;android-24;default;x86_64' --force + $ANDROID_HOME/emulator/emulator -list-avds + echo "Starting emulator" + # Start emulator in background + nohup $ANDROID_HOME/emulator/emulator -avd xamarin_android_emulator -no-snapshot > /dev/null 2>&1 & + echo "Emulator starting" + + - name: Configure + run: cmake -DCMAKE_TOOLCHAIN_FILE=$ANDROID_HOME/ndk-bundle/build/cmake/android.toolchain.cmake -DANDROID_PLATFORM=16 -DANDROID_ABI=x86_64 -DCMAKE_BUILD_TYPE=Debug .. + + - name: Build + run: cmake --build . --parallel + + - name: Wait for emulator ready + run: | + $ANDROID_HOME/platform-tools/adb wait-for-device shell 'while [[ -z $(getprop sys.boot_completed | tr -d '\r') ]]; do sleep 10; done; input keyevent 82' + $ANDROID_HOME/platform-tools/adb devices + $ANDROID_HOME/platform-tools/adb shell getprop ro.product.cpu.abi + echo "Emulator started" + + - name: Deploy tests + run: | + adb push tests /data/local/tmp + adb shell find /data/local/tmp/tests -maxdepth 1 -exec chmod +x {} \\\; + + - name: Test + run: adb shell find /data/local/tmp/tests -name "*_tests" -maxdepth 1 -exec {} \\\; \ No newline at end of file From 91858ca3f32c4c7d7704b7ed72043caa451377a3 Mon Sep 17 00:00:00 2001 From: Bas Hendri Date: Mon, 4 May 2020 13:31:08 -0700 Subject: [PATCH 2/3] forces GTEST_HAS_DEATH_TEST --- CMakeLists.txt | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 6a12c33..5077fbd 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -14,7 +14,7 @@ add_library(GSL INTERFACE) # determine whether this is a standalone project or included by other projects set(GSL_STANDALONE_PROJECT OFF) if (CMAKE_CURRENT_SOURCE_DIR STREQUAL CMAKE_SOURCE_DIR) - set(GSL_STANDALONE_PROJECT ON) + set(GSL_STANDALONE_PROJECT ON) endif () set(GSL_CXX_STANDARD "14" CACHE STRING "Use c++ standard") @@ -98,6 +98,11 @@ add_library(Microsoft.GSL::GSL ALIAS GSL) option(GSL_TEST "Generate tests." ${GSL_STANDALONE_PROJECT}) if (GSL_TEST) - enable_testing() - add_subdirectory(tests) + enable_testing() + if(IOS) + add_compile_definitions( + GTEST_HAS_DEATH_TEST=1 + ) + endif() + add_subdirectory(tests) endif () From 1e4e23738c9b70644656aee4ea4fc50a051f7793 Mon Sep 17 00:00:00 2001 From: Bas Hendri Date: Thu, 7 May 2020 15:44:56 -0700 Subject: [PATCH 3/3] updates README.md with iOS & Android support --- README.md | 2 ++ 1 file changed, 2 insertions(+) diff --git a/README.md b/README.md index fc6d46c..f4d4e02 100644 --- a/README.md +++ b/README.md @@ -44,6 +44,8 @@ The test suite that exercises GSL has been built and passes successfully on the * OS X El Capitan (10.11) using Xcode with AppleClang 8.0.0.8000042 * OS X High Sierra 10.13.2 (17C88) using Apple LLVM version 9.0.0 (clang-900.0.39.2) * FreeBSD 10.x with Clang/LLVM 3.6 +* iOS 8 and newer using AppleClang 11.0.3.11030032 +* Android 4.1 and newer (API Level 16 and above) using NDK r21b > If you successfully port GSL to another platform, we would love to hear from you. Please submit an issue to let us know. Also please consider contributing any changes that were necessary back to this project to benefit the wider community.