diff options
author | Damien Martin-Guillerez <dmarting@google.com> | 2016-01-15 14:01:37 +0100 |
---|---|---|
committer | Damien Martin-Guillerez <dmarting@google.com> | 2016-01-15 23:12:09 +0100 |
commit | 76547e5190845eab44a40e171e4686c07ea9df2e (patch) | |
tree | 204de1328cce953773e4f065bd3e46dd9e1b3626 | |
parent | b6ef4015d7eccc6f63dab3dc46e76f9f9f2217ab (diff) | |
download | protobuf-76547e5190845eab44a40e171e4686c07ea9df2e.tar.gz protobuf-76547e5190845eab44a40e171e4686c07ea9df2e.tar.bz2 protobuf-76547e5190845eab44a40e171e4686c07ea9df2e.zip |
Make protobuf Skylark extension appends the workspace root
This change make protobuf skylark extension works when using
remote repository.
Note that this make the Skylark extension unusable prior
to Bazel 0.1.4 because the workspace_root is not available
on prior version.
Tested with Bazel 0.1.4rc2.
Fixes https://github.com/bazelbuild/bazel/issues/784.
-rw-r--r-- | protobuf.bzl | 16 |
1 files changed, 10 insertions, 6 deletions
diff --git a/protobuf.bzl b/protobuf.bzl index bf748db6..f674a6c6 100644 --- a/protobuf.bzl +++ b/protobuf.bzl @@ -1,13 +1,19 @@ # -*- mode: python; -*- PYTHON-PREPROCESSING-REQUIRED +def _GetPath(ctx, path): + if ctx.label.workspace_root: + return ctx.label.workspace_root + '/' + path + else: + return path + def _GenDir(ctx): if not ctx.attr.includes: - return "" + return ctx.label.workspace_root if not ctx.attr.includes[0]: - return ctx.label.package + return _GetPath(ctx, ctx.label.package) if not ctx.label.package: - return ctx.attr.includes[0] - return ctx.label.package + '/' + ctx.attr.includes[0] + return _GetPath(ctx, ctx.attr.includes[0]) + return _GetPath(ctx, ctx.label.package + '/' + ctx.attr.includes[0]) def _CcOuts(srcs): return [s[:-len(".proto")] + ".pb.h" for s in srcs] + \ @@ -36,8 +42,6 @@ def _RelativeOutputPath(path, include): return path[len(PACKAGE_NAME)+1:] - - def _proto_gen_impl(ctx): """General implementation for generating protos""" srcs = ctx.files.srcs |