Skip to content

Commit

Permalink
Add the workspace name to the SDK path
Browse files Browse the repository at this point in the history
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 bazelbuild#848.

--
MOS_MIGRATED_REVID=120705755
  • Loading branch information
kchodorow authored and meteorcloudy committed Apr 25, 2016
1 parent 2c4289e commit 6ba22c0
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,7 @@ 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("%api_level%", apiLevel.toString());
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,4 +6,5 @@ create_android_sdk_rules(
name = "%repository_name%",
build_tools_version = "%build_tools_version%",
api_level = %api_level%,
workspace_name = "%workspace_name%",
)
6 changes: 4 additions & 2 deletions tools/android/android_sdk_repository_template.bzl
Original file line number Diff line number Diff line change
Expand Up @@ -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(
Expand Down Expand Up @@ -189,7 +190,8 @@ def create_android_sdk_rules(name, build_tools_version, api_level):
"#!/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"]]
Expand Down

0 comments on commit 6ba22c0

Please sign in to comment.