Remove all autotools usage (#10132)
* Bazelfying conformance tests
Adding infrastructure to "Bazelify" languages other than Java and C++
* Delete benchmarks for languages supported by other repositories
* Bazelfying benchmark tests
* Bazelfying python
Use upb's system python rule instead of branching tensorflow
* Bazelfying Ruby
* Bazelfying C#
* Bazelfying Objective-c
* Bazelfying Kokoro mac builds
* Bazelfying Kokoro linux builds
* Deleting all deprecated files from autotools cleanup
This boils down to Makefile.am and tests.sh and all of their remaining references
* Cleanup after PR reorganizing
- Enable 32 bit tests
- Move conformance tests back
- Use select statements to select alternate runtimes
- Add internal prefixes to proto library macros
* Updating READMEs to use bazel instead of autotools.
* Bazelfying Kokoro release builds
* First round of review fixes
* Second round of review fixes
* Third round of review fixes
* Filtering out conformance tests from Bazel on Windows (b/241484899)
* Add version metadata that was previously scraped from configure.ac
* fixing typo from previous fix
* Adding ruby version tests
* Bumping pinned upb version, and adding tests to python CI
diff --git a/objectivec/BUILD.bazel b/objectivec/BUILD.bazel
index c18788f..153894f 100644
--- a/objectivec/BUILD.bazel
+++ b/objectivec/BUILD.bazel
@@ -1,5 +1,6 @@
load("@rules_cc//cc:defs.bzl", "objc_library")
load("@rules_pkg//:mappings.bzl", "pkg_files", "strip_prefix")
+load("//conformance:defs.bzl", "conformance_test")
objc_library(
name = "objectivec",
@@ -90,6 +91,20 @@
visibility = ["//visibility:public"],
)
+################################################################################
+# Tests
+################################################################################
+
+conformance_test(
+ name = "conformance_test",
+ failure_list = "//conformance:failure_list_objc.txt",
+ testee = "//conformance:conformance_objc",
+)
+
+################################################################################
+# Distribution files
+################################################################################
+
pkg_files(
name = "dist_files",
srcs = glob([
diff --git a/objectivec/DevTools/compile_testing_protos.sh b/objectivec/DevTools/compile_testing_protos.sh
index 69c32f9..eb43cae 100755
--- a/objectivec/DevTools/compile_testing_protos.sh
+++ b/objectivec/DevTools/compile_testing_protos.sh
@@ -89,7 +89,8 @@
# Move to the top of the protobuf directories and ensure there is a protoc
# binary to use.
cd "${SRCROOT}/.."
-[[ -x src/protoc ]] || \
+readonly PROTOC="bazel-bin/protoc"
+[[ -x $PROTOC ]] || \
die "Could not find the protoc binary; make sure you have built it (objectivec/DevTools/full_mac_build.sh -h)."
# -----------------------------------------------------------------------------
@@ -120,7 +121,7 @@
readonly NewestInput=$(find \
src/google/protobuf/*.proto \
objectivec/Tests/*.proto \
- src/.libs src/*.la src/protoc \
+ src/.libs src/*.la $PROTOC \
objectivec/DevTools/compile_testing_protos.sh \
-type f -print0 \
| xargs -0 stat -f "%m %N" \
@@ -152,7 +153,7 @@
# -----------------------------------------------------------------------------
# Helper to invoke protoc
compile_protos() {
- src/protoc \
+ $PROTOC \
--objc_out="${OUTPUT_DIR}/google/protobuf" \
--proto_path=src/google/protobuf/ \
--proto_path=src \
diff --git a/objectivec/DevTools/full_mac_build.sh b/objectivec/DevTools/full_mac_build.sh
index 0e183f2..0af0e40 100755
--- a/objectivec/DevTools/full_mac_build.sh
+++ b/objectivec/DevTools/full_mac_build.sh
@@ -8,6 +8,7 @@
# Some base locations.
readonly ScriptDir=$(dirname "$(echo $0 | sed -e "s,^\([^/]\),$(pwd)/\1,")")
readonly ProtoRootDir="${ScriptDir}/../.."
+readonly BazelFlags="-k --test_output=streamed --macos_minimum_os=10.9"
printUsage() {
NAME=$(basename "${0}")
@@ -24,8 +25,6 @@
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.
@@ -60,25 +59,7 @@
echo "========================================================================"
}
-# 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
+NUM_JOBS=auto
DO_CLEAN=no
REGEN_DESCRIPTORS=no
CORE_ONLY=no
@@ -98,15 +79,12 @@
-c | --clean )
DO_CLEAN=yes
;;
- -a | --autogen )
- DO_AUTOGEN=yes
- ;;
-r | --regenerate-descriptors )
REGEN_DESCRIPTORS=yes
;;
-j | --jobs )
shift
- NUM_MAKE_JOBS="${1}"
+ NUM_JOBS="${1}"
;;
--core-only )
CORE_ONLY=yes
@@ -154,21 +132,9 @@
# 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"
- wrapped_make clean
+ bazel clean
if [[ "${DO_XCODE_IOS_TESTS}" == "yes" ]] ; then
XCODEBUILD_CLEAN_BASE_IOS=(
xcodebuild
@@ -212,26 +178,23 @@
if [[ "${REGEN_DESCRIPTORS}" == "yes" ]] ; then
header "Regenerating the descriptor sources."
- ./generate_descriptor_proto.sh -j "${NUM_MAKE_JOBS}"
+ ./generate_descriptor_proto.sh -j "${NUM_JOBS}"
fi
if [[ "${CORE_ONLY}" == "yes" ]] ; then
header "Building core Only"
- wrapped_make -j "${NUM_MAKE_JOBS}"
+ bazel build //:protoc //:protobuf //:protobuf_lite -j "${NUM_JOBS}" $BazelFlags
else
header "Building"
# Can't issue these together, when fully parallel, something sometimes chokes
# at random.
- wrapped_make -j "${NUM_MAKE_JOBS}" all
- wrapped_make -j "${NUM_MAKE_JOBS}" check
+ bazel test //src/... $BazelFlags
# Fire off the conformance tests also.
- cd conformance
- wrapped_make -j "${NUM_MAKE_JOBS}" test_cpp
- cd ..
+ bazel test //objectivec:conformance_test $BazelFlags
fi
# Ensure the WKT sources checked in are current.
-objectivec/generate_well_known_types.sh --check-only -j "${NUM_MAKE_JOBS}"
+objectivec/generate_well_known_types.sh --check-only -j "${NUM_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.
@@ -295,7 +258,7 @@
-disable-concurrent-destination-testing
)
;;
- 11.* | 12.* | 13.*)
+ 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
@@ -391,9 +354,7 @@
if [[ "${DO_OBJC_CONFORMANCE_TESTS}" == "yes" ]] ; then
header "Running ObjC Conformance Tests"
- cd conformance
- wrapped_make -j "${NUM_MAKE_JOBS}" test_objc
- cd ..
+ bazel test //objectivec:conformance_test $BazelFlags
fi
echo ""
diff --git a/objectivec/README.md b/objectivec/README.md
index f2c2a84..25e6b23 100644
--- a/objectivec/README.md
+++ b/objectivec/README.md
@@ -25,7 +25,7 @@
$ objectivec/DevTools/full_mac_build.sh
-This will generate the `src/protoc` binary.
+This will generate the `protoc` binary.
Building
--------
diff --git a/objectivec/generate_well_known_types.sh b/objectivec/generate_well_known_types.sh
index e6c9b04..10b2a10 100755
--- a/objectivec/generate_well_known_types.sh
+++ b/objectivec/generate_well_known_types.sh
@@ -4,7 +4,7 @@
# the protocol compiler changes.
# HINT: Flags passed to generate_well_known_types.sh will be passed directly
-# to make when building protoc. This is particularly useful for passing
+# to bazel when building protoc. This is particularly useful for passing
# -j4 to run 4 jobs simultaneously.
set -eu
@@ -30,18 +30,10 @@
exit 1
fi
-if [[ ! -e src/Makefile ]]; then
- cat >&2 << __EOF__
-Could not find src/Makefile. You must run ./configure (and perhaps
-./autogen.sh) first.
-__EOF__
- exit 1
-fi
-
# Make sure the compiler is current.
-cd src
-make $@ protoc
+bazel build $@ //:protoc
+cd src
declare -a RUNTIME_PROTO_FILES=( \
google/protobuf/any.proto \
google/protobuf/api.proto \
@@ -59,7 +51,7 @@
# Generate to a temp directory to see if they match.
TMP_DIR=$(mktemp -d)
trap "rm -rf ${TMP_DIR}" EXIT
-./protoc --objc_out="${TMP_DIR}" ${RUNTIME_PROTO_FILES[@]}
+${ProtoRootDir}/bazel-bin/protoc --objc_out="${TMP_DIR}" ${RUNTIME_PROTO_FILES[@]}
DID_COPY=0
for PROTO_FILE in "${RUNTIME_PROTO_FILES[@]}"; do