diff options
author | Jisi Liu <liujisi@google.com> | 2016-02-02 10:38:45 -0800 |
---|---|---|
committer | Jisi Liu <liujisi@google.com> | 2016-02-02 10:38:45 -0800 |
commit | 287a095c87d2c188a6869a1e8addcc5d7ab18958 (patch) | |
tree | 7ac78846007b95b55e3f393eec9ea10eafc0cffb | |
parent | 7727e2603c5aae1f1d914074979f2dfd74846dbd (diff) | |
parent | 76547e5190845eab44a40e171e4686c07ea9df2e (diff) | |
download | protobuf-287a095c87d2c188a6869a1e8addcc5d7ab18958.tar.gz protobuf-287a095c87d2c188a6869a1e8addcc5d7ab18958.tar.bz2 protobuf-287a095c87d2c188a6869a1e8addcc5d7ab18958.zip |
Merge pull request #1165 from damienmg/master
Make protobuf Skylark extension appends the workspace root
-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 |