From 35cd11f5ed2020078904c6efb2866180246514dc Mon Sep 17 00:00:00 2001 From: Kevin Gozali Date: Tue, 27 Oct 2020 16:10:18 -0700 Subject: [PATCH] Android CI: set up NDK via local.properties (#30259) Summary: Pull Request resolved: https://github.com/facebook/react-native/pull/30259 Before side-by-side NDK is supported by the Circle CI image, pending https://github.com/facebook/react-native/pull/29050 & https://github.com/facebook/react-native/pull/29987, this local.properties file forces Gradle to use the specified SDK/NDK path. We do this internally at FB CI as well. This addresses the following failure: https://app.circleci.com/pipelines/github/facebook/react-native/6851/workflows/9fd91d5d-3f05-4521-93fc-95abd5c84227/jobs/173735 Also, this fixed bad src copy for Buck-building: `//packages/react-native-codegen:setup_cli` Changelog: [Internal] Reviewed By: hramos Differential Revision: D24577333 fbshipit-source-id: 93f11c3e3a3f699415739d0760ee10909eb748ed --- packages/react-native-codegen/DEFS.bzl | 2 +- scripts/validate-android-test-env.sh | 13 +++++++++++++ 2 files changed, 14 insertions(+), 1 deletion(-) diff --git a/packages/react-native-codegen/DEFS.bzl b/packages/react-native-codegen/DEFS.bzl index 7f52f314861930..606db2c3eb86fd 100644 --- a/packages/react-native-codegen/DEFS.bzl +++ b/packages/react-native-codegen/DEFS.bzl @@ -77,7 +77,7 @@ def rn_codegen_cli(): bash = r""" set -euo pipefail mkdir -p "$OUT" - cp -r "$SRCDIR/." "$OUT/" + rsync -rLptgoD "$SRCDIR/" "$OUT" cd "$OUT" yarn install 2> >(grep -v '^warning' 1>&2) yarn run build diff --git a/scripts/validate-android-test-env.sh b/scripts/validate-android-test-env.sh index 5f6be9956cba97..121c832128de96 100755 --- a/scripts/validate-android-test-env.sh +++ b/scripts/validate-android-test-env.sh @@ -11,6 +11,8 @@ # the android sdk that is actually installed. Also, we must have the # right version of Java. +THIS_DIR=$(cd -P "$(dirname "$(readlink "${BASH_SOURCE[0]}" || echo "${BASH_SOURCE[0]}")")" && pwd) + # Check that Buck is working. if [ -z "$(which buck)" ]; then echo "You need to install Buck." @@ -115,3 +117,14 @@ if [ -z "$JAVA_HOME" ]; then echo "You will also want to add \$JAVA_HOME/bin to your path." exit 1 fi + +# Assuming Android SDK/NDK has been set up, set up `local.properties` file +# to force Gradle to use the provided versions. This is necessary before +# the side-by-side NDK installation is supported for Circle CI runs. +LOCAL_PROPERTIES="$THIS_DIR/../local.properties" +if [ ! -f "$LOCAL_PROPERTIES" ]; then + echo "Setting up local.properties for NDK builds." + touch "$LOCAL_PROPERTIES" + echo "sdk.dir=$ANDROID_HOME" >> "$LOCAL_PROPERTIES" + echo "ndk.dir=$ANDROID_NDK" >> "$LOCAL_PROPERTIES" +fi