From da9511a5bfaaa253d8d9576b06af511ed287d04f Mon Sep 17 00:00:00 2001 From: Pascal Hartig Date: Thu, 9 Sep 2021 08:45:50 -0700 Subject: [PATCH] Fix CI build for Android (#2836) Summary: I've been really sweating about this one. It looks like Google now removed NDK 21 as it's too old. However, we've been struggling with the upgrade because OpenSSL was built against an old version of the NDK/glibc/LLVM/some other stuff. I've now managed to create an OpenSSL distribution for 1.1.1k (we had 1.1.0h before) that seems to build with this after some small modifications. This seems to do the trick, but I wouldn't be shocked if we found some more incompatibilities further down the line. Pull Request resolved: https://github.com/facebook/flipper/pull/2836 Test Plan: - Locally: `./gradlew :tutorial:installDebug`. Builds, starts up. Cool. - Public GitHub CI: Happy. - Circle CI: Only triggers post-land. We'll see. But the setup is simple, so hopefully it should work there, too. - Internal CI: Waiting for signal. Reviewed By: fabiomassimo Differential Revision: D30839209 Pulled By: passy fbshipit-source-id: efe599f28cc0edfdf2149f905c3483555239edc0 --- .circleci/config.yml | 2 +- .github/workflows/android-sample.yml | 2 -- .github/workflows/publish-android.yml | 2 -- .github/workflows/react-native-example.yml | 2 -- android/third-party/native.gradle | 16 ++++++++-------- .../third-party/overrides/Folly/CMakeLists.txt | 2 +- .../third-party/overrides/RSocket/CMakeLists.txt | 2 +- build.gradle | 4 ++-- xplat/CMakeLists.txt | 2 +- 9 files changed, 14 insertions(+), 20 deletions(-) diff --git a/.circleci/config.yml b/.circleci/config.yml index e559a7cef..3c2169bbe 100644 --- a/.circleci/config.yml +++ b/.circleci/config.yml @@ -2,7 +2,7 @@ version: 2.1 executors: default-executor: docker: - - image: circleci/android:api-29-ndk + - image: circleci/android:api-30-ndk resource_class: large environment: diff --git a/.github/workflows/android-sample.yml b/.github/workflows/android-sample.yml index 017f3c5d1..63e924837 100644 --- a/.github/workflows/android-sample.yml +++ b/.github/workflows/android-sample.yml @@ -13,8 +13,6 @@ jobs: uses: actions/setup-java@v1 with: java-version: 1.8 - - name: Install NDK 21 - run: echo "y" | sudo /usr/local/lib/android/sdk/tools/bin/sdkmanager --install "ndk;21.0.6113669" "ndk;20.0.5594570" --sdk_root=${ANDROID_SDK_ROOT} - name: Compute build cache run: ./scripts/checksum-android.sh checksum-android.txt - uses: actions/cache@v2 diff --git a/.github/workflows/publish-android.yml b/.github/workflows/publish-android.yml index 9a8bbf42a..dc6bcd245 100644 --- a/.github/workflows/publish-android.yml +++ b/.github/workflows/publish-android.yml @@ -22,8 +22,6 @@ jobs: uses: actions/setup-java@v1 with: java-version: 1.8 - - name: Install NDK 20, 21 - run: echo "y" | sudo /usr/local/lib/android/sdk/tools/bin/sdkmanager --install "ndk;21.0.6113669" "ndk;20.0.5594570" --sdk_root=${ANDROID_SDK_ROOT} - name: Write GPG Sec Ring run: echo '${{ secrets.GPG_KEY_CONTENTS }}' | base64 -d > /tmp/secring.gpg - name: Update gradle.properties diff --git a/.github/workflows/react-native-example.yml b/.github/workflows/react-native-example.yml index 7df5bcb19..a96353710 100644 --- a/.github/workflows/react-native-example.yml +++ b/.github/workflows/react-native-example.yml @@ -42,8 +42,6 @@ jobs: uses: actions/setup-java@v1 with: java-version: 1.8 - - name: Install NDK 21 - run: echo "y" | sudo /usr/local/lib/android/sdk/tools/bin/sdkmanager --install "ndk;21.0.6113669" "ndk;20.0.5594570" --sdk_root=${ANDROID_SDK_ROOT} - name: Compute build cache run: ${GITHUB_WORKSPACE}/scripts/checksum-android.sh checksum-android.txt - uses: actions/cache@v2 diff --git a/android/third-party/native.gradle b/android/third-party/native.gradle index 464a06146..4bafb1eac 100644 --- a/android/third-party/native.gradle +++ b/android/third-party/native.gradle @@ -11,7 +11,7 @@ import org.apache.tools.ant.filters.ReplaceTokens // Increment this when making changes to any of the native // dependencies. // !!! -final def CACHE_REVISION = 30 +final def CACHE_REVISION = 31 final def externalDir = new File("$projectDir/external") final def downloadsDir = new File("$externalDir/downloads") @@ -195,7 +195,7 @@ task finalizeLibEvent(dependsOn: [prepareLibEvent2], type: Copy) { task downloadOpenSSLSource(dependsOn: [], type: Download) { onlyIf { isCacheOutOfDate(CACHE_REVISION) } - src 'https://github.com/passy/openssl-android/releases/download/1.1.0h/openssl-1.1.0h.tar.gz' + src 'https://github.com/passy/openssl-android/releases/download/1.1.1k/openssl-1.1.1k.tar.gz' onlyIfNewer true overwrite false dest new File(downloadsDir, getDownloadFileName(src)) @@ -203,7 +203,7 @@ task downloadOpenSSLSource(dependsOn: [], type: Download) { task downloadOpenSSLLibs(dependsOn: [], type: Download) { onlyIf { isCacheOutOfDate(CACHE_REVISION) } - src 'https://github.com/passy/openssl-android/releases/download/1.1.0h-r2/openssl-1.1.0h-r2-prebuilt.tar.gz' + src 'https://github.com/passy/openssl-android/releases/download/1.1.1k/openssl-1.1.1k-prebuilt.tar.gz' onlyIfNewer true overwrite false dest new File(downloadsDir, getDownloadFileName(src)) @@ -214,7 +214,7 @@ task prepareOpenSSL(dependsOn: [downloadOpenSSLSource, downloadOpenSSLLibs], typ from tarTree(downloadOpenSSLSource.dest) from tarTree(downloadOpenSSLLibs.dest) from './overrides/OpenSSL/' - include 'openssl-1.1.0h/**/*' + include 'openssl-1.1.1k/**/*' include 'libs/**/*' includeEmptyDirs = false into "$externalDir/OpenSSL/" @@ -222,17 +222,17 @@ task prepareOpenSSL(dependsOn: [downloadOpenSSLSource, downloadOpenSSLLibs], typ task configureOpenSSL(dependsOn: [prepareOpenSSL], type: Exec) { onlyIf { isCacheOutOfDate(CACHE_REVISION) } - workingDir "$externalDir/OpenSSL/openssl-1.1.0h/" + workingDir "$externalDir/OpenSSL/openssl-1.1.1k/" // This is only to generate a buildconfig.h in the next step. I **believe** // that the options here don't really matter for that file. - commandLine './Configure', 'dist' + commandLine './Configure', 'linux-generic64' } task finalizeOpenSSL(dependsOn: [configureOpenSSL], type: Exec) { onlyIf { isCacheOutOfDate(CACHE_REVISION) } - workingDir "$externalDir/OpenSSL/openssl-1.1.0h/" + workingDir "$externalDir/OpenSSL/openssl-1.1.1k/" commandLine 'make', 'build_generated' - onlyIf { !file("$externalDir/OpenSSL/openssl-1.1.0h/include/openssl/opensslconf.h").exists() } + onlyIf { !file("$externalDir/OpenSSL/openssl-1.1.1k/include/openssl/opensslconf.h").exists() } } task downloadRSocket(dependsOn: [], type: Download) { diff --git a/android/third-party/overrides/Folly/CMakeLists.txt b/android/third-party/overrides/Folly/CMakeLists.txt index c900b2a63..cc1c5a3b4 100644 --- a/android/third-party/overrides/Folly/CMakeLists.txt +++ b/android/third-party/overrides/Folly/CMakeLists.txt @@ -16,7 +16,7 @@ list(APPEND dir_list ${FOLLY_DIR}/memory/detail) set(BOOST_DIR ../boost/boost_1_63_0/) set(GLOG_DIR ../glog/) -set(OPENSSL_DIR ../OpenSSL/openssl-1.1.0h/) +set(OPENSSL_DIR ../OpenSSL/openssl-1.1.1k/) set(LIBEVENT_DIR ../LibEvent/libevent-2.1.11-stable/) set(DOUBLECONVERSION_DIR ../double-conversion/double-conversion-3.0.0/) diff --git a/android/third-party/overrides/RSocket/CMakeLists.txt b/android/third-party/overrides/RSocket/CMakeLists.txt index 8ccb3b6bf..7963ce6ca 100644 --- a/android/third-party/overrides/RSocket/CMakeLists.txt +++ b/android/third-party/overrides/RSocket/CMakeLists.txt @@ -12,7 +12,7 @@ set(glog_DIR ${third_party_ndk}/glog) set(BOOST_DIR ${third_party_ndk}/boost/boost_1_63_0/) set(LIBEVENT_DIR ${third_party_ndk}/LibEvent/libevent-2.1.11-stable/) set(DOUBLECONVERSION_DIR ${third_party_ndk}/double-conversion/double-conversion-3.0.0/) -set(OPENSSL_DIR ${third_party_ndk}/OpenSSL/openssl-1.1.0h/) +set(OPENSSL_DIR ${third_party_ndk}/OpenSSL/openssl-1.1.1k/) set(RSOCKET_ROOT_DIR ${PROJECT_SOURCE_DIR}/rsocket-cpp-${RSOCKET_VERSION}) set(RSOCKET_DIR ${PROJECT_SOURCE_DIR}/rsocket-cpp-${RSOCKET_VERSION}/rsocket) diff --git a/build.gradle b/build.gradle index 36c0b4959..c153679e7 100644 --- a/build.gradle +++ b/build.gradle @@ -11,7 +11,7 @@ buildscript { mavenCentral() } dependencies { - classpath 'com.android.tools.build:gradle:4.2.1' + classpath 'com.android.tools.build:gradle:4.2.2' classpath 'com.vanniktech:gradle-maven-publish-plugin:0.17.0' classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$KOTLIN_VERSION" classpath "org.jetbrains.dokka:dokka-gradle-plugin:1.5.0" @@ -49,7 +49,7 @@ ext { targetSdkVersion = 30 compileSdkVersion = 30 buildToolsVersion = '30.0.2' - ndkVersion = '21.3.6528147' + ndkVersion = '23.0.7599858' } ext.deps = [ diff --git a/xplat/CMakeLists.txt b/xplat/CMakeLists.txt index fdee35bdc..806a864ac 100644 --- a/xplat/CMakeLists.txt +++ b/xplat/CMakeLists.txt @@ -17,7 +17,7 @@ set(glog_DIR ${external_DIR}/glog) set(BOOST_DIR ${external_DIR}/boost/boost_1_63_0/) set(LIBEVENT_DIR ${external_DIR}/LibEvent/libevent-2.1.11-stable/) set(DOUBLECONVERSION_DIR ${external_DIR}/double-conversion/double-conversion-3.0.0/) -set(OPENSSL_DIR ${external_DIR}/OpenSSL/openssl-1.1.0h/) +set(OPENSSL_DIR ${external_DIR}/OpenSSL/openssl-1.1.1k/) list(APPEND dir_list ./) list(APPEND dir_list ./Flipper)