ADD: added new version of protobuf
This commit is contained in:
@@ -16,7 +16,7 @@ die() {
|
||||
exit 1
|
||||
}
|
||||
|
||||
readonly GeneratorSrc="${ProtoRootDir}/src/google/protobuf/compiler/objectivec/file.cc"
|
||||
readonly GeneratorSrc="${ProtoRootDir}/src/google/protobuf/compiler/objectivec/objectivec_file.cc"
|
||||
readonly RuntimeSrc="${ProtoRootDir}/objectivec/GPBBootstrap.h"
|
||||
|
||||
check_constant() {
|
||||
|
||||
@@ -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[@]}"
|
||||
|
||||
@@ -8,11 +8,6 @@ set -eu
|
||||
# Some base locations.
|
||||
readonly ScriptDir=$(dirname "$(echo $0 | sed -e "s,^\([^/]\),$(pwd)/\1,")")
|
||||
readonly ProtoRootDir="${ScriptDir}/../.."
|
||||
readonly BazelFlags="--announce_rc --macos_minimum_os=10.9 \
|
||||
$(${ScriptDir}/../../kokoro/common/bazel_flags.sh)"
|
||||
|
||||
# Invoke with BAZEL=bazelisk to use that instead.
|
||||
readonly BazelBin="${BAZEL:=bazel}"
|
||||
|
||||
printUsage() {
|
||||
NAME=$(basename "${0}")
|
||||
@@ -29,9 +24,13 @@ OPTIONS:
|
||||
Show this message
|
||||
-c, --clean
|
||||
Issue a clean before the normal build.
|
||||
-a, --autogen
|
||||
Start by rerunning autogen & configure.
|
||||
-r, --regenerate-descriptors
|
||||
Run generate_descriptor_proto.sh to regenerate all the checked in
|
||||
proto sources.
|
||||
-j #, --jobs #
|
||||
Force the number of parallel jobs (useful for debugging build issues).
|
||||
--core-only
|
||||
Skip some of the core protobuf build/checks to shorten the build time.
|
||||
--skip-xcode
|
||||
@@ -61,7 +60,25 @@ header() {
|
||||
echo "========================================================================"
|
||||
}
|
||||
|
||||
BAZEL=bazel
|
||||
# Thanks to libtool, builds can fail in odd ways and since it eats some output
|
||||
# it can be hard to spot, so force error output if make exits with a non zero.
|
||||
wrapped_make() {
|
||||
set +e # Don't stop if the command fails.
|
||||
make $*
|
||||
MAKE_EXIT_STATUS=$?
|
||||
if [ ${MAKE_EXIT_STATUS} -ne 0 ]; then
|
||||
echo "Error: 'make $*' exited with status ${MAKE_EXIT_STATUS}"
|
||||
exit ${MAKE_EXIT_STATUS}
|
||||
fi
|
||||
set -e
|
||||
}
|
||||
|
||||
NUM_MAKE_JOBS=$(/usr/sbin/sysctl -n hw.ncpu)
|
||||
if [[ "${NUM_MAKE_JOBS}" -lt 2 ]] ; then
|
||||
NUM_MAKE_JOBS=2
|
||||
fi
|
||||
|
||||
DO_AUTOGEN=no
|
||||
DO_CLEAN=no
|
||||
REGEN_DESCRIPTORS=no
|
||||
CORE_ONLY=no
|
||||
@@ -81,9 +98,16 @@ while [[ $# != 0 ]]; do
|
||||
-c | --clean )
|
||||
DO_CLEAN=yes
|
||||
;;
|
||||
-a | --autogen )
|
||||
DO_AUTOGEN=yes
|
||||
;;
|
||||
-r | --regenerate-descriptors )
|
||||
REGEN_DESCRIPTORS=yes
|
||||
;;
|
||||
-j | --jobs )
|
||||
shift
|
||||
NUM_MAKE_JOBS="${1}"
|
||||
;;
|
||||
--core-only )
|
||||
CORE_ONLY=yes
|
||||
;;
|
||||
@@ -130,9 +154,21 @@ done
|
||||
# Into the proto dir.
|
||||
cd "${ProtoRootDir}"
|
||||
|
||||
# if no Makefile, force the autogen.
|
||||
if [[ ! -f Makefile ]] ; then
|
||||
DO_AUTOGEN=yes
|
||||
fi
|
||||
|
||||
if [[ "${DO_AUTOGEN}" == "yes" ]] ; then
|
||||
header "Running autogen & configure"
|
||||
./autogen.sh
|
||||
./configure \
|
||||
CPPFLAGS="-mmacosx-version-min=10.9 -Wunused-const-variable -Wunused-function"
|
||||
fi
|
||||
|
||||
if [[ "${DO_CLEAN}" == "yes" ]] ; then
|
||||
header "Cleaning"
|
||||
"${BazelBin}" clean
|
||||
wrapped_make clean
|
||||
if [[ "${DO_XCODE_IOS_TESTS}" == "yes" ]] ; then
|
||||
XCODEBUILD_CLEAN_BASE_IOS=(
|
||||
xcodebuild
|
||||
@@ -176,23 +212,26 @@ fi
|
||||
|
||||
if [[ "${REGEN_DESCRIPTORS}" == "yes" ]] ; then
|
||||
header "Regenerating the descriptor sources."
|
||||
./generate_descriptor_proto.sh
|
||||
./generate_descriptor_proto.sh -j "${NUM_MAKE_JOBS}"
|
||||
fi
|
||||
|
||||
if [[ "${CORE_ONLY}" == "yes" ]] ; then
|
||||
header "Building core Only"
|
||||
"${BazelBin}" build //:protoc //:protobuf //:protobuf_lite $BazelFlags
|
||||
wrapped_make -j "${NUM_MAKE_JOBS}"
|
||||
else
|
||||
header "Building"
|
||||
# Can't issue these together, when fully parallel, something sometimes chokes
|
||||
# at random.
|
||||
"${BazelBin}" test //src/... $BazelFlags
|
||||
wrapped_make -j "${NUM_MAKE_JOBS}" all
|
||||
wrapped_make -j "${NUM_MAKE_JOBS}" check
|
||||
# Fire off the conformance tests also.
|
||||
"${BazelBin}" test //objectivec:conformance_test $BazelFlags
|
||||
cd conformance
|
||||
wrapped_make -j "${NUM_MAKE_JOBS}" test_cpp
|
||||
cd ..
|
||||
fi
|
||||
|
||||
# Ensure the WKT sources checked in are current.
|
||||
BAZEL="${BazelBin}" objectivec/generate_well_known_types.sh --check-only $BazelFlags
|
||||
objectivec/generate_well_known_types.sh --check-only -j "${NUM_MAKE_JOBS}"
|
||||
|
||||
header "Checking on the ObjC Runtime Code"
|
||||
# Some of the kokoro machines don't have python3 yet, so fall back to python if need be.
|
||||
@@ -225,11 +264,38 @@ if [[ "${DO_XCODE_IOS_TESTS}" == "yes" ]] ; then
|
||||
# just pick a mix of OS Versions and 32/64 bit.
|
||||
# NOTE: Different Xcode have different simulated hardware/os support.
|
||||
case "${XCODE_VERSION}" in
|
||||
[6-9].* | 1[0-2].* )
|
||||
echo "ERROR: Xcode 13.3.1 or higher is required." 1>&2
|
||||
[6-8].* )
|
||||
echo "ERROR: The unittests include Swift code that is now Swift 4.0." 1>&2
|
||||
echo "ERROR: Xcode 9.0 or higher is required to build the test suite, but the library works with Xcode 7.x." 1>&2
|
||||
exit 11
|
||||
;;
|
||||
13.* | 14.*)
|
||||
9.[0-2]* )
|
||||
XCODEBUILD_TEST_BASE_IOS+=(
|
||||
-destination "platform=iOS Simulator,name=iPhone 4s,OS=8.1" # 32bit
|
||||
-destination "platform=iOS Simulator,name=iPhone 7,OS=latest" # 64bit
|
||||
# 9.0-9.2 all seem to often fail running destinations in parallel
|
||||
-disable-concurrent-testing
|
||||
)
|
||||
;;
|
||||
9.[3-4]* )
|
||||
XCODEBUILD_TEST_BASE_IOS+=(
|
||||
# Xcode 9.3 chokes targeting iOS 8.x - http://www.openradar.me/39335367
|
||||
-destination "platform=iOS Simulator,name=iPhone 4s,OS=9.0" # 32bit
|
||||
-destination "platform=iOS Simulator,name=iPhone 7,OS=latest" # 64bit
|
||||
# 9.3 also seems to often fail running destinations in parallel
|
||||
-disable-concurrent-testing
|
||||
)
|
||||
;;
|
||||
10.*)
|
||||
XCODEBUILD_TEST_BASE_IOS+=(
|
||||
-destination "platform=iOS Simulator,name=iPhone 4s,OS=8.1" # 32bit
|
||||
-destination "platform=iOS Simulator,name=iPhone 7,OS=latest" # 64bit
|
||||
# 10.x also seems to often fail running destinations in parallel (with
|
||||
# 32bit one include at least)
|
||||
-disable-concurrent-destination-testing
|
||||
)
|
||||
;;
|
||||
11.* | 12.* | 13.* | 14.*)
|
||||
# Dropped 32bit as Apple doesn't seem support the simulators either.
|
||||
XCODEBUILD_TEST_BASE_IOS+=(
|
||||
-destination "platform=iOS Simulator,name=iPhone 8,OS=latest" # 64bit
|
||||
@@ -266,8 +332,9 @@ if [[ "${DO_XCODE_OSX_TESTS}" == "yes" ]] ; then
|
||||
XCODEBUILD_TEST_BASE_OSX+=( -quiet )
|
||||
fi
|
||||
case "${XCODE_VERSION}" in
|
||||
[6-9].* | 1[0-2].* )
|
||||
echo "ERROR: Xcode 13.3.1 or higher is required." 1>&2
|
||||
[6-8].* )
|
||||
echo "ERROR: The unittests include Swift code that is now Swift 4.0." 1>&2
|
||||
echo "ERROR: Xcode 9.0 or higher is required to build the test suite, but the library works with Xcode 7.x." 1>&2
|
||||
exit 11
|
||||
;;
|
||||
esac
|
||||
@@ -287,10 +354,15 @@ if [[ "${DO_XCODE_TVOS_TESTS}" == "yes" ]] ; then
|
||||
-scheme ProtocolBuffers
|
||||
)
|
||||
case "${XCODE_VERSION}" in
|
||||
[6-9].* | 1[0-2].* )
|
||||
echo "ERROR: Xcode 13.3.1 or higher is required." 1>&2
|
||||
[6-9].* )
|
||||
echo "ERROR: Xcode 10.0 or higher is required to build the test suite." 1>&2
|
||||
exit 11
|
||||
;;
|
||||
10.* | 11.* | 12.*)
|
||||
XCODEBUILD_TEST_BASE_TVOS+=(
|
||||
-destination "platform=tvOS Simulator,name=Apple TV 4K,OS=latest"
|
||||
)
|
||||
;;
|
||||
13.* | 14.*)
|
||||
XCODEBUILD_TEST_BASE_TVOS+=(
|
||||
-destination "platform=tvOS Simulator,name=Apple TV 4K (2nd generation),OS=latest"
|
||||
@@ -319,7 +391,9 @@ fi
|
||||
|
||||
if [[ "${DO_OBJC_CONFORMANCE_TESTS}" == "yes" ]] ; then
|
||||
header "Running ObjC Conformance Tests"
|
||||
"${BazelBin}" test //objectivec:conformance_test $BazelFlags
|
||||
cd conformance
|
||||
wrapped_make -j "${NUM_MAKE_JOBS}" test_objc
|
||||
cd ..
|
||||
fi
|
||||
|
||||
echo ""
|
||||
|
||||
@@ -485,13 +485,14 @@ class SourceFile(object):
|
||||
if self._macro_collection:
|
||||
# Always add a blank line, seems to read better. (If need be, add an
|
||||
# option to the EXPAND to indicate if this should be done.)
|
||||
result.extend([_GENERATED_CODE_LINE, ''])
|
||||
result.extend([_GENERATED_CODE_LINE, '// clang-format off', ''])
|
||||
macro = line[directive_len:].strip()
|
||||
try:
|
||||
expand_result = self._macro_collection.Expand(macro)
|
||||
# Since expansions are line oriented, strip trailing whitespace
|
||||
# from the lines.
|
||||
lines = [x.rstrip() for x in expand_result.split('\n')]
|
||||
lines.append('// clang-format on')
|
||||
result.append('\n'.join(lines))
|
||||
except PDDMError as e:
|
||||
raise PDDMError('%s\n...while expanding "%s" from the section'
|
||||
|
||||
@@ -418,18 +418,24 @@ baz
|
||||
foo
|
||||
//%PDDM-EXPAND mumble(abc)
|
||||
// This block of code is generated, do not edit it directly.
|
||||
// clang-format off
|
||||
|
||||
abc: doAbc(int abc);
|
||||
// clang-format on
|
||||
//%PDDM-EXPAND-END mumble(abc)
|
||||
bar
|
||||
//%PDDM-EXPAND mumble(def)
|
||||
// This block of code is generated, do not edit it directly.
|
||||
// clang-format off
|
||||
|
||||
def: doDef(int def);
|
||||
// clang-format on
|
||||
//%PDDM-EXPAND mumble(ghi)
|
||||
// This block of code is generated, do not edit it directly.
|
||||
// clang-format off
|
||||
|
||||
ghi: doGhi(int ghi);
|
||||
// clang-format on
|
||||
//%PDDM-EXPAND-END (2 expansions)
|
||||
baz
|
||||
//%PDDM-DEFINE mumble(a_)
|
||||
|
||||
Reference in New Issue
Block a user