Hook up staleness tests to non-bootstrap edition defaults
PiperOrigin-RevId: 623936729pull/16469/head
parent
de5e7b6b8e
commit
7d87a1780a
|
@ -10,6 +10,7 @@ load("//build_defs:java_opts.bzl", "protobuf_java_export", "protobuf_java_librar
|
||||||
load("//conformance:defs.bzl", "conformance_test")
|
load("//conformance:defs.bzl", "conformance_test")
|
||||||
load("//java/internal:testing.bzl", "junit_tests")
|
load("//java/internal:testing.bzl", "junit_tests")
|
||||||
load("//src/google/protobuf/editions:defaults.bzl", "compile_edition_defaults", "embed_edition_defaults")
|
load("//src/google/protobuf/editions:defaults.bzl", "compile_edition_defaults", "embed_edition_defaults")
|
||||||
|
load("//upb/cmake:build_defs.bzl", "staleness_test")
|
||||||
|
|
||||||
LITE_SRCS = [
|
LITE_SRCS = [
|
||||||
# Keep in sync with `//java/lite:pom.xml`.
|
# Keep in sync with `//java/lite:pom.xml`.
|
||||||
|
@ -106,6 +107,15 @@ LITE_SRCS = [
|
||||||
"src/main/java/com/google/protobuf/Writer.java",
|
"src/main/java/com/google/protobuf/Writer.java",
|
||||||
]
|
]
|
||||||
|
|
||||||
|
FULL_SRCS = glob(
|
||||||
|
[
|
||||||
|
"src/main/java/com/google/protobuf/*.java",
|
||||||
|
],
|
||||||
|
exclude = LITE_SRCS,
|
||||||
|
) + [
|
||||||
|
":gen_well_known_protos_java",
|
||||||
|
]
|
||||||
|
|
||||||
internal_gen_well_known_protos_java(
|
internal_gen_well_known_protos_java(
|
||||||
name = "gen_well_known_protos_javalite",
|
name = "gen_well_known_protos_javalite",
|
||||||
javalite = True,
|
javalite = True,
|
||||||
|
@ -190,6 +200,32 @@ filegroup(
|
||||||
visibility = ["//pkg:__pkg__"],
|
visibility = ["//pkg:__pkg__"],
|
||||||
)
|
)
|
||||||
|
|
||||||
|
compile_edition_defaults(
|
||||||
|
name = "java_edition_defaults",
|
||||||
|
srcs = [
|
||||||
|
"//:descriptor_proto",
|
||||||
|
"//java/core:java_features_proto",
|
||||||
|
],
|
||||||
|
maximum_edition = "2023",
|
||||||
|
minimum_edition = "PROTO2",
|
||||||
|
)
|
||||||
|
|
||||||
|
embed_edition_defaults(
|
||||||
|
name = "embedded_java_edition_defaults_generate",
|
||||||
|
defaults = "java_edition_defaults",
|
||||||
|
output = "generated/src/main/java/com/google/protobuf/JavaEditionDefaults.java",
|
||||||
|
placeholder = "DEFAULTS_VALUE",
|
||||||
|
template = "src/main/java/com/google/protobuf/JavaEditionDefaults.java.template",
|
||||||
|
)
|
||||||
|
|
||||||
|
staleness_test(
|
||||||
|
name = "generated_java_defaults_staleness_test",
|
||||||
|
outs = ["src/main/java/com/google/protobuf/JavaEditionDefaults.java"],
|
||||||
|
generated_pattern = "generated/%s",
|
||||||
|
tags = ["manual"],
|
||||||
|
target_files = ["src/main/java/com/google/protobuf/JavaEditionDefaults.java"],
|
||||||
|
)
|
||||||
|
|
||||||
internal_gen_well_known_protos_java(
|
internal_gen_well_known_protos_java(
|
||||||
name = "gen_well_known_protos_java",
|
name = "gen_well_known_protos_java",
|
||||||
deps = [
|
deps = [
|
||||||
|
@ -211,14 +247,7 @@ internal_gen_well_known_protos_java(
|
||||||
|
|
||||||
java_library(
|
java_library(
|
||||||
name = "core",
|
name = "core",
|
||||||
srcs = glob(
|
srcs = FULL_SRCS,
|
||||||
[
|
|
||||||
"src/main/java/com/google/protobuf/*.java",
|
|
||||||
],
|
|
||||||
exclude = LITE_SRCS,
|
|
||||||
) + [
|
|
||||||
":gen_well_known_protos_java",
|
|
||||||
],
|
|
||||||
visibility = ["//visibility:public"],
|
visibility = ["//visibility:public"],
|
||||||
exports = [
|
exports = [
|
||||||
":lite_runtime_only",
|
":lite_runtime_only",
|
||||||
|
@ -230,14 +259,7 @@ java_library(
|
||||||
|
|
||||||
protobuf_versioned_java_library(
|
protobuf_versioned_java_library(
|
||||||
name = "core_bundle",
|
name = "core_bundle",
|
||||||
srcs = glob(
|
srcs = FULL_SRCS,
|
||||||
[
|
|
||||||
"src/main/java/com/google/protobuf/*.java",
|
|
||||||
],
|
|
||||||
exclude = LITE_SRCS,
|
|
||||||
) + [
|
|
||||||
":gen_well_known_protos_java",
|
|
||||||
],
|
|
||||||
automatic_module_name = "com.google.protobuf",
|
automatic_module_name = "com.google.protobuf",
|
||||||
bundle_description = "Core Protocol Buffers library. Protocol Buffers " +
|
bundle_description = "Core Protocol Buffers library. Protocol Buffers " +
|
||||||
"are a way of encoding structured data in an " +
|
"are a way of encoding structured data in an " +
|
||||||
|
|
|
@ -13,6 +13,8 @@ cd $(dirname -- "$0")
|
||||||
readonly BazelBin="${BAZEL:-bazel} ${BAZEL_STARTUP_FLAGS}"
|
readonly BazelBin="${BAZEL:-bazel} ${BAZEL_STARTUP_FLAGS}"
|
||||||
|
|
||||||
STALENESS_TESTS=(
|
STALENESS_TESTS=(
|
||||||
|
"java/core:generated_java_defaults_staleness_test"
|
||||||
|
"upb/reflection:bootstrap_upb_defaults_staleness_test"
|
||||||
"src:cmake_lists_staleness_test"
|
"src:cmake_lists_staleness_test"
|
||||||
"src/google/protobuf:well_known_types_staleness_test"
|
"src/google/protobuf:well_known_types_staleness_test"
|
||||||
"objectivec:well_known_types_staleness_test"
|
"objectivec:well_known_types_staleness_test"
|
||||||
|
|
|
@ -3006,8 +3006,12 @@ bool CommandLineInterface::WriteDescriptorSet(
|
||||||
}
|
}
|
||||||
|
|
||||||
bool CommandLineInterface::WriteEditionDefaults(const DescriptorPool& pool) {
|
bool CommandLineInterface::WriteEditionDefaults(const DescriptorPool& pool) {
|
||||||
const Descriptor* feature_set =
|
const Descriptor* feature_set;
|
||||||
pool.FindMessageTypeByName("google.protobuf.FeatureSet");
|
if (opensource_runtime_) {
|
||||||
|
feature_set = pool.FindMessageTypeByName("google.protobuf.FeatureSet");
|
||||||
|
} else {
|
||||||
|
feature_set = pool.FindMessageTypeByName("google.protobuf.FeatureSet");
|
||||||
|
}
|
||||||
if (feature_set == nullptr) {
|
if (feature_set == nullptr) {
|
||||||
std::cerr << edition_defaults_out_name_
|
std::cerr << edition_defaults_out_name_
|
||||||
<< ": Could not find FeatureSet in descriptor pool. Please make "
|
<< ": Could not find FeatureSet in descriptor pool. Please make "
|
||||||
|
|
|
@ -193,6 +193,11 @@ class PROTOC_EXPORT CommandLineInterface {
|
||||||
void SetVersionInfo(const std::string& text) { version_info_ = text; }
|
void SetVersionInfo(const std::string& text) { version_info_ = text; }
|
||||||
|
|
||||||
|
|
||||||
|
// Configure protoc to act as if we're in opensource.
|
||||||
|
void set_opensource_runtime(bool opensource) {
|
||||||
|
opensource_runtime_ = opensource;
|
||||||
|
}
|
||||||
|
|
||||||
private:
|
private:
|
||||||
// -----------------------------------------------------------------
|
// -----------------------------------------------------------------
|
||||||
|
|
||||||
|
@ -463,6 +468,8 @@ class PROTOC_EXPORT CommandLineInterface {
|
||||||
|
|
||||||
// When using --encode, this will be passed to SetSerializationDeterministic.
|
// When using --encode, this will be passed to SetSerializationDeterministic.
|
||||||
bool deterministic_output_ = false;
|
bool deterministic_output_ = false;
|
||||||
|
|
||||||
|
bool opensource_runtime_ = PROTO2_IS_OSS;
|
||||||
};
|
};
|
||||||
|
|
||||||
} // namespace compiler
|
} // namespace compiler
|
||||||
|
|
|
@ -39,6 +39,9 @@ int ProtobufMain(int argc, char* argv[]) {
|
||||||
|
|
||||||
CommandLineInterface cli;
|
CommandLineInterface cli;
|
||||||
cli.AllowPlugins("protoc-");
|
cli.AllowPlugins("protoc-");
|
||||||
|
#ifdef GOOGLE_PROTOBUF_RUNTIME_INCLUDE_BASE
|
||||||
|
cli.set_opensource_runtime(true);
|
||||||
|
#endif
|
||||||
|
|
||||||
// Proto2 C++
|
// Proto2 C++
|
||||||
cpp::CppGenerator cpp_generator;
|
cpp::CppGenerator cpp_generator;
|
||||||
|
|
|
@ -31,7 +31,7 @@ def _compile_edition_defaults_impl(ctx):
|
||||||
ctx.actions.run(
|
ctx.actions.run(
|
||||||
outputs = [out_file],
|
outputs = [out_file],
|
||||||
inputs = sources,
|
inputs = sources,
|
||||||
executable = ctx.executable._protoc,
|
executable = ctx.executable.protoc or ctx.executable._protoc_minimal,
|
||||||
arguments = [args],
|
arguments = [args],
|
||||||
progress_message = "Generating edition defaults",
|
progress_message = "Generating edition defaults",
|
||||||
)
|
)
|
||||||
|
@ -45,7 +45,12 @@ compile_edition_defaults = rule(
|
||||||
),
|
),
|
||||||
"minimum_edition": attr.string(mandatory = True),
|
"minimum_edition": attr.string(mandatory = True),
|
||||||
"maximum_edition": attr.string(mandatory = True),
|
"maximum_edition": attr.string(mandatory = True),
|
||||||
"_protoc": attr.label(
|
"protoc": attr.label(
|
||||||
|
mandatory = False,
|
||||||
|
executable = True,
|
||||||
|
cfg = "exec",
|
||||||
|
),
|
||||||
|
"_protoc_minimal": attr.label(
|
||||||
default = "//src/google/protobuf/compiler:protoc_minimal",
|
default = "//src/google/protobuf/compiler:protoc_minimal",
|
||||||
executable = True,
|
executable = True,
|
||||||
cfg = "exec",
|
cfg = "exec",
|
||||||
|
|
|
@ -7,12 +7,16 @@
|
||||||
|
|
||||||
load("//bazel:upb_minitable_proto_library.bzl", "upb_minitable_proto_library")
|
load("//bazel:upb_minitable_proto_library.bzl", "upb_minitable_proto_library")
|
||||||
load("//bazel:upb_proto_library.bzl", "upb_proto_reflection_library")
|
load("//bazel:upb_proto_library.bzl", "upb_proto_reflection_library")
|
||||||
|
|
||||||
|
# end:github_only
|
||||||
load(
|
load(
|
||||||
"//src/google/protobuf/editions:defaults.bzl",
|
"//src/google/protobuf/editions:defaults.bzl",
|
||||||
"compile_edition_defaults",
|
"compile_edition_defaults",
|
||||||
"embed_edition_defaults",
|
"embed_edition_defaults",
|
||||||
)
|
)
|
||||||
load("//upb/bazel:build_defs.bzl", "UPB_DEFAULT_COPTS")
|
load("//upb/bazel:build_defs.bzl", "UPB_DEFAULT_COPTS")
|
||||||
|
|
||||||
|
# begin:github_only
|
||||||
load(
|
load(
|
||||||
"//upb/cmake:build_defs.bzl",
|
"//upb/cmake:build_defs.bzl",
|
||||||
"staleness_test",
|
"staleness_test",
|
||||||
|
@ -188,6 +192,29 @@ cc_test(
|
||||||
],
|
],
|
||||||
)
|
)
|
||||||
|
|
||||||
|
# begin:google_only
|
||||||
|
# compile_edition_defaults(
|
||||||
|
# name = "upb_edition_defaults",
|
||||||
|
# srcs = [
|
||||||
|
# "//:descriptor_proto",
|
||||||
|
# ],
|
||||||
|
# compatible_with = ["//buildenv/target:non_prod"],
|
||||||
|
# maximum_edition = "2023",
|
||||||
|
# minimum_edition = "PROTO2",
|
||||||
|
# )
|
||||||
|
#
|
||||||
|
# embed_edition_defaults(
|
||||||
|
# name = "embedded_upb_edition_defaults_generate",
|
||||||
|
# compatible_with = ["//buildenv/target:non_prod"],
|
||||||
|
# defaults = "upb_edition_defaults",
|
||||||
|
# output = "internal/upb_edition_defaults.h",
|
||||||
|
# placeholder = "DEFAULTS_VALUE",
|
||||||
|
# template = "internal/upb_edition_defaults.h.template",
|
||||||
|
# )
|
||||||
|
# end:google_only
|
||||||
|
|
||||||
|
# TODO Merge these once we deal with the whitespace issues with reversible stripping.
|
||||||
|
# begin:github_only
|
||||||
compile_edition_defaults(
|
compile_edition_defaults(
|
||||||
name = "upb_edition_defaults",
|
name = "upb_edition_defaults",
|
||||||
srcs = [
|
srcs = [
|
||||||
|
@ -209,8 +236,10 @@ staleness_test(
|
||||||
name = "bootstrap_upb_defaults_staleness_test",
|
name = "bootstrap_upb_defaults_staleness_test",
|
||||||
outs = ["internal/upb_edition_defaults.h"],
|
outs = ["internal/upb_edition_defaults.h"],
|
||||||
generated_pattern = "generated/%s",
|
generated_pattern = "generated/%s",
|
||||||
|
tags = ["manual"],
|
||||||
target_files = ["internal/upb_edition_defaults.h"],
|
target_files = ["internal/upb_edition_defaults.h"],
|
||||||
)
|
)
|
||||||
|
# end:github_only
|
||||||
|
|
||||||
# begin:github_only
|
# begin:github_only
|
||||||
filegroup(
|
filegroup(
|
||||||
|
|
Loading…
Reference in New Issue