aboutsummaryrefslogtreecommitdiffhomepage
path: root/objectivec
diff options
context:
space:
mode:
authorGravatar Thomas Van Lenten <thomasvl@google.com>2016-04-19 17:57:17 -0400
committerGravatar Thomas Van Lenten <thomasvl@google.com>2016-04-20 10:14:18 -0400
commit511f28b73a066f4e7c5b4eeedc5b465e81451fc4 (patch)
tree05d2cb2dfdb6553553a63b123f4635d5aee50f38 /objectivec
parent52825bf91a4676dd7745bd37df69a9452fa75434 (diff)
ObjC support for failing the build in the generated WKTs are out of date
- Always generated into a temp directory so we can see if things changed. - Add a flag to control exiting with error when stale vs updating. This should let the continuous builds error out when ObjC needs to have the checked in sources updated.
Diffstat (limited to 'objectivec')
-rwxr-xr-xobjectivec/DevTools/full_mac_build.sh40
-rwxr-xr-xobjectivec/generate_well_known_types.sh29
2 files changed, 38 insertions, 31 deletions
diff --git a/objectivec/DevTools/full_mac_build.sh b/objectivec/DevTools/full_mac_build.sh
index 4d4930dc..ff51d9f0 100755
--- a/objectivec/DevTools/full_mac_build.sh
+++ b/objectivec/DevTools/full_mac_build.sh
@@ -26,8 +26,9 @@ OPTIONS:
Issue a clean before the normal build.
-a, --autogen
Start by rerunning autogen & configure.
- -r, --regenerate-cpp-descriptors
- The descriptor.proto is checked in generated, cause it to regenerate.
+ -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
@@ -71,7 +72,7 @@ fi
DO_AUTOGEN=no
DO_CLEAN=no
-REGEN_CPP_DESCRIPTORS=no
+REGEN_DESCRIPTORS=no
CORE_ONLY=no
DO_XCODE_IOS_TESTS=yes
DO_XCODE_OSX_TESTS=yes
@@ -88,8 +89,8 @@ while [[ $# != 0 ]]; do
-a | --autogen )
DO_AUTOGEN=yes
;;
- -r | --regenerate-cpp-descriptors )
- REGEN_CPP_DESCRIPTORS=yes
+ -r | --regenerate-descriptors )
+ REGEN_DESCRIPTORS=yes
;;
-j | --jobs )
shift
@@ -164,8 +165,8 @@ if [[ "${DO_CLEAN}" == "yes" ]] ; then
fi
fi
-if [[ "${REGEN_CPP_DESCRIPTORS}" == "yes" ]] ; then
- header "Regenerating the C++ descriptor sources."
+if [[ "${REGEN_DESCRIPTORS}" == "yes" ]] ; then
+ header "Regenerating the descriptor sources."
./generate_descriptor_proto.sh -j "${NUM_MAKE_JOBS}"
fi
@@ -184,29 +185,8 @@ else
cd ..
fi
-header "Ensuring the ObjC descriptors are current."
-# Find the newest input file (protos, compiler, and the generator script).
-# (these patterns catch some extra stuff, but better to over sample than under)
-readonly NewestInput=$(find \
- src/google/protobuf/*.proto \
- src/.libs src/*.la src/protoc \
- objectivec/generate_well_known_types.sh \
- -type f -print0 \
- | xargs -0 stat -f "%m %N" \
- | sort -n | tail -n1 | cut -f2- -d" ")
-# Find the oldest output file.
-readonly OldestOutput=$(find \
- "${ProtoRootDir}/objectivec/google" \
- -type f -print0 \
- | xargs -0 stat -f "%m %N" \
- | sort -n -r | tail -n1 | cut -f2- -d" ")
-# If the newest input is newer than the oldest output, regenerate.
-if [[ "${NewestInput}" -nt "${OldestOutput}" ]] ; then
- echo ">> Newest input is newer than oldest output, regenerating."
- objectivec/generate_well_known_types.sh -j "${NUM_MAKE_JOBS}"
-else
- echo ">> Newest input is older than oldest output, no need to regenerating."
-fi
+# Ensure the WKT sources checked in are current.
+objectivec/generate_well_known_types.sh --check-only -j "${NUM_MAKE_JOBS}"
header "Checking on the ObjC Runtime Code"
objectivec/DevTools/pddm_tests.py
diff --git a/objectivec/generate_well_known_types.sh b/objectivec/generate_well_known_types.sh
index be9b38a5..73be50ff 100755
--- a/objectivec/generate_well_known_types.sh
+++ b/objectivec/generate_well_known_types.sh
@@ -12,6 +12,13 @@ set -eu
readonly ScriptDir=$(dirname "$(echo $0 | sed -e "s,^\([^/]\),$(pwd)/\1,")")
readonly ProtoRootDir="${ScriptDir}/.."
+# Flag for continuous integration to check that everything is current.
+CHECK_ONLY=0
+if [[ $# -ge 1 && ( "$1" == "--check-only" ) ]] ; then
+ CHECK_ONLY=1
+ shift
+fi
+
pushd "${ProtoRootDir}" > /dev/null
if test ! -e src/google/protobuf/stubs/common.h; then
@@ -46,4 +53,24 @@ declare -a RUNTIME_PROTO_FILES=( \
google/protobuf/type.proto \
google/protobuf/wrappers.proto)
-./protoc --objc_out="${ProtoRootDir}/objectivec" ${RUNTIME_PROTO_FILES[@]}
+# 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[@]}
+set +e
+diff -r "${TMP_DIR}/google" "${ProtoRootDir}/objectivec/google" > /dev/null
+if [[ $? -eq 0 ]] ; then
+ echo "Generated source for WellKnownTypes is current."
+ exit 0
+fi
+set -e
+
+# If check only mode, error out.
+if [[ "${CHECK_ONLY}" == 1 ]] ; then
+ echo "ERROR: The WKTs need to be regenerated! Run $0"
+ exit 1
+fi
+
+# Copy them over.
+echo "Copying over updated WellKnownType sources."
+cp -r "${TMP_DIR}/google/" "${ProtoRootDir}/objectivec/google/"