From 9ce4a77f61c134bbed28bfd5be5cd7dc0e80f5e3 Mon Sep 17 00:00:00 2001 From: Josh Haberman Date: Wed, 14 Nov 2018 16:46:19 -0800 Subject: Updates to build system for upb C++ compiler. --- build_defs.bzl | 28 ++++++++++++++-------------- 1 file changed, 14 insertions(+), 14 deletions(-) (limited to 'build_defs.bzl') diff --git a/build_defs.bzl b/build_defs.bzl index 0e58bbb..c1dd422 100644 --- a/build_defs.bzl +++ b/build_defs.bzl @@ -218,31 +218,26 @@ def _remove_up(string): return _remove_suffix(string, ".proto") def _upb_proto_library_srcs_impl(ctx): - descriptors = [] + sources = [] outs = [] + include_dirs = {} for dep in ctx.attr.deps: if hasattr(dep, 'proto'): - for desc in dep.proto.transitive_descriptor_sets: - descriptors.append(desc) for src in dep.proto.transitive_sources: + sources.append(src) + include_dirs[_remove_suffix(src.path, _remove_up(src.short_path) + "." + src.extension)] = True outs.append(ctx.actions.declare_file(_remove_up(src.short_path) + ".upb.h")) outs.append(ctx.actions.declare_file(_remove_up(src.short_path) + ".upb.c")) outdir = _remove_suffix(outs[-1].path, _remove_up(src.short_path) + ".upb.c") - concatenated = ctx.actions.declare_file(ctx.label.name + "_concatenated_descriptor.bin") - descriptor_paths = [d.path for d in descriptors] + source_paths = [d.path for d in sources] + include_args = ["-I" + root for root in include_dirs.keys()] - ctx.actions.run_shell( - inputs = descriptors, - outputs = [concatenated], - progress_message = "Concatenating descriptors", - command = "cat %s > %s" % (" ".join(descriptor_paths), concatenated.path), - ) ctx.actions.run( - inputs = [concatenated], + inputs = [ctx.executable.upbc] + sources, outputs = outs, - executable = ctx.executable.upbc, - arguments = ["--outdir", outdir, concatenated.path], + executable = ctx.executable.protoc, + arguments = ["--upb_out", outdir, "--plugin=protoc-gen-upb=" + ctx.executable.upbc.path] + include_args + source_paths, progress_message = "Generating upb protos", ) @@ -255,6 +250,11 @@ _upb_proto_library_srcs = rule( executable = True, cfg = "host", ), + "protoc": attr.label( + executable = True, + cfg = "host", + default = "@com_google_protobuf//:protoc", + ), "deps": attr.label_list(), } ) -- cgit v1.2.3