[ObjC] Move the version check out into a sh_test.

Since the sources can't reference each other, this is what helps keep them in
sync. Move it out to be a stand alone test in bazel instead of having it wired
into the Xcode projects.

PiperOrigin-RevId: 508429454
pull/11885/head
Protobuf Team Bot 2 years ago committed by Copybara-Service
parent 6bb44d98b5
commit 2fed1e3e83
  1. 12
      objectivec/BUILD.bazel
  2. 21
      objectivec/DevTools/check_version_stamps.sh
  3. 20
      objectivec/ProtocolBuffers_OSX.xcodeproj/project.pbxproj
  4. 20
      objectivec/ProtocolBuffers_iOS.xcodeproj/project.pbxproj
  5. 20
      objectivec/ProtocolBuffers_tvOS.xcodeproj/project.pbxproj
  6. 7
      src/google/protobuf/compiler/objectivec/BUILD.bazel

@ -101,6 +101,18 @@ conformance_test(
testee = "//conformance:conformance_objc",
)
# -------------------------------------------------------------------
# Current Version Check between Generator and Runtime Sources
sh_test(
name = "check_version_stamps",
size = "small",
srcs = ["DevTools/check_version_stamps.sh"],
data = [
"GPBBootstrap.h",
"//src/google/protobuf/compiler/objectivec:file.cc",
],
)
################################################################################
# Distribution files
################################################################################

@ -3,21 +3,24 @@
# This script checks that the runtime version number constant in the compiler
# source and in the runtime source is the same.
#
# A distro can be made of the protobuf sources with only a subset of the
# languages, so if the compiler depended on the Objective C runtime, those
# builds would break. At the same time, we don't want the runtime source
# depending on the compiler sources; so two copies of the constant are needed.
readonly ScriptDir=$(dirname "$(echo $0 | sed -e "s,^\([^/]\),$(pwd)/\1,")")
readonly ProtoRootDir="${ScriptDir}/../.."
# We don't really want the generator sources directly referencing the runtime
# or the reverse, so they both have the same constant defined, and this script
# is used in a test to ensure the values stay in sync.
die() {
echo "Error: $1"
exit 1
}
readonly GeneratorSrc="${ProtoRootDir}/src/google/protobuf/compiler/objectivec/file.cc"
readonly RuntimeSrc="${ProtoRootDir}/objectivec/GPBBootstrap.h"
readonly GeneratorSrc="src/google/protobuf/compiler/objectivec/file.cc"
readonly RuntimeSrc="objectivec/GPBBootstrap.h"
if [[ ! -e "${GeneratorSrc}" ]] ; then
die "Failed to find generator file: ${GeneratorSrc}"
fi
if [[ ! -e "${RuntimeSrc}" ]] ; then
die "Failed to find runtime file: ${RuntimeSrc}"
fi
check_constant() {
local ConstantName="$1"

@ -610,7 +610,6 @@
isa = PBXNativeTarget;
buildConfigurationList = 8BBEA4BA147C728600C4ADB7 /* Build configuration list for PBXNativeTarget "UnitTests" */;
buildPhases = (
F4B62A781AF91F6000AFCEDC /* Script: Check Runtime Stamps */,
8BBEA4A1147C727100C4ADB7 /* Resources */,
8BBEA4A2147C727100C4ADB7 /* Sources */,
8BBEA4A3147C727100C4ADB7 /* Frameworks */,
@ -697,25 +696,6 @@
};
/* End PBXResourcesBuildPhase section */
/* Begin PBXShellScriptBuildPhase section */
F4B62A781AF91F6000AFCEDC /* Script: Check Runtime Stamps */ = {
isa = PBXShellScriptBuildPhase;
alwaysOutOfDate = 1;
buildActionMask = 2147483647;
files = (
);
inputPaths = (
);
name = "Script: Check Runtime Stamps";
outputPaths = (
);
runOnlyForDeploymentPostprocessing = 0;
shellPath = /bin/sh;
shellScript = "set -eu\nexec \"${SOURCE_ROOT}/DevTools/check_version_stamps.sh\"\n";
showEnvVarsInLog = 0;
};
/* End PBXShellScriptBuildPhase section */
/* Begin PBXSourcesBuildPhase section */
7461B52B0F94FAF800A0C422 /* Sources */ = {
isa = PBXSourcesBuildPhase;

@ -617,7 +617,6 @@
isa = PBXNativeTarget;
buildConfigurationList = 8BBEA4BA147C728600C4ADB7 /* Build configuration list for PBXNativeTarget "UnitTests" */;
buildPhases = (
F4B62A791AF91F7500AFCEDC /* Script: Check Runtime Stamps */,
8BBEA4A1147C727100C4ADB7 /* Resources */,
8BBEA4A2147C727100C4ADB7 /* Sources */,
8BBEA4A3147C727100C4ADB7 /* Frameworks */,
@ -704,25 +703,6 @@
};
/* End PBXResourcesBuildPhase section */
/* Begin PBXShellScriptBuildPhase section */
F4B62A791AF91F7500AFCEDC /* Script: Check Runtime Stamps */ = {
isa = PBXShellScriptBuildPhase;
alwaysOutOfDate = 1;
buildActionMask = 2147483647;
files = (
);
inputPaths = (
);
name = "Script: Check Runtime Stamps";
outputPaths = (
);
runOnlyForDeploymentPostprocessing = 0;
shellPath = /bin/sh;
shellScript = "set -eu\nexec \"${SOURCE_ROOT}/DevTools/check_version_stamps.sh\"\n";
showEnvVarsInLog = 0;
};
/* End PBXShellScriptBuildPhase section */
/* Begin PBXSourcesBuildPhase section */
7461B52B0F94FAF800A0C422 /* Sources */ = {
isa = PBXSourcesBuildPhase;

@ -617,7 +617,6 @@
isa = PBXNativeTarget;
buildConfigurationList = 8BBEA4BA147C728600C4ADB7 /* Build configuration list for PBXNativeTarget "UnitTests" */;
buildPhases = (
F4B62A791AF91F7500AFCEDC /* Script: Check Runtime Stamps */,
8BBEA4A1147C727100C4ADB7 /* Resources */,
8BBEA4A2147C727100C4ADB7 /* Sources */,
8BBEA4A3147C727100C4ADB7 /* Frameworks */,
@ -704,25 +703,6 @@
};
/* End PBXResourcesBuildPhase section */
/* Begin PBXShellScriptBuildPhase section */
F4B62A791AF91F7500AFCEDC /* Script: Check Runtime Stamps */ = {
isa = PBXShellScriptBuildPhase;
alwaysOutOfDate = 1;
buildActionMask = 2147483647;
files = (
);
inputPaths = (
);
name = "Script: Check Runtime Stamps";
outputPaths = (
);
runOnlyForDeploymentPostprocessing = 0;
shellPath = /bin/sh;
shellScript = "set -eu\nexec \"${SOURCE_ROOT}/DevTools/check_version_stamps.sh\"\n";
showEnvVarsInLog = 0;
};
/* End PBXShellScriptBuildPhase section */
/* Begin PBXSourcesBuildPhase section */
7461B52B0F94FAF800A0C422 /* Sources */ = {
isa = PBXSourcesBuildPhase;

@ -133,6 +133,13 @@ cc_test(
],
)
# Exposed only for the version check to ensure the ObjC Runtime and Generator
# are in sync.
exports_files(
["file.cc"],
visibility = ["//objectivec:__pkg__"],
)
################################################################################
# Distribution packaging
################################################################################

Loading…
Cancel
Save