diff options
author | Joshua Haberman <jhaberman@gmail.com> | 2019-06-02 20:40:15 -0700 |
---|---|---|
committer | GitHub <noreply@github.com> | 2019-06-02 20:40:15 -0700 |
commit | 26245628a9b8abfc217b080eec73af477a5fc65c (patch) | |
tree | 82d74c160a0fc33073ff6ce7081d33767feec45e | |
parent | d5137134e0c56164e56ba413a5fb18cee4d472f1 (diff) | |
parent | ba29af3a6af9c2e4dfc32ad0230f889e117908b3 (diff) |
Merge pull request #178 from haberman/generated-only
Hid generated-code-only headers inside a separate library.
-rw-r--r-- | BUILD | 24 | ||||
-rw-r--r-- | CMakeLists.txt | 9 | ||||
-rw-r--r-- | bazel/upb_proto_library.bzl | 5 |
3 files changed, 32 insertions, 6 deletions
@@ -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 bb3eb57..147e088 100644 --- a/bazel/upb_proto_library.bzl +++ b/bazel/upb_proto_library.bzl @@ -230,7 +230,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, |