Commit 287a095c authored by Jisi Liu's avatar Jisi Liu

Merge pull request #1165 from damienmg/master

Make protobuf Skylark extension appends the workspace root
parents 7727e260 76547e51
# -*- mode: python; -*- PYTHON-PREPROCESSING-REQUIRED # -*- 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): def _GenDir(ctx):
if not ctx.attr.includes: if not ctx.attr.includes:
return "" return ctx.label.workspace_root
if not ctx.attr.includes[0]: if not ctx.attr.includes[0]:
return ctx.label.package return _GetPath(ctx, ctx.label.package)
if not ctx.label.package: if not ctx.label.package:
return ctx.attr.includes[0] return _GetPath(ctx, ctx.attr.includes[0])
return ctx.label.package + '/' + ctx.attr.includes[0] return _GetPath(ctx, ctx.label.package + '/' + ctx.attr.includes[0])
def _CcOuts(srcs): def _CcOuts(srcs):
return [s[:-len(".proto")] + ".pb.h" for s in srcs] + \ return [s[:-len(".proto")] + ".pb.h" for s in srcs] + \
...@@ -36,8 +42,6 @@ def _RelativeOutputPath(path, include): ...@@ -36,8 +42,6 @@ def _RelativeOutputPath(path, include):
return path[len(PACKAGE_NAME)+1:] return path[len(PACKAGE_NAME)+1:]
def _proto_gen_impl(ctx): def _proto_gen_impl(ctx):
"""General implementation for generating protos""" """General implementation for generating protos"""
srcs = ctx.files.srcs srcs = ctx.files.srcs
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment