From 1a5a609b0e504aa5bf25e5b79d505974e34f0f98 Mon Sep 17 00:00:00 2001 From: Laurent Le Brun Date: Fri, 24 May 2019 14:22:13 +0200 Subject: Update upb_proto_library.bzl for Bazel compatibility With this change, the code now builds with the flags --incompatible_depset_is_not_iterable, --incompatible_new_actions_api, and --incompatible_no_support_tools_in_action_inputs. These flags will soon be enabled by default in Bazel. --- bazel/upb_proto_library.bzl | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) (limited to 'bazel') diff --git a/bazel/upb_proto_library.bzl b/bazel/upb_proto_library.bzl index 09d557c..bb3eb57 100644 --- a/bazel/upb_proto_library.bzl +++ b/bazel/upb_proto_library.bzl @@ -42,7 +42,7 @@ def _generate_output_file(ctx, src, extension): else: real_short_path = paths.relativize(src.short_path, ctx.label.package) output_filename = paths.replace_extension(real_short_path, extension) - ret = ctx.new_file(ctx.genfiles_dir, output_filename) + ret = ctx.actions.declare_file(output_filename) return ret def _filter_none(elems): @@ -149,12 +149,13 @@ _WrappedGeneratedSrcs = provider(fields = ["srcs"]) def _compile_upb_protos(ctx, proto_info, proto_sources, ext): srcs = [_generate_output_file(ctx, name, ext + ".c") for name in proto_sources] hdrs = [_generate_output_file(ctx, name, ext + ".h") for name in proto_sources] - transitive_sets = list(proto_info.transitive_descriptor_sets) + transitive_sets = proto_info.transitive_descriptor_sets.to_list() ctx.actions.run( inputs = depset( - direct = [ctx.executable._upbc, proto_info.direct_descriptor_set], + direct = [proto_info.direct_descriptor_set], transitive = [proto_info.transitive_descriptor_sets], ), + tools = [ctx.executable._upbc], outputs = srcs + hdrs, executable = ctx.executable._protoc, arguments = [ -- cgit v1.2.3 From ba29af3a6af9c2e4dfc32ad0230f889e117908b3 Mon Sep 17 00:00:00 2001 From: Joshua Haberman Date: Sat, 1 Jun 2019 19:27:49 -0700 Subject: Hid generated-code-only headers inside a separate library. --- BUILD | 24 +++++++++++++++++++++--- CMakeLists.txt | 9 +++++++-- bazel/upb_proto_library.bzl | 5 ++++- 3 files changed, 32 insertions(+), 6 deletions(-) (limited to 'bazel') diff --git a/BUILD b/BUILD index 11156c8..70ef137 100644 --- a/BUILD +++ b/BUILD @@ -50,7 +50,11 @@ cc_library( srcs = [ "upb/decode.c", "upb/encode.c", + "upb/generated_util.h", "upb/msg.c", + "upb/msg.h", + "upb/port_def.inc", + "upb/port_undef.inc", "upb/table.c", "upb/table.int.h", "upb/upb.c", @@ -58,16 +62,30 @@ cc_library( hdrs = [ "upb/decode.h", "upb/encode.h", - "upb/generated_util.h", - "upb/msg.h", "upb/upb.h", ], copts = COPTS, - # Internal-only, but we have to make them public for generated code. + visibility = ["//visibility:public"], +) + +# Common support routines used by generated code. This library has no +# implementation, but depends on :upb and exposes a few more hdrs. +# +# This is public only because we have no way of visibility-limiting it to +# upb_proto_library() only. This interface is not stable and by using it you +# give up any backward compatibility guarantees. +cc_library( + name = "generated_code_support__only_for_generated_code_do_not_use__i_give_permission_to_break_me", textual_hdrs = [ "upb/port_def.inc", "upb/port_undef.inc", ], + hdrs = [ + "upb/generated_util.h", + "upb/msg.h", + ], + deps = [":upb"], + copts = COPTS, visibility = ["//visibility:public"], ) diff --git a/CMakeLists.txt b/CMakeLists.txt index 2573173..c1c45df 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -63,15 +63,20 @@ enable_testing() add_library(upb upb/decode.c upb/encode.c + upb/generated_util.h upb/msg.c + upb/msg.h + upb/port_def.inc + upb/port_undef.inc upb/table.c upb/table.int.h upb/upb.c upb/decode.h upb/encode.h - upb/generated_util.h - upb/msg.h upb/upb.h) +add_library(generated_code_support__only_for_generated_code_do_not_use__i_give_permission_to_break_me INTERFACE) +target_link_libraries(generated_code_support__only_for_generated_code_do_not_use__i_give_permission_to_break_me INTERFACE + upb) add_library(reflection upb/def.c upb/msgfactory.c diff --git a/bazel/upb_proto_library.bzl b/bazel/upb_proto_library.bzl index 09d557c..e68f340 100644 --- a/bazel/upb_proto_library.bzl +++ b/bazel/upb_proto_library.bzl @@ -229,7 +229,10 @@ _upb_proto_library_aspect = aspect( "_cc_toolchain": attr.label( default = "@bazel_tools//tools/cpp:current_cc_toolchain", ), - "_upb": attr.label_list(default = ["//:upb"]), + "_upb": attr.label_list(default = [ + "//:generated_code_support__only_for_generated_code_do_not_use__i_give_permission_to_break_me", + "//:upb" + ]), "_ext": attr.string(default = ".upb"), }), implementation = _upb_proto_aspect_impl, -- cgit v1.2.3