diff --git a/.github/workflows/ci-mobile.yml b/.github/workflows/ci-mobile.yml new file mode 100644 index 0000000000..1b9d5d0d37 --- /dev/null +++ b/.github/workflows/ci-mobile.yml @@ -0,0 +1,86 @@ +# +# GitHub Actions workflow for building cpprestsdk on iOS and Android +# +# Note: Please do not include any non-mobile targets in this workflow because +# we don't want a failure in one of several dozens Linux distributions +# hide a problem in the only 2 targets our mobile developers care about! +# +name: Mobile + +on: [push] + +jobs: + build: + strategy: + matrix: + os: [ubuntu-latest,macos-latest] + flavor: [Release] # Only use one of Debug/Release (capitalized) for now to save on minutes + fail-fast: false + + runs-on: ${{ matrix.os }} + + steps: + - name: Checkout Sources + uses: actions/checkout@v1 + with: + fetch-depth: 1 + - name: Update Submodules + run: git submodule update --init + - name: Build (iOS) + timeout-minutes: 30 + run: | + set -x + mkdir -p bins/ios/cpprestsdk + pushd Build_iOS + BOOST_VERSION="1.71.0" OPENSSL_VERSION="1.1.1d" ./configure.sh -build_type ${{ matrix.flavor }} + ls -alFR . + if [ -f build.${{ matrix.flavor }}.ios/lib/libcpprest.a ]; then mv build.${{ matrix.flavor }}.ios/lib ${GITHUB_WORKSPACE}/bins/ios/cpprestsdk/; mv build.${{ matrix.flavor }}.ios/include ${GITHUB_WORKSPACE}/bins/ios/cpprestsdk/; fi + if [ -d openssl ]; then mv openssl ${GITHUB_WORKSPACE}/bins/ios/; fi + if [ -d boost.xcframework ]; then mv boost.xcframework ${GITHUB_WORKSPACE}/bins/ios/; fi + if: matrix.os == 'macos-latest' + - name: Build (Android) + timeout-minutes: 25 + run: | + set -x + export NDK_ROOT=${ANDROID_SDK_ROOT}/ndk-bundle + echo "::set-env name=NDK_ROOT::$NDK_ROOT" + mkdir -p bins/android/cpprestsdk + pushd Build_android + mkdir build + pushd build + ../configure.sh --boost 1.69.0 --openssl 1.1.0j --ndk ${NDK_ROOT} + ls -alFR . + mv ${GITHUB_WORKSPACE}/Release/include ${GITHUB_WORKSPACE}/bins/android/cpprestsdk/ || true + if [ -f build.armv7.debug/Release/Binaries/libcpprest.a ]; then mkdir -p ${GITHUB_WORKSPACE}/bins/android/cpprestsdk/libs/armeabi-v7a/Debug; mv build.armv7.debug/Release/Binaries/libcpprest.a ${GITHUB_WORKSPACE}/bins/android/cpprestsdk/libs/armeabi-v7a/Debug/; fi + if [ -f build.armv7.release/Release/Binaries/libcpprest.a ]; then mkdir -p ${GITHUB_WORKSPACE}/bins/android/cpprestsdk/libs/armeabi-v7a/Release; mv build.armv7.release/Release/Binaries/libcpprest.a ${GITHUB_WORKSPACE}/bins/android/cpprestsdk/libs/armeabi-v7a/Release/; fi + if [ -f build.x86.debug/Release/Binaries/libcpprest.a ]; then mkdir -p ${GITHUB_WORKSPACE}/bins/android/cpprestsdk/libs/x86/Debug; mv build.x86.debug/Release/Binaries/libcpprest.a ${GITHUB_WORKSPACE}/bins/android/cpprestsdk/libs/x86/Debug/; fi + if [ -f build.x86.release/Release/Binaries/libcpprest.a ]; then mkdir -p ${GITHUB_WORKSPACE}/bins/android/cpprestsdk/libs/x86/Release; mv build.x86.release/Release/Binaries/libcpprest.a ${GITHUB_WORKSPACE}/bins/android/cpprestsdk/libs/x86/Release/; fi + if [ -d openssl ]; then mv openssl ${GITHUB_WORKSPACE}/bins/android/; fi + if [ -d Boost-for-Android/build/out ]; then mv Boost-for-Android/build/out ${GITHUB_WORKSPACE}/bins/android/boost; fi + if: matrix.os == 'ubuntu-latest' + - name: Prepare Binaries + timeout-minutes: 5 + run: | + # It is about 30 times faster to zip artifacts first instead of letting + # upload artifact action send about 44K boost headers over the network. + # The artifact with binaries from both platforms takes about 345M, which + # is why we only create and upload them for tagged commits. + set -x + mkdir binaries + mkdir binaries/ios + mkdir binaries/android + if [ -d bins/android/cpprestsdk ]; then (cd bins/android && zip -r ${GITHUB_WORKSPACE}/binaries/android/cpprestsdk.zip cpprestsdk); fi + if [ -d bins/android/openssl ]; then (cd bins/android && zip -r ${GITHUB_WORKSPACE}/binaries/android/openssl.zip openssl); fi + if [ -d bins/android/boost ]; then (cd bins/android && zip -r ${GITHUB_WORKSPACE}/binaries/android/boost.zip boost); fi + if [ -d bins/ios/cpprestsdk ]; then (cd bins/ios && zip -r ${GITHUB_WORKSPACE}/binaries/ios/cpprestsdk.zip cpprestsdk); fi + if [ -d bins/ios/openssl ]; then (cd bins/ios && zip -r ${GITHUB_WORKSPACE}/binaries/ios/openssl.zip openssl); fi + if [ -d bins/ios/boost.xcframework ]; then (cd bins/ios && zip -r ${GITHUB_WORKSPACE}/binaries/ios/boost.xcframework.zip boost.xcframework); fi + ls -alFR binaries + if: contains(github.ref, 'tags') + - name: Upload Binaries + timeout-minutes: 2 + uses: actions/upload-artifact@v2 + with: + name: binaries + path: ./binaries + if: contains(github.ref, 'tags') diff --git a/Build_android/configure.sh b/Build_android/configure.sh index 59b35659ae..3e7a1ae73f 100755 --- a/Build_android/configure.sh +++ b/Build_android/configure.sh @@ -151,12 +151,11 @@ if [ "${DO_OPENSSL}" == "1" ]; then ( # ----- # Uses the build script from Moritz Wundke (formerly MysticTreeGames) # https://github.com/moritz-wundke/Boost-for-Android -# (plus the patch https://github.com/o01eg/Boost-for-Android/tree/ndk-bump-21) if [ "${DO_BOOST}" == "1" ]; then ( - if [ ! -d 'Boost-for-Android' ]; then git clone https://github.com/o01eg/Boost-for-Android/; fi + if [ ! -d 'Boost-for-Android' ]; then git clone https://github.com/moritz-wundke/Boost-for-Android; fi cd Boost-for-Android - git checkout 7626dd6f7cab7866dce20e685d4a1b11194366a7 + git checkout c439278a9e7b33b8a176c172bb573c2f665d9179 PATH="$PATH:$NDK_DIR" \ CXXFLAGS="-std=gnu++11" \ ./build-android.sh \ diff --git a/Build_iOS/.gitignore b/Build_iOS/.gitignore index 93f4744bb6..826b4d6133 100644 --- a/Build_iOS/.gitignore +++ b/Build_iOS/.gitignore @@ -1,7 +1,7 @@ # iOS folders that dependencies get stored in boostoniphone/ boost -boost.framework/ +boost.xcframework/ ios-cmake/ openssl/ OpenSSL-for-iPhone/ \ No newline at end of file diff --git a/Build_iOS/configure.sh b/Build_iOS/configure.sh index 7045be58fc..0fc6407ad1 100755 --- a/Build_iOS/configure.sh +++ b/Build_iOS/configure.sh @@ -91,18 +91,15 @@ git submodule update --init ## Build Boost -if [ ! -e $ABS_PATH/boost.framework ] && [ ! -d $ABS_PATH/boost ]; then +if [ ! -e $ABS_PATH/boost.xcframework ] && [ ! -d $ABS_PATH/boost ]; then if [ ! -d "${ABS_PATH}/Apple-Boost-BuildScript" ]; then git clone https://github.com/faithfracture/Apple-Boost-BuildScript ${ABS_PATH}/Apple-Boost-BuildScript fi pushd ${ABS_PATH}/Apple-Boost-BuildScript - git checkout 8c42427b4ebc7865eb99b0a0b9607888af2c6abc + git checkout 27ca8978bf3ee029f699356a7d044a5a1fc0cd84 BOOST_LIBS="thread chrono filesystem regex system random" ./boost.sh -ios -tvos --boost-version $BOOST_VERSION popd - mv ${ABS_PATH}/Apple-Boost-BuildScript/build/boost/${BOOST_VERSION}/ios/framework/boost.framework ${ABS_PATH} - mv ${ABS_PATH}/boost.framework/Versions/A/Headers ${ABS_PATH}/boost.headers - mkdir -p ${ABS_PATH}/boost.framework/Versions/A/Headers - mv ${ABS_PATH}/boost.headers ${ABS_PATH}/boost.framework/Versions/A/Headers/boost + mv ${ABS_PATH}/Apple-Boost-BuildScript/dist/boost.xcframework ${ABS_PATH} fi ## Build OpenSSL diff --git a/README.md b/README.md index a1f46ab4fb..222fd9b29e 100644 --- a/README.md +++ b/README.md @@ -11,7 +11,8 @@ The C++ REST SDK is a Microsoft project for cloud-based client-server communicat [![openSUSE Tumbleweed package](https://repology.org/badge/version-for-repo/opensuse_tumbleweed/cpprestsdk.svg)](https://repology.org/metapackage/cpprestsdk)
[![Debian Testing package](https://repology.org/badge/version-for-repo/debian_testing/cpprestsdk.svg)](https://repology.org/metapackage/cpprestsdk)
-[![Build Status](https://dev.azure.com/vclibs/cpprestsdk/_apis/build/status/Microsoft.cpprestsdk.Ubuntu)](https://dev.azure.com/vclibs/cpprestsdk/_build/latest?definitionId=1) +[![Build Status](https://dev.azure.com/vclibs/cpprestsdk/_apis/build/status/Microsoft.cpprestsdk.Ubuntu)](https://dev.azure.com/vclibs/cpprestsdk/_build/latest?definitionId=1)
+[![Build Status: Mobile](https://github.com/microsoft/cpprestsdk/workflows/Mobile/badge.svg)](https://github.com/microsoft/cpprestsdk/actions) With [vcpkg](https://github.com/Microsoft/vcpkg) on Windows ``` diff --git a/Release/CMakeLists.txt b/Release/CMakeLists.txt index 13a3f01db8..cf4eadd655 100644 --- a/Release/CMakeLists.txt +++ b/Release/CMakeLists.txt @@ -15,9 +15,21 @@ set(CPPREST_VERSION_REVISION 16) enable_testing() -set(WERROR ON CACHE BOOL "Treat Warnings as Errors.") +if(IOS) + # We disable warnings as errors on iOS because of command-line warning: + # clang: warning: overriding '-mios-simulator-version-min=8.0' option with '--target=arm64-apple-ios13.5' [-Woverriding-t-option] + # which for some reason can't be disabled from cmake the usual way. + set(WERROR OFF CACHE BOOL "Treat Warnings as Errors.") + # We exclude compression on iOS for now because of the problem I described + # in greater details in this StackOverflow post: + # https://stackoverflow.com/questions/58628377/catalina-c-using-cmath-headers-yield-error-no-member-named-signbit-in-th/59780819#59780819 + set(CPPREST_EXCLUDE_COMPRESSION ON CACHE BOOL "Exclude compression functionality.") +else() + set(WERROR ON CACHE BOOL "Treat Warnings as Errors.") + set(CPPREST_EXCLUDE_COMPRESSION OFF CACHE BOOL "Exclude compression functionality.") +endif() + set(CPPREST_EXCLUDE_WEBSOCKETS OFF CACHE BOOL "Exclude websockets functionality.") -set(CPPREST_EXCLUDE_COMPRESSION OFF CACHE BOOL "Exclude compression functionality.") set(CPPREST_EXCLUDE_BROTLI ON CACHE BOOL "Exclude Brotli compression functionality.") set(CPPREST_EXPORT_DIR cmake/cpprestsdk CACHE STRING "Directory to install CMake config files.") set(CPPREST_INSTALL_HEADERS ON CACHE BOOL "Install header files.") diff --git a/Release/cmake/cpprest_find_boost.cmake b/Release/cmake/cpprest_find_boost.cmake index 3c857bafa0..9c356f51a9 100644 --- a/Release/cmake/cpprest_find_boost.cmake +++ b/Release/cmake/cpprest_find_boost.cmake @@ -30,8 +30,8 @@ function(cpprest_find_boost) set(Boost_INCLUDE_DIR "${IOS_SOURCE_DIR}/boost/include" CACHE INTERNAL "") else() set(IOS_SOURCE_DIR "${PROJECT_SOURCE_DIR}/../Build_iOS") - set(Boost_LIBRARIES "${IOS_SOURCE_DIR}/boost.framework/boost" CACHE INTERNAL "") - set(Boost_INCLUDE_DIR "${IOS_SOURCE_DIR}/boost.framework/Headers" CACHE INTERNAL "") + set(Boost_LIBRARIES "${IOS_SOURCE_DIR}/boost.xcframework/boost" CACHE INTERNAL "") + set(Boost_INCLUDE_DIR "${IOS_SOURCE_DIR}/boost.xcframework/Headers" CACHE INTERNAL "") endif() elseif(ANDROID) set(Boost_COMPILER "-clang")