ADD: added new version of protobuf

This commit is contained in:
Henry Winkel
2022-12-20 10:09:28 +01:00
parent 4a79559129
commit 1e2b3dda7b
1513 changed files with 123720 additions and 83381 deletions

View File

@@ -25,16 +25,46 @@ case "${ACTION}" in
;;
esac
# -----------------------------------------------------------------------------
# Reusing a bunch of the protos from the protocolbuffers/protobuf tree, this
# can include some extras as there is no harm in ensuring work for C++
# generation.
CORE_PROTO_FILES=(
src/google/protobuf/any_test.proto
src/google/protobuf/unittest_arena.proto
src/google/protobuf/unittest_custom_options.proto
src/google/protobuf/unittest_enormous_descriptor.proto
src/google/protobuf/unittest_embed_optimize_for.proto
src/google/protobuf/unittest_empty.proto
src/google/protobuf/unittest_import.proto
src/google/protobuf/unittest_import_lite.proto
src/google/protobuf/unittest_lite.proto
src/google/protobuf/unittest_mset.proto
src/google/protobuf/unittest_mset_wire_format.proto
src/google/protobuf/unittest_no_generic_services.proto
src/google/protobuf/unittest_optimize_for.proto
src/google/protobuf/unittest.proto
src/google/protobuf/unittest_import_public.proto
src/google/protobuf/unittest_import_public_lite.proto
src/google/protobuf/unittest_drop_unknown_fields.proto
src/google/protobuf/unittest_preserve_unknown_enum.proto
src/google/protobuf/map_lite_unittest.proto
src/google/protobuf/map_proto2_unittest.proto
src/google/protobuf/map_unittest.proto
# The unittest_custom_options.proto extends the messages in descriptor.proto
# so we build it in to test extending in general. The library doesn't provide
# a descriptor as it doesn't use the classes/enums.
src/google/protobuf/descriptor.proto
)
# -----------------------------------------------------------------------------
# The objc unittest specific proto files.
OBJC_TEST_PROTO_FILES=(
objectivec/Tests/any_test.proto
objectivec/Tests/map_proto2_unittest.proto
objectivec/Tests/map_unittest.proto
objectivec/Tests/unittest_cycle.proto
objectivec/Tests/unittest_deprecated_file.proto
objectivec/Tests/unittest_deprecated.proto
objectivec/Tests/unittest_deprecated_file.proto
objectivec/Tests/unittest_extension_chain_a.proto
objectivec/Tests/unittest_extension_chain_b.proto
objectivec/Tests/unittest_extension_chain_c.proto
@@ -42,30 +72,24 @@ OBJC_TEST_PROTO_FILES=(
objectivec/Tests/unittest_extension_chain_e.proto
objectivec/Tests/unittest_extension_chain_f.proto
objectivec/Tests/unittest_extension_chain_g.proto
objectivec/Tests/unittest_import_public.proto
objectivec/Tests/unittest_import.proto
objectivec/Tests/unittest_mset.proto
objectivec/Tests/unittest_objc_options.proto
objectivec/Tests/unittest_objc_startup.proto
objectivec/Tests/unittest_objc.proto
objectivec/Tests/unittest_preserve_unknown_enum.proto
objectivec/Tests/unittest_objc_startup.proto
objectivec/Tests/unittest_objc_options.proto
objectivec/Tests/unittest_runtime_proto2.proto
objectivec/Tests/unittest_runtime_proto3.proto
objectivec/Tests/unittest.proto
)
OBJC_EXTENSIONS=( .pbobjc.h .pbobjc.m )
# -----------------------------------------------------------------------------
# Ensure the output dir exists
mkdir -p "${OUTPUT_DIR}"
mkdir -p "${OUTPUT_DIR}/google/protobuf"
# -----------------------------------------------------------------------------
# Move to the top of the protobuf directories and ensure there is a protoc
# binary to use.
cd "${SRCROOT}/.."
readonly PROTOC="bazel-bin/protoc"
[[ -x "${PROTOC}" ]] || \
[[ -x src/protoc ]] || \
die "Could not find the protoc binary; make sure you have built it (objectivec/DevTools/full_mac_build.sh -h)."
# -----------------------------------------------------------------------------
@@ -73,7 +97,7 @@ RUN_PROTOC=no
# Check to if all the output files exist (in case a new one got added).
for PROTO_FILE in "${OBJC_TEST_PROTO_FILES[@]}"; do
for PROTO_FILE in "${CORE_PROTO_FILES[@]}" "${OBJC_TEST_PROTO_FILES[@]}"; do
DIR=${PROTO_FILE%/*}
BASE_NAME=${PROTO_FILE##*/}
# Drop the extension
@@ -81,7 +105,7 @@ for PROTO_FILE in "${OBJC_TEST_PROTO_FILES[@]}"; do
OBJC_NAME=$(echo "${BASE_NAME}" | awk -F _ '{for(i=1; i<=NF; i++) printf "%s", toupper(substr($i,1,1)) substr($i,2);}')
for EXT in "${OBJC_EXTENSIONS[@]}"; do
if [[ ! -f "${OUTPUT_DIR}/${DIR}/${OBJC_NAME}${EXT}" ]]; then
if [[ ! -f "${OUTPUT_DIR}/google/protobuf/${OBJC_NAME}${EXT}" ]]; then
RUN_PROTOC=yes
fi
done
@@ -94,7 +118,9 @@ if [[ "${RUN_PROTOC}" != "yes" ]] ; then
# (these patterns catch some extra stuff, but better to over sample than
# under)
readonly NewestInput=$(find \
objectivec/Tests/*.proto "${PROTOC}" \
src/google/protobuf/*.proto \
objectivec/Tests/*.proto \
src/.libs src/*.la src/protoc \
objectivec/DevTools/compile_testing_protos.sh \
-type f -print0 \
| xargs -0 stat -f "%m %N" \
@@ -124,13 +150,28 @@ find "${OUTPUT_DIR}" \
| xargs -0 rm -rf
# -----------------------------------------------------------------------------
# Generate the Objective C specific testing protos.
# Helper to invoke protoc
compile_protos() {
src/protoc \
--objc_out="${OUTPUT_DIR}/google/protobuf" \
--proto_path=src/google/protobuf/ \
--proto_path=src \
--experimental_allow_proto3_optional \
"$@"
}
"${PROTOC}" \
--objc_out="${OUTPUT_DIR}" \
--objc_opt=expected_prefixes_path=objectivec/Tests/expected_prefixes.txt \
--objc_opt=prefixes_must_be_registered=yes \
--objc_opt=require_prefixes=yes \
--proto_path=. \
--proto_path=src \
# -----------------------------------------------------------------------------
# Generate most of the proto files that exist in the C++ src tree.
# Note: there is overlap in package.Message names between some of the test
# files, so they can't be generated all at once. This works because the overlap
# isn't linked into a single binary.
for a_proto in "${CORE_PROTO_FILES[@]}" ; do
compile_protos "${a_proto}"
done
# -----------------------------------------------------------------------------
# Generate the Objective C specific testing protos.
compile_protos \
--proto_path="objectivec/Tests" \
"${OBJC_TEST_PROTO_FILES[@]}"