Skip to content

Commit

Permalink
Make Android rules/tests refer to the correct runfiles paths
Browse files Browse the repository at this point in the history
Fixes the android part of bazelbuild#1316.

--
MOS_MIGRATED_REVID=123644129
  • Loading branch information
kchodorow committed May 31, 2016
1 parent a8efe48 commit dc54452
Show file tree
Hide file tree
Showing 5 changed files with 7 additions and 12 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -86,7 +86,6 @@ public SkyValue fetch(
String template = getStringResource("android_sdk_repository_template.txt");

String buildFile = template
.replaceAll("%workspace_name%", rule.getWorkspaceName())
.replaceAll("%repository_name%", rule.getName())
.replaceAll("%build_tools_version%", buildToolsVersion)
.replaceAll("%build_tools_directory%", buildToolsDirectory)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,5 +7,4 @@ create_android_sdk_rules(
build_tools_version = "%build_tools_version%",
build_tools_directory = "%build_tools_directory%",
api_level = %api_level%,
workspace_name = "%workspace_name%",
)
6 changes: 3 additions & 3 deletions src/test/shell/bazel/android/android_integration_test.sh
Original file line number Diff line number Diff line change
Expand Up @@ -205,15 +205,15 @@ function test_android_binary_clang() {
}

# ndk r10 and earlier
if [[ ! -r "${BAZEL_RUNFILES}/external/androidndk/ndk/RELEASE.TXT" ]]; then
if [[ ! -r "${TEST_SRCDIR}/androidndk/ndk/RELEASE.TXT" ]]; then
# ndk r11 and later
if [[ ! -r "${BAZEL_RUNFILES}/external/androidndk/ndk/source.properties" ]]; then
if [[ ! -r "${TEST_SRCDIR}/androidndk/ndk/source.properties" ]]; then
echo "Not running Android tests due to lack of an Android NDK."
exit 0
fi
fi

if [[ ! -r "${BAZEL_RUNFILES}/external/androidsdk/SDK Readme.txt" ]]; then
if [[ ! -r "${TEST_SRCDIR}/androidsdk/SDK Readme.txt" ]]; then
echo "Not running Android tests due to lack of an Android SDK."
exit 0
fi
Expand Down
4 changes: 2 additions & 2 deletions src/test/shell/bazel/test-setup.sh
Original file line number Diff line number Diff line change
Expand Up @@ -66,8 +66,8 @@ function setup_android_support() {
# TODO(bazel-team): This hard-codes the name of the Android repository in
# the WORKSPACE file of Bazel. Change this once external repositories have
# their own defined names under which they are mounted.
NDK_SRCDIR=$BAZEL_RUNFILES/external/androidndk/ndk
SDK_SRCDIR=$BAZEL_RUNFILES/external/androidsdk
NDK_SRCDIR=$TEST_SRCDIR/androidndk/ndk
SDK_SRCDIR=$TEST_SRCDIR/androidsdk

mkdir -p $ANDROID_NDK
mkdir -p $ANDROID_SDK
Expand Down
7 changes: 2 additions & 5 deletions tools/android/android_sdk_repository_template.bzl
Original file line number Diff line number Diff line change
Expand Up @@ -17,8 +17,7 @@ def create_android_sdk_rules(
name,
build_tools_version,
build_tools_directory,
api_level,
workspace_name):
api_level):
"""Generate the contents of the android_sdk_repository.
Args:
Expand All @@ -27,7 +26,6 @@ def create_android_sdk_rules(
build_tools_directory: string, the directory name of the build tools in
sdk's build-tools directory.
api_level: int, the API level from which to get android.jar et al.
workspace_name: string, the local workspace's name.
"""

native.filegroup(
Expand Down Expand Up @@ -196,8 +194,7 @@ def create_android_sdk_rules(
"#!/bin/bash -eu",
# The tools under build-tools/VERSION require the libraries under build-tools/VERSION/lib,
# so we can't simply depend on them as a file like we do with aapt.
# TODO(kchodorow): change this to SDK=$${0}.runfiles/%s once runfiles are restructured.
"SDK=$${0}.runfiles/%s/external/%s" % (workspace_name, name),
"SDK=$${0}.runfiles/%s" % name,
"exec $${SDK}/build-tools/%s/%s $$*" % (build_tools_directory, tool),
"EOF\n"]),
) for tool in ["aapt", "aidl", "zipalign"]]
Expand Down

0 comments on commit dc54452

Please sign in to comment.