Skip to content
This repository has been archived by the owner on Dec 13, 2018. It is now read-only.

Commit

Permalink
Try to re-relativize this stuff
Browse files Browse the repository at this point in the history
  • Loading branch information
srawlins committed Oct 13, 2016
1 parent c625a99 commit 2752fe6
Showing 1 changed file with 5 additions and 7 deletions.
12 changes: 5 additions & 7 deletions dart/build_rules/internal.bzl
Original file line number Diff line number Diff line change
Expand Up @@ -126,6 +126,8 @@ def make_dart_context(label,
if not lib_root:
if label.workspace_root.startswith("external/"):
lib_root = "%s/lib/" % label.workspace_root[len("external/"):]
elif not label.package:
lib_root = "lib/"
else:
lib_root = "%s/lib/" % label.package

Expand Down Expand Up @@ -206,13 +208,7 @@ def package_spec_action(ctx, dart_ctx, output):
content = "# Generated by Bazel\n"
for dc in dart_ctxs:
relative_lib_root = _relative_path(dart_ctx.label.package, dc.lib_root)
if dc.label.workspace_root.startswith("external/"):
content += "%s:%s\n" % (dc.package, dc.lib_root)
else:
if dc.lib_root == '/lib/':
content += "%s:lib/\n" % (dc.package)
else:
content += "%s:%s\n" % (dc.package, relative_lib_root)
content += "%s:%s\n" % (dc.package, relative_lib_root)

# Emit the package spec.
ctx.file_action(
Expand All @@ -223,6 +219,8 @@ def package_spec_action(ctx, dart_ctx, output):

def _relative_path(from_dir, to_path):
"""Returns the relative path from a directory to a path via the repo root."""
if not from_dir:
return to_path
return "../" * (from_dir.count("/") + 1) + to_path


Expand Down

0 comments on commit 2752fe6

Please sign in to comment.