diff options
author | 2015-12-04 16:59:07 +0000 | |
---|---|---|
committer | 2015-12-04 21:06:51 +0000 | |
commit | 0e222581e674b0f7c186c4bc40be2af680e94643 (patch) | |
tree | 5ad198afcd208cdd841b65825e0cca7654fdc699 /tools/build_defs/docker/docker.bzl | |
parent | df4194f47f2e1777301071b48dedf9a80b2264b8 (diff) |
docker_build: Properly handle / as data_path
The handling in _compute_data_path would incorrectly result in an empty
strip_prefix being passed to _dest_path. The outcome was all files would
end up at the top of directory, instead of nested according to the
repository structure.
This change brings the behavior in line with the documentation, which
states:
> This path can be absolute from the workspace root if starting with a
> `/` or relative to the rule's directory.
Fixes https://github.com/bazelbuild/bazel/issues/677
--
Change-Id: Ifdab97ed0e851cf6cabc7bd3206343766861b725
Reviewed-on: https://bazel-review.googlesource.com/#/c/2480
MOS_MIGRATED_REVID=109418486
Diffstat (limited to 'tools/build_defs/docker/docker.bzl')
-rw-r--r-- | tools/build_defs/docker/docker.bzl | 5 |
1 files changed, 4 insertions, 1 deletions
diff --git a/tools/build_defs/docker/docker.bzl b/tools/build_defs/docker/docker.bzl index 9b1cc31da9..395f0277d0 100644 --- a/tools/build_defs/docker/docker.bzl +++ b/tools/build_defs/docker/docker.bzl @@ -71,7 +71,10 @@ def _compute_data_path(out, data_path): # Strip ./ from the beginning if specified. # There is no way to handle .// correctly (no function that would make # that possible and Skylark is not turing complete) so just consider it - # as an absolute path. + # as an absolute path. A data_path of / should preserve the entire + # path up to the repository root. + if data_path == "/": + return data_path if len(data_path) >= 2 and data_path[0:2] == "./": data_path = data_path[2:] if not data_path or data_path == ".": # Relative to current package |