Skip to content

Commit

Permalink
Fix CI build for Android (#2836)
Browse files Browse the repository at this point in the history
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: #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
  • Loading branch information
passy authored and facebook-github-bot committed Sep 9, 2021
1 parent 9f7b788 commit da9511a
Show file tree
Hide file tree
Showing 9 changed files with 14 additions and 20 deletions.
2 changes: 1 addition & 1 deletion .circleci/config.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand Down
2 changes: 0 additions & 2 deletions .github/workflows/android-sample.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
2 changes: 0 additions & 2 deletions .github/workflows/publish-android.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
2 changes: 0 additions & 2 deletions .github/workflows/react-native-example.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
16 changes: 8 additions & 8 deletions android/third-party/native.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -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")
Expand Down Expand Up @@ -195,15 +195,15 @@ 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))
}

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))
Expand All @@ -214,25 +214,25 @@ 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/"
}

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) {
Expand Down
2 changes: 1 addition & 1 deletion android/third-party/overrides/Folly/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -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/)

Expand Down
2 changes: 1 addition & 1 deletion android/third-party/overrides/RSocket/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
4 changes: 2 additions & 2 deletions build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down Expand Up @@ -49,7 +49,7 @@ ext {
targetSdkVersion = 30
compileSdkVersion = 30
buildToolsVersion = '30.0.2'
ndkVersion = '21.3.6528147'
ndkVersion = '23.0.7599858'
}

ext.deps = [
Expand Down
2 changes: 1 addition & 1 deletion xplat/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down

0 comments on commit da9511a

Please sign in to comment.