Skip to content

Commit

Permalink
Alpha 1 drop of Google's Objective C plugin and runtime support for p…
Browse files Browse the repository at this point in the history
…rotobufs.
  • Loading branch information
thomasvl committed May 6, 2015
1 parent efa666c commit 30650d8
Show file tree
Hide file tree
Showing 165 changed files with 82,460 additions and 3 deletions.
6 changes: 6 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -74,3 +74,9 @@ src/**/*.trs
# JavaBuild output.
java/target
javanano/target

# Directories created by opening the Objective C Xcode projects.
objectivec/ProtocolBuffers_OSX.xcodeproj/project.xcworkspace/xcuserdata/
objectivec/ProtocolBuffers_OSX.xcodeproj/xcuserdata/
objectivec/ProtocolBuffers_iOS.xcodeproj/project.xcworkspace/xcuserdata/
objectivec/ProtocolBuffers_iOS.xcodeproj/xcuserdata/
124 changes: 123 additions & 1 deletion Makefile.am
Original file line number Diff line number Diff line change
Expand Up @@ -197,6 +197,128 @@ javanano_EXTRA_DIST=
javanano/README.md \
javanano/pom.xml

objectivec_EXTRA_DIST= \
objectivec/DevTools/generate_descriptors_proto.sh \
objectivec/DevTools/pddm.py \
objectivec/DevTools/pddm_tests.py \
objectivec/google/protobuf/Descriptor.pbobjc.h \
objectivec/google/protobuf/Descriptor.pbobjc.m \
objectivec/google/protobuf/Duration.pbobjc.h \
objectivec/google/protobuf/Duration.pbobjc.m \
objectivec/google/protobuf/Timestamp.pbobjc.h \
objectivec/google/protobuf/Timestamp.pbobjc.m \
objectivec/GPBArray.h \
objectivec/GPBArray.m \
objectivec/GPBArray_PackagePrivate.h \
objectivec/GPBBootstrap.h \
objectivec/GPBCodedInputStream.h \
objectivec/GPBCodedInputStream.m \
objectivec/GPBCodedInputStream_PackagePrivate.h \
objectivec/GPBCodedOutputStream.h \
objectivec/GPBCodedOutputStream.m \
objectivec/GPBDescriptor.h \
objectivec/GPBDescriptor.m \
objectivec/GPBDescriptor_PackagePrivate.h \
objectivec/GPBDictionary.h \
objectivec/GPBDictionary.m \
objectivec/GPBDictionary_PackagePrivate.h \
objectivec/GPBExtensionField.h \
objectivec/GPBExtensionField.m \
objectivec/GPBExtensionField_PackagePrivate.h \
objectivec/GPBExtensionRegistry.h \
objectivec/GPBExtensionRegistry.m \
objectivec/GPBExtensionRegistry_PackagePrivate.h \
objectivec/GPBField.h \
objectivec/GPBField.m \
objectivec/GPBField_PackagePrivate.h \
objectivec/GPBMessage.h \
objectivec/GPBMessage.m \
objectivec/GPBMessage_PackagePrivate.h \
objectivec/GPBProtocolBuffers.h \
objectivec/GPBProtocolBuffers.m \
objectivec/GPBProtocolBuffers_RuntimeSupport.h \
objectivec/GPBRootObject.h \
objectivec/GPBRootObject.m \
objectivec/GPBRootObject_PackagePrivate.h \
objectivec/GPBTypes.h \
objectivec/GPBUnknownFieldSet.h \
objectivec/GPBUnknownFieldSet.m \
objectivec/GPBUnknownFieldSet_PackagePrivate.h \
objectivec/GPBUtilities.h \
objectivec/GPBUtilities.m \
objectivec/GPBUtilities_PackagePrivate.h \
objectivec/GPBWellKnownTypes.h \
objectivec/GPBWellKnownTypes.m \
objectivec/GPBWireFormat.h \
objectivec/GPBWireFormat.m \
objectivec/ProtocolBuffers_iOS.xcodeproj/project.pbxproj \
objectivec/ProtocolBuffers_iOS.xcodeproj/project.xcworkspace/contents.xcworkspacedata \
objectivec/ProtocolBuffers_iOS.xcodeproj/project.xcworkspace/xcshareddata/WorkspaceSettings.xcsettings \
objectivec/ProtocolBuffers_iOS.xcodeproj/xcshareddata/xcbaselines/8BBEA4A5147C727100C4ADB7.xcbaseline/FFE465CA-0E74-40E8-9F09-500B66B7DCB2.plist \
objectivec/ProtocolBuffers_iOS.xcodeproj/xcshareddata/xcbaselines/8BBEA4A5147C727100C4ADB7.xcbaseline/Info.plist \
objectivec/ProtocolBuffers_iOS.xcodeproj/xcshareddata/xcschemes/PerformanceTests.xcscheme \
objectivec/ProtocolBuffers_iOS.xcodeproj/xcshareddata/xcschemes/ProtocolBuffers.xcscheme \
objectivec/ProtocolBuffers_OSX.xcodeproj/project.pbxproj \
objectivec/ProtocolBuffers_OSX.xcodeproj/project.xcworkspace/contents.xcworkspacedata \
objectivec/ProtocolBuffers_OSX.xcodeproj/project.xcworkspace/xcshareddata/WorkspaceSettings.xcsettings \
objectivec/ProtocolBuffers_OSX.xcodeproj/xcshareddata/xcschemes/PerformanceTests.xcscheme \
objectivec/ProtocolBuffers_OSX.xcodeproj/xcshareddata/xcschemes/ProtocolBuffers.xcscheme \
objectivec/Tests/Filter1.txt \
objectivec/Tests/Filter2.txt \
objectivec/Tests/golden_message \
objectivec/Tests/golden_packed_fields_message \
objectivec/Tests/GPBARCUnittestProtos.m \
objectivec/Tests/GPBArrayTests.m \
objectivec/Tests/GPBCodedInputStreamTests.m \
objectivec/Tests/GPBCodedOuputStreamTests.m \
objectivec/Tests/GPBConcurrencyTests.m \
objectivec/Tests/GPBDescriptorTests.m \
objectivec/Tests/GPBDictionaryTests+Bool.m \
objectivec/Tests/GPBDictionaryTests+Int32.m \
objectivec/Tests/GPBDictionaryTests+Int64.m \
objectivec/Tests/GPBDictionaryTests+String.m \
objectivec/Tests/GPBDictionaryTests+UInt32.m \
objectivec/Tests/GPBDictionaryTests+UInt64.m \
objectivec/Tests/GPBDictionaryTests.pddm \
objectivec/Tests/GPBFilteredMessageTests.m \
objectivec/Tests/GPBMessageTests+Merge.m \
objectivec/Tests/GPBMessageTests+Runtime.m \
objectivec/Tests/GPBMessageTests+Serialization.m \
objectivec/Tests/GPBMessageTests.m \
objectivec/Tests/GPBPerfTests.m \
objectivec/Tests/GPBStringTests.m \
objectivec/Tests/GPBSwiftTests.swift \
objectivec/Tests/GPBTestUtilities.h \
objectivec/Tests/GPBTestUtilities.m \
objectivec/Tests/GPBUnittestProtos.m \
objectivec/Tests/GPBUnknownFieldSetTest.m \
objectivec/Tests/GPBUtilitiesTests.m \
objectivec/Tests/GPBWellKnownTypesTest.m \
objectivec/Tests/GPBWireFormatTests.m \
objectivec/Tests/iOSTestHarness/AppDelegate.m \
objectivec/Tests/iOSTestHarness/en.lproj/InfoPlist.strings \
objectivec/Tests/iOSTestHarness/Images.xcassets/AppIcon.appiconset/Contents.json \
objectivec/Tests/iOSTestHarness/Images.xcassets/AppIcon.appiconset/iPad6.png \
objectivec/Tests/iOSTestHarness/Images.xcassets/AppIcon.appiconset/[email protected] \
objectivec/Tests/iOSTestHarness/Images.xcassets/AppIcon.appiconset/iPad7.png \
objectivec/Tests/iOSTestHarness/Images.xcassets/AppIcon.appiconset/[email protected] \
objectivec/Tests/iOSTestHarness/Images.xcassets/AppIcon.appiconset/iPhone6.png \
objectivec/Tests/iOSTestHarness/Images.xcassets/AppIcon.appiconset/[email protected] \
objectivec/Tests/iOSTestHarness/Images.xcassets/AppIcon.appiconset/[email protected] \
objectivec/Tests/iOSTestHarness/Images.xcassets/AppIcon.appiconset/[email protected] \
objectivec/Tests/iOSTestHarness/Images.xcassets/LaunchImage.launchimage/Contents.json \
objectivec/Tests/iOSTestHarness/Info.plist \
objectivec/Tests/iOSTestHarness/LaunchScreen.xib \
objectivec/Tests/text_format_map_unittest_data.txt \
objectivec/Tests/text_format_unittest_data.txt \
objectivec/Tests/unittest_cycle.proto \
objectivec/Tests/unittest_filter.proto \
objectivec/Tests/unittest_name_mangling.proto \
objectivec/Tests/unittest_objc.proto \
objectivec/Tests/unittest_runtime_proto2.proto \
objectivec/Tests/unittest_runtime_proto3.proto \
objectivec/Tests/UnitTests-Bridging-Header.h \
objectivec/Tests/UnitTests-Info.plist

python_EXTRA_DIST= \
python/google/protobuf/internal/api_implementation.cc \
Expand Down Expand Up @@ -301,7 +423,7 @@ ruby_EXTRA_DIST= \
ruby/tests/generated_code.rb \
ruby/tests/generated_code_test.rb

all_EXTRA_DIST=$(java_EXTRA_DIST) $(javanano_EXTRA_DIST) $(python_EXTRA_DIST) $(ruby_EXTRA_DIST)
all_EXTRA_DIST=$(java_EXTRA_DIST) $(javanano_EXTRA_DIST) $(objectivec_EXTRA_DIST) $(python_EXTRA_DIST) $(ruby_EXTRA_DIST)

EXTRA_DIST = $(@DIST_LANG@_EXTRA_DIST) \
autogen.sh \
Expand Down
56 changes: 56 additions & 0 deletions objectivec/DevTools/check_version_stamps.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,56 @@
#!/bin/bash

# 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.

set -eu

readonly ScriptDir=$(dirname "$(echo $0 | sed -e "s,^\([^/]\),$(pwd)/\1,")")
readonly ProtoRootDir="${ScriptDir}/../.."

die() {
echo "Error: $1"
exit 1
}

readonly ConstantName=GOOGLE_PROTOBUF_OBJC_GEN_VERSION

# Collect version from plugin sources.

readonly PluginSrc="${ProtoRootDir}/src/google/protobuf/compiler/objectivec/objectivec_file.cc"
readonly PluginVersion=$( \
cat "${PluginSrc}" \
| sed -n -e "s:const int32_t ${ConstantName} = \([0-9]*\);:\1:p"
)

if [[ -z "${PluginVersion}" ]] ; then
die "Failed to fine ${ConstantName} in the plugin source (${PluginSrc})."
fi

# Collect version from runtime sources.

readonly RuntimeSrc="${ProtoRootDir}/objectivec/GPBBootstrap.h"
readonly RuntimeVersion=$( \
cat "${RuntimeSrc}" \
| sed -n -e "s:#define ${ConstantName} \([0-9]*\):\1:p"
)

if [[ -z "${RuntimeVersion}" ]] ; then
die "Failed to fine ${ConstantName} in the runtime source (${RuntimeSrc})."
fi

# Compare them.

if [[ "${PluginVersion}" != "${RuntimeVersion}" ]] ; then
die "Versions don't match!
Plugin: ${PluginVersion} from ${PluginSrc}
Runtime: ${RuntimeVersion} from ${RuntimeSrc}
"
fi

# Success
36 changes: 36 additions & 0 deletions objectivec/DevTools/generate_descriptors_proto.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
#!/bin/bash

# This script will generate the common descriptors needed by the Objective C
# runtime.

# HINT: Flags passed to generate_descriptor_proto.sh will be passed directly
# to make when building protoc. This is particularly useful for passing
# -j4 to run 4 jobs simultaneously.

set -eu

readonly ScriptDir=$(dirname "$(echo $0 | sed -e "s,^\([^/]\),$(pwd)/\1,")")
readonly ProtoRootDir="${ScriptDir}/../.."
readonly ProtoC="${ProtoRootDir}/src/protoc"

pushd "${ProtoRootDir}" > /dev/null

# Compiler build fails if config.h hasn't been made yet (even if configure/etc.
# have been run, so get that made first).
make $@ config.h

# Make sure the compiler is current.
cd src
make $@ protoc

# These really should only be run when the inputs or compiler are newer than
# the outputs.

# Needed by the runtime.
./protoc --objc_out="${ProtoRootDir}/objectivec" google/protobuf/descriptor.proto

# Well known types that the library provides helpers for.
./protoc --objc_out="${ProtoRootDir}/objectivec" google/protobuf/timestamp.proto
./protoc --objc_out="${ProtoRootDir}/objectivec" google/protobuf/duration.proto

popd > /dev/null
Loading

0 comments on commit 30650d8

Please sign in to comment.