Add the workspace name to the SDK path This makes the android rules work if the workspace name is set. See https://github.com/bazelbuild/bazel/wiki/Updating-the-runfiles-tree-structure for more details. This is required for rolling forward https://github.com/bazelbuild/bazel/issues/848. -- MOS_MIGRATED_REVID=120705755
diff --git a/src/main/java/com/google/devtools/build/lib/bazel/rules/android/AndroidSdkRepositoryFunction.java b/src/main/java/com/google/devtools/build/lib/bazel/rules/android/AndroidSdkRepositoryFunction.java index c729dd1..9882e01 100644 --- a/src/main/java/com/google/devtools/build/lib/bazel/rules/android/AndroidSdkRepositoryFunction.java +++ b/src/main/java/com/google/devtools/build/lib/bazel/rules/android/AndroidSdkRepositoryFunction.java
@@ -58,6 +58,7 @@ 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("%api_level%", apiLevel.toString());
diff --git a/src/main/java/com/google/devtools/build/lib/bazel/rules/android/android_sdk_repository_template.txt b/src/main/java/com/google/devtools/build/lib/bazel/rules/android/android_sdk_repository_template.txt index f277a06..b13b413 100644 --- a/src/main/java/com/google/devtools/build/lib/bazel/rules/android/android_sdk_repository_template.txt +++ b/src/main/java/com/google/devtools/build/lib/bazel/rules/android/android_sdk_repository_template.txt
@@ -6,4 +6,5 @@ name = "%repository_name%", build_tools_version = "%build_tools_version%", api_level = %api_level%, + workspace_name = "%workspace_name%", )
diff --git a/tools/android/android_sdk_repository_template.bzl b/tools/android/android_sdk_repository_template.bzl index ee7cda8..f7fbe26 100644 --- a/tools/android/android_sdk_repository_template.bzl +++ b/tools/android/android_sdk_repository_template.bzl
@@ -13,13 +13,14 @@ # See the License for the specific language governing permissions and # limitations under the License. -def create_android_sdk_rules(name, build_tools_version, api_level): +def create_android_sdk_rules(name, build_tools_version, api_level, workspace_name): """Generate the contents of the android_sdk_repository. Args: name: string, the name of the repository being generated. build_tools: string, the version of Android's build tools to work with. api_level: int, the API level from which to get android.jar et al. + workspace_name: string, the local workspace's name. """ native.filegroup( @@ -189,7 +190,8 @@ "#!/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. - "SDK=$${0}.runfiles/external/%s" % name, + # TODO(kchodorow): change this to SDK=$${0}.runfiles/%s once runfiles are restructured. + "SDK=$${0}.runfiles/%s/external/%s" % (workspace_name, name), "exec $${SDK}/build-tools/%s/%s $$*" % (build_tools_version, tool), "EOF\n"]), ) for tool in ["aapt", "aidl", "zipalign"]]