Give generated_code_support.h its own forwarding header.
This will allow us to refactor the underlying rules and headers without breaking the generated code.
PiperOrigin-RevId: 541517265
diff --git a/BUILD b/BUILD
index 549ef0b..39023f8 100644
--- a/BUILD
+++ b/BUILD
@@ -465,38 +465,21 @@
# 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",
- hdrs = [
- "upb/collections/array.h",
- "upb/collections/array_internal.h",
- "upb/collections/map_gencode_util.h",
- "upb/collections/message_value.h",
- "upb/extension_registry.h",
- "upb/message/accessors.h",
- "upb/message/accessors_internal.h",
- "upb/message/extension_internal.h",
- "upb/message/internal.h",
- "upb/message/message.h",
- "upb/mini_table/common.h",
- "upb/mini_table/enum_internal.h",
- "upb/mini_table/extension_internal.h",
- "upb/mini_table/field_internal.h",
- "upb/mini_table/file_internal.h",
- "upb/mini_table/message_internal.h",
- "upb/mini_table/sub_internal.h",
- "upb/mini_table/types.h",
+ hdrs = ["upb/generated_code_support.h"],
+ copts = UPB_DEFAULT_COPTS,
+ textual_hdrs = [
"upb/port/def.inc",
"upb/port/undef.inc",
- "upb/wire/decode.h",
- "upb/wire/decode_fast.h",
- "upb/wire/encode.h",
],
- copts = UPB_DEFAULT_COPTS,
visibility = ["//visibility:public"],
deps = [
- ":base",
":collections_internal",
- ":hash",
+ ":message_accessors",
+ ":message_accessors_internal",
+ ":message_internal",
+ ":mini_table_internal",
":upb",
+ ":wire_internal",
],
)
@@ -1050,6 +1033,7 @@
":descriptor_upb_proto",
":eps_copy_input_stream",
":fastdecode",
+ ":generated_code_support__only_for_generated_code_do_not_use__i_give_permission_to_break_me",
":hash",
":lex",
":mem_internal",
@@ -1088,6 +1072,7 @@
":descriptor_upb_proto_reflection",
":eps_copy_input_stream",
":fastdecode",
+ ":generated_code_support__only_for_generated_code_do_not_use__i_give_permission_to_break_me",
":hash",
":json",
":lex",
@@ -1128,6 +1113,7 @@
":descriptor_upb_proto",
":eps_copy_input_stream",
":fastdecode",
+ ":generated_code_support__only_for_generated_code_do_not_use__i_give_permission_to_break_me",
":hash",
":json",
":lex",
diff --git a/upb/generated_code_support.h b/upb/generated_code_support.h
new file mode 100644
index 0000000..59f5694
--- /dev/null
+++ b/upb/generated_code_support.h
@@ -0,0 +1,56 @@
+/*
+ * Copyright (c) 2009-2023, Google LLC
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions are met:
+ * * Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * * Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ * * Neither the name of Google LLC nor the
+ * names of its contributors may be used to endorse or promote products
+ * derived from this software without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
+ * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED. IN NO EVENT SHALL Google LLC BE LIABLE FOR ANY DIRECT,
+ * INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
+ * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
+ * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
+ * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
+ * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#ifndef UPB_GENERATED_CODE_SUPPORT_H_
+#define UPB_GENERATED_CODE_SUPPORT_H_
+
+// IWYU pragma: begin_exports
+#include "upb/collections/array.h"
+#include "upb/collections/array_internal.h"
+#include "upb/collections/map_gencode_util.h"
+#include "upb/collections/message_value.h"
+#include "upb/extension_registry.h"
+#include "upb/message/accessors.h"
+#include "upb/message/accessors_internal.h"
+#include "upb/message/extension_internal.h"
+#include "upb/message/internal.h"
+#include "upb/message/message.h"
+#include "upb/mini_table/common.h"
+#include "upb/mini_table/decode.h"
+#include "upb/mini_table/enum_internal.h"
+#include "upb/mini_table/extension_internal.h"
+#include "upb/mini_table/field_internal.h"
+#include "upb/mini_table/file_internal.h"
+#include "upb/mini_table/message_internal.h"
+#include "upb/mini_table/sub_internal.h"
+#include "upb/mini_table/types.h"
+#include "upb/wire/decode.h"
+#include "upb/wire/decode_fast.h"
+#include "upb/wire/encode.h"
+// IWYU pragma: end_exports
+
+#endif // UPB_GENERATED_CODE_SUPPORT_H_
diff --git a/upb/reflection/stage0/google/protobuf/descriptor.upb.c b/upb/reflection/stage0/google/protobuf/descriptor.upb.c
index 8620a81..cc200d8 100644
--- a/upb/reflection/stage0/google/protobuf/descriptor.upb.c
+++ b/upb/reflection/stage0/google/protobuf/descriptor.upb.c
@@ -1,8 +1,5 @@
#include <stddef.h>
-#include "upb/collections/array_internal.h"
-#include "upb/message/internal.h"
-#include "upb/mini_table/decode.h"
-#include "upb/mini_table/enum_internal.h"
+#include "upb/generated_code_support.h"
#include "google/protobuf/descriptor.upb.h"
static upb_Arena* upb_BootstrapArena() {
@@ -414,4 +411,3 @@
upb_BootstrapArena(), NULL);
return mini_table;
}
-
diff --git a/upb/reflection/stage0/google/protobuf/descriptor.upb.h b/upb/reflection/stage0/google/protobuf/descriptor.upb.h
index 81c8968..a5e0490 100644
--- a/upb/reflection/stage0/google/protobuf/descriptor.upb.h
+++ b/upb/reflection/stage0/google/protobuf/descriptor.upb.h
@@ -9,14 +9,7 @@
#ifndef GOOGLE_PROTOBUF_DESCRIPTOR_PROTO_UPB_H_
#define GOOGLE_PROTOBUF_DESCRIPTOR_PROTO_UPB_H_
-#include "upb/collections/array_internal.h"
-#include "upb/collections/map_gencode_util.h"
-#include "upb/message/accessors.h"
-#include "upb/message/internal.h"
-#include "upb/mini_table/enum_internal.h"
-#include "upb/wire/decode.h"
-#include "upb/wire/decode_fast.h"
-#include "upb/wire/encode.h"
+#include "upb/generated_code_support.h"
// Must be last.
#include "upb/port/def.inc"
diff --git a/upbc/protoc-gen-upb.cc b/upbc/protoc-gen-upb.cc
index 8451564..045581d 100644
--- a/upbc/protoc-gen-upb.cc
+++ b/upbc/protoc-gen-upb.cc
@@ -841,14 +841,7 @@
output(
"#ifndef $0_UPB_H_\n"
"#define $0_UPB_H_\n\n"
- "#include \"upb/collections/array_internal.h\"\n"
- "#include \"upb/collections/map_gencode_util.h\"\n"
- "#include \"upb/message/accessors.h\"\n"
- "#include \"upb/message/internal.h\"\n"
- "#include \"upb/mini_table/enum_internal.h\"\n"
- "#include \"upb/wire/decode.h\"\n"
- "#include \"upb/wire/decode_fast.h\"\n"
- "#include \"upb/wire/encode.h\"\n\n",
+ "#include \"upb/generated_code_support.h\"\n",
ToPreproc(file.name()));
for (int i = 0; i < file.public_dependency_count(); i++) {
@@ -1544,9 +1537,7 @@
output(
"#include <stddef.h>\n"
- "#include \"upb/collections/array_internal.h\"\n"
- "#include \"upb/message/internal.h\"\n"
- "#include \"upb/mini_table/enum_internal.h\"\n"
+ "#include \"upb/generated_code_support.h\"\n"
"#include \"$0\"\n",
HeaderFilename(file));
@@ -1638,10 +1629,7 @@
const Options& options, Output& output) {
output(
"#include <stddef.h>\n"
- "#include \"upb/collections/array_internal.h\"\n"
- "#include \"upb/message/internal.h\"\n"
- "#include \"upb/mini_table/decode.h\"\n"
- "#include \"upb/mini_table/enum_internal.h\"\n"
+ "#include \"upb/generated_code_support.h\"\n"
"#include \"$0\"\n\n",
HeaderFilename(file));
diff --git a/upbc/stage0/google/protobuf/compiler/plugin.upb.c b/upbc/stage0/google/protobuf/compiler/plugin.upb.c
index 70ada66..1590f35 100644
--- a/upbc/stage0/google/protobuf/compiler/plugin.upb.c
+++ b/upbc/stage0/google/protobuf/compiler/plugin.upb.c
@@ -1,8 +1,5 @@
#include <stddef.h>
-#include "upb/collections/array_internal.h"
-#include "upb/message/internal.h"
-#include "upb/mini_table/decode.h"
-#include "upb/mini_table/enum_internal.h"
+#include "upb/generated_code_support.h"
#include "google/protobuf/compiler/plugin.upb.h"
#include "google/protobuf/descriptor.upb.h"
@@ -65,4 +62,3 @@
upb_BootstrapArena(), NULL);
return mini_table;
}
-
diff --git a/upbc/stage0/google/protobuf/compiler/plugin.upb.h b/upbc/stage0/google/protobuf/compiler/plugin.upb.h
index 412707c..be35a42 100644
--- a/upbc/stage0/google/protobuf/compiler/plugin.upb.h
+++ b/upbc/stage0/google/protobuf/compiler/plugin.upb.h
@@ -9,14 +9,7 @@
#ifndef GOOGLE_PROTOBUF_COMPILER_PLUGIN_PROTO_UPB_H_
#define GOOGLE_PROTOBUF_COMPILER_PLUGIN_PROTO_UPB_H_
-#include "upb/collections/array_internal.h"
-#include "upb/collections/map_gencode_util.h"
-#include "upb/message/accessors.h"
-#include "upb/message/internal.h"
-#include "upb/mini_table/enum_internal.h"
-#include "upb/wire/decode.h"
-#include "upb/wire/decode_fast.h"
-#include "upb/wire/encode.h"
+#include "upb/generated_code_support.h"
// Must be last.
#include "upb/port/def.inc"