aboutsummaryrefslogtreecommitdiffhomepage
diff options
context:
space:
mode:
-rwxr-xr-xcompile.sh3
-rwxr-xr-xscripts/bootstrap/buildenv.sh6
-rwxr-xr-xscripts/ci/build.sh34
-rwxr-xr-xsrc/test/shell/bazel/test-setup.sh12
4 files changed, 50 insertions, 5 deletions
diff --git a/compile.sh b/compile.sh
index 3f7a27d4f6..a5598ef20c 100755
--- a/compile.sh
+++ b/compile.sh
@@ -162,7 +162,8 @@ if [ $DO_TESTS ]; then
new_step "Running tests"
display "."
- if grep -sq '^ *actual = "//:dummy"' WORKSPACE; then
+ if [ "$(get_bind_target //external:android_ndk_repository)" = "//:dummy"
+ -o "$(get_bind_target //external:android_sdk_repository)" = "//:dummy" ]; then
display "$WARNING Android SDK or NDK are not set in the WORKSPACE file. Android tests will not be run."
fi
diff --git a/scripts/bootstrap/buildenv.sh b/scripts/bootstrap/buildenv.sh
index ab4dbeaaa7..be2cfa1db1 100755
--- a/scripts/bootstrap/buildenv.sh
+++ b/scripts/bootstrap/buildenv.sh
@@ -134,3 +134,9 @@ function get_java_version() {
fail "Cannot determine JDK version, please set \$JAVA_HOME."
fi
}
+
+# Return the target that a bind point to, using Bazel query.
+function get_bind_target() {
+ $BAZEL --bazelrc=${BAZELRC} --nomaster_bazelrc test \
+ query "deps($1, 1) - $1"
+}
diff --git a/scripts/ci/build.sh b/scripts/ci/build.sh
index 282fd55cd8..45d930813f 100755
--- a/scripts/ci/build.sh
+++ b/scripts/ci/build.sh
@@ -63,6 +63,39 @@ function get_full_release_name() {
fi
}
+function setup_android_repositories() {
+ if [ ! -f WORKSPACE.bak ] && [ -n "${ANDROID_SDK_PATH-}" ]; then
+ cp WORKSPACE WORKSPACE.bak
+ trap '[ -f WORKSPACE.bak ] && rm WORKSPACE && mv WORKSPACE.bak WORKSPACE' \
+ EXIT
+ cat >>WORKSPACE <<EOF
+new_local_repository(
+ name = "globbed_android_sdk",
+ path = "${ANDROID_SDK_PATH}",
+ build_file = "BUILD.glob",
+)
+
+bind(
+ name = "android_sdk_for_testing",
+ actual = "@globbed_android_sdk//:all",
+)
+EOF
+ if [ -n "${ANDROID_NDK_PATH-}" ]; then
+ cat >>WORKSPACE <<EOF
+new_local_repository(
+ name = "globbed_android_ndk",
+ path = "${ANDROID_NDK_PATH}",
+ build_file = "BUILD.glob",
+)
+
+bind(
+ name = "android_ndk_for_testing",
+ actual = "@globbed_android_ndk//:all",
+)
+EOF
+ fi
+ fi
+}
# Main entry point for building bazel.
# It sets the embed label to the release name if any, calls the whole
# test suite, compile the various packages, then copy the artifacts
@@ -70,6 +103,7 @@ function get_full_release_name() {
function bazel_build() {
local release_label="$(get_full_release_name)"
local embed_label_opts=
+ setup_android_repositories
if [ -n "${release_label}" ]; then
export EMBED_LABEL="${release_label}"
fi
diff --git a/src/test/shell/bazel/test-setup.sh b/src/test/shell/bazel/test-setup.sh
index 0c74c06682..5664986493 100755
--- a/src/test/shell/bazel/test-setup.sh
+++ b/src/test/shell/bazel/test-setup.sh
@@ -206,23 +206,27 @@ EOF
fi
done
+
+ local ANDROID_SDK_API_LEVEL=$(ls $SDK_SRCDIR/platforms | cut -d '-' -f 2 | sort -n | tail -1)
+ local ANDROID_NDK_API_LEVEL=$(ls $NDK_SRCDIR/platforms | cut -d '-' -f 2 | sort -n | tail -1)
+ local ANDROID_SDK_TOOLS_VERSION=$(ls $SDK_SRCDIR/build-tools | sort -n | tail -1)
cat >> WORKSPACE <<EOF
android_ndk_repository(
name = "androidndk",
path = "$ANDROID_NDK",
- api_level = 19
+ api_level = $ANDROID_NDK_API_LEVEL,
)
android_sdk_repository(
name = "androidsdk",
path = "$ANDROID_SDK",
- build_tools_version = "21.1.1",
- api_level = 19
+ build_tools_version = "$ANDROID_SDK_TOOLS_VERSION",
+ api_level = $ANDROID_SDK_API_LEVEL,
)
android_local_tools_repository(
name = "androidtools",
- path = "$ANDROID_TOOLS"
+ path = "$ANDROID_TOOLS",
)
EOF
}