|
|
|
@ -51,7 +51,7 @@ def lua_cclibrary(name, srcs, hdrs = [], deps = [], luadeps = []): |
|
|
|
|
"-undefined dynamic_lookup", |
|
|
|
|
], |
|
|
|
|
"//conditions:default": [], |
|
|
|
|
}) |
|
|
|
|
}), |
|
|
|
|
) |
|
|
|
|
|
|
|
|
|
native.genrule( |
|
|
|
@ -313,10 +313,6 @@ def cc_library_func(ctx, hdrs, srcs, deps): |
|
|
|
|
cc_toolchain = toolchain, |
|
|
|
|
static_library = output_file, |
|
|
|
|
) |
|
|
|
|
linking_context = cc_common.create_linking_context( |
|
|
|
|
libraries_to_link = [library_to_link], |
|
|
|
|
) |
|
|
|
|
|
|
|
|
|
archiver_path = cc_common.get_tool_for_action( |
|
|
|
|
feature_configuration = feature_configuration, |
|
|
|
|
action_name = CPP_LINK_STATIC_LIBRARY_ACTION_NAME, |
|
|
|
@ -332,7 +328,13 @@ def cc_library_func(ctx, hdrs, srcs, deps): |
|
|
|
|
action_name = CPP_LINK_STATIC_LIBRARY_ACTION_NAME, |
|
|
|
|
variables = archiver_variables, |
|
|
|
|
) |
|
|
|
|
object_files = compilation_info.cc_compilation_outputs.object_files(use_pic = False) |
|
|
|
|
|
|
|
|
|
# Non-PIC objects only get emitted in opt builds. |
|
|
|
|
use_pic = True |
|
|
|
|
if ctx.var.get("COMPILATION_MODE") == "opt": |
|
|
|
|
use_pic = False |
|
|
|
|
|
|
|
|
|
object_files = compilation_info.cc_compilation_outputs.object_files(use_pic = use_pic) |
|
|
|
|
args = ctx.actions.args() |
|
|
|
|
args.add_all(command_line) |
|
|
|
|
args.add_all(object_files) |
|
|
|
@ -357,11 +359,14 @@ def cc_library_func(ctx, hdrs, srcs, deps): |
|
|
|
|
), |
|
|
|
|
outputs = [output_file], |
|
|
|
|
) |
|
|
|
|
linking_context = cc_common.create_linking_context( |
|
|
|
|
libraries_to_link = [library_to_link], |
|
|
|
|
) |
|
|
|
|
return [ |
|
|
|
|
CcInfo( |
|
|
|
|
compilation_context = compilation_info.compilation_context, |
|
|
|
|
linking_context = linking_context, |
|
|
|
|
) |
|
|
|
|
), |
|
|
|
|
] |
|
|
|
|
|
|
|
|
|
def _upb_proto_library_aspect_impl(target, ctx): |
|
|
|
@ -377,20 +382,22 @@ def _upb_proto_library_aspect_impl(target, ctx): |
|
|
|
|
file_types = types, |
|
|
|
|
) |
|
|
|
|
ctx.actions.run( |
|
|
|
|
inputs = [ctx.executable._upbc] + proto_sources, |
|
|
|
|
inputs = depset( |
|
|
|
|
direct = target[ProtoInfo].direct_sources + [ctx.executable._upbc], |
|
|
|
|
transitive = [target[ProtoInfo].transitive_sources], |
|
|
|
|
), |
|
|
|
|
outputs = files["srcs"] + files["hdrs"], |
|
|
|
|
executable = ctx.executable._protoc, |
|
|
|
|
arguments = ["--upb_out"], #, ctx.genfiles_dir, "--plugin=protoc-gen-upb=" + ctx.executable._upbc.path] + [file.path for file in files["srcs"]], |
|
|
|
|
arguments = ["--upb_out=" + ctx.genfiles_dir.path, "--plugin=protoc-gen-upb=" + ctx.executable._upbc.path] + [file.path for file in proto_sources], |
|
|
|
|
progress_message = "Generating upb protos", |
|
|
|
|
) |
|
|
|
|
return cc_library_func( |
|
|
|
|
ctx = ctx, |
|
|
|
|
hdrs = files["hdrs"], |
|
|
|
|
srcs = files["srcs"], |
|
|
|
|
deps = ctx.rule.attr.deps |
|
|
|
|
deps = ctx.rule.attr.deps + [ctx.attr._upb], |
|
|
|
|
) |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
_upb_proto_library_aspect = aspect( |
|
|
|
|
attrs = { |
|
|
|
|
"_upbc": attr.label( |
|
|
|
@ -416,14 +423,20 @@ def _upb_proto_library_impl(ctx): |
|
|
|
|
dep = ctx.attr.deps[0] |
|
|
|
|
if CcInfo not in dep: |
|
|
|
|
fail("proto_library rule must generate CcInfo (have cc_api_version>0).") |
|
|
|
|
return [dep[CcInfo]] |
|
|
|
|
|
|
|
|
|
return [ |
|
|
|
|
DefaultInfo( |
|
|
|
|
files = depset( |
|
|
|
|
[dep[CcInfo].linking_context.libraries_to_link[0].static_library], |
|
|
|
|
), |
|
|
|
|
), |
|
|
|
|
dep[CcInfo], |
|
|
|
|
] |
|
|
|
|
|
|
|
|
|
upb_proto_library = rule( |
|
|
|
|
output_to_genfiles = True, |
|
|
|
|
implementation = _upb_proto_library_impl, |
|
|
|
|
attrs = { |
|
|
|
|
'deps': attr.label_list( |
|
|
|
|
"deps": attr.label_list( |
|
|
|
|
aspects = [_upb_proto_library_aspect], |
|
|
|
|
allow_rules = ["proto_library"], |
|
|
|
|
providers = [ProtoInfo], |
|
|
|
|