Skip to content

Commit 30650d8

Browse files
committed
Alpha 1 drop of Google's Objective C plugin and runtime support for protobufs.
1 parent efa666c commit 30650d8

File tree

165 files changed

+82460
-3
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

165 files changed

+82460
-3
lines changed

.gitignore

+6
Original file line numberDiff line numberDiff line change
@@ -74,3 +74,9 @@ src/**/*.trs
7474
# JavaBuild output.
7575
java/target
7676
javanano/target
77+
78+
# Directories created by opening the Objective C Xcode projects.
79+
objectivec/ProtocolBuffers_OSX.xcodeproj/project.xcworkspace/xcuserdata/
80+
objectivec/ProtocolBuffers_OSX.xcodeproj/xcuserdata/
81+
objectivec/ProtocolBuffers_iOS.xcodeproj/project.xcworkspace/xcuserdata/
82+
objectivec/ProtocolBuffers_iOS.xcodeproj/xcuserdata/

Makefile.am

+123-1
Original file line numberDiff line numberDiff line change
@@ -197,6 +197,128 @@ javanano_EXTRA_DIST=
197197
javanano/README.md \
198198
javanano/pom.xml
199199

200+
objectivec_EXTRA_DIST= \
201+
objectivec/DevTools/generate_descriptors_proto.sh \
202+
objectivec/DevTools/pddm.py \
203+
objectivec/DevTools/pddm_tests.py \
204+
objectivec/google/protobuf/Descriptor.pbobjc.h \
205+
objectivec/google/protobuf/Descriptor.pbobjc.m \
206+
objectivec/google/protobuf/Duration.pbobjc.h \
207+
objectivec/google/protobuf/Duration.pbobjc.m \
208+
objectivec/google/protobuf/Timestamp.pbobjc.h \
209+
objectivec/google/protobuf/Timestamp.pbobjc.m \
210+
objectivec/GPBArray.h \
211+
objectivec/GPBArray.m \
212+
objectivec/GPBArray_PackagePrivate.h \
213+
objectivec/GPBBootstrap.h \
214+
objectivec/GPBCodedInputStream.h \
215+
objectivec/GPBCodedInputStream.m \
216+
objectivec/GPBCodedInputStream_PackagePrivate.h \
217+
objectivec/GPBCodedOutputStream.h \
218+
objectivec/GPBCodedOutputStream.m \
219+
objectivec/GPBDescriptor.h \
220+
objectivec/GPBDescriptor.m \
221+
objectivec/GPBDescriptor_PackagePrivate.h \
222+
objectivec/GPBDictionary.h \
223+
objectivec/GPBDictionary.m \
224+
objectivec/GPBDictionary_PackagePrivate.h \
225+
objectivec/GPBExtensionField.h \
226+
objectivec/GPBExtensionField.m \
227+
objectivec/GPBExtensionField_PackagePrivate.h \
228+
objectivec/GPBExtensionRegistry.h \
229+
objectivec/GPBExtensionRegistry.m \
230+
objectivec/GPBExtensionRegistry_PackagePrivate.h \
231+
objectivec/GPBField.h \
232+
objectivec/GPBField.m \
233+
objectivec/GPBField_PackagePrivate.h \
234+
objectivec/GPBMessage.h \
235+
objectivec/GPBMessage.m \
236+
objectivec/GPBMessage_PackagePrivate.h \
237+
objectivec/GPBProtocolBuffers.h \
238+
objectivec/GPBProtocolBuffers.m \
239+
objectivec/GPBProtocolBuffers_RuntimeSupport.h \
240+
objectivec/GPBRootObject.h \
241+
objectivec/GPBRootObject.m \
242+
objectivec/GPBRootObject_PackagePrivate.h \
243+
objectivec/GPBTypes.h \
244+
objectivec/GPBUnknownFieldSet.h \
245+
objectivec/GPBUnknownFieldSet.m \
246+
objectivec/GPBUnknownFieldSet_PackagePrivate.h \
247+
objectivec/GPBUtilities.h \
248+
objectivec/GPBUtilities.m \
249+
objectivec/GPBUtilities_PackagePrivate.h \
250+
objectivec/GPBWellKnownTypes.h \
251+
objectivec/GPBWellKnownTypes.m \
252+
objectivec/GPBWireFormat.h \
253+
objectivec/GPBWireFormat.m \
254+
objectivec/ProtocolBuffers_iOS.xcodeproj/project.pbxproj \
255+
objectivec/ProtocolBuffers_iOS.xcodeproj/project.xcworkspace/contents.xcworkspacedata \
256+
objectivec/ProtocolBuffers_iOS.xcodeproj/project.xcworkspace/xcshareddata/WorkspaceSettings.xcsettings \
257+
objectivec/ProtocolBuffers_iOS.xcodeproj/xcshareddata/xcbaselines/8BBEA4A5147C727100C4ADB7.xcbaseline/FFE465CA-0E74-40E8-9F09-500B66B7DCB2.plist \
258+
objectivec/ProtocolBuffers_iOS.xcodeproj/xcshareddata/xcbaselines/8BBEA4A5147C727100C4ADB7.xcbaseline/Info.plist \
259+
objectivec/ProtocolBuffers_iOS.xcodeproj/xcshareddata/xcschemes/PerformanceTests.xcscheme \
260+
objectivec/ProtocolBuffers_iOS.xcodeproj/xcshareddata/xcschemes/ProtocolBuffers.xcscheme \
261+
objectivec/ProtocolBuffers_OSX.xcodeproj/project.pbxproj \
262+
objectivec/ProtocolBuffers_OSX.xcodeproj/project.xcworkspace/contents.xcworkspacedata \
263+
objectivec/ProtocolBuffers_OSX.xcodeproj/project.xcworkspace/xcshareddata/WorkspaceSettings.xcsettings \
264+
objectivec/ProtocolBuffers_OSX.xcodeproj/xcshareddata/xcschemes/PerformanceTests.xcscheme \
265+
objectivec/ProtocolBuffers_OSX.xcodeproj/xcshareddata/xcschemes/ProtocolBuffers.xcscheme \
266+
objectivec/Tests/Filter1.txt \
267+
objectivec/Tests/Filter2.txt \
268+
objectivec/Tests/golden_message \
269+
objectivec/Tests/golden_packed_fields_message \
270+
objectivec/Tests/GPBARCUnittestProtos.m \
271+
objectivec/Tests/GPBArrayTests.m \
272+
objectivec/Tests/GPBCodedInputStreamTests.m \
273+
objectivec/Tests/GPBCodedOuputStreamTests.m \
274+
objectivec/Tests/GPBConcurrencyTests.m \
275+
objectivec/Tests/GPBDescriptorTests.m \
276+
objectivec/Tests/GPBDictionaryTests+Bool.m \
277+
objectivec/Tests/GPBDictionaryTests+Int32.m \
278+
objectivec/Tests/GPBDictionaryTests+Int64.m \
279+
objectivec/Tests/GPBDictionaryTests+String.m \
280+
objectivec/Tests/GPBDictionaryTests+UInt32.m \
281+
objectivec/Tests/GPBDictionaryTests+UInt64.m \
282+
objectivec/Tests/GPBDictionaryTests.pddm \
283+
objectivec/Tests/GPBFilteredMessageTests.m \
284+
objectivec/Tests/GPBMessageTests+Merge.m \
285+
objectivec/Tests/GPBMessageTests+Runtime.m \
286+
objectivec/Tests/GPBMessageTests+Serialization.m \
287+
objectivec/Tests/GPBMessageTests.m \
288+
objectivec/Tests/GPBPerfTests.m \
289+
objectivec/Tests/GPBStringTests.m \
290+
objectivec/Tests/GPBSwiftTests.swift \
291+
objectivec/Tests/GPBTestUtilities.h \
292+
objectivec/Tests/GPBTestUtilities.m \
293+
objectivec/Tests/GPBUnittestProtos.m \
294+
objectivec/Tests/GPBUnknownFieldSetTest.m \
295+
objectivec/Tests/GPBUtilitiesTests.m \
296+
objectivec/Tests/GPBWellKnownTypesTest.m \
297+
objectivec/Tests/GPBWireFormatTests.m \
298+
objectivec/Tests/iOSTestHarness/AppDelegate.m \
299+
objectivec/Tests/iOSTestHarness/en.lproj/InfoPlist.strings \
300+
objectivec/Tests/iOSTestHarness/Images.xcassets/AppIcon.appiconset/Contents.json \
301+
objectivec/Tests/iOSTestHarness/Images.xcassets/AppIcon.appiconset/iPad6.png \
302+
objectivec/Tests/iOSTestHarness/Images.xcassets/AppIcon.appiconset/[email protected] \
303+
objectivec/Tests/iOSTestHarness/Images.xcassets/AppIcon.appiconset/iPad7.png \
304+
objectivec/Tests/iOSTestHarness/Images.xcassets/AppIcon.appiconset/[email protected] \
305+
objectivec/Tests/iOSTestHarness/Images.xcassets/AppIcon.appiconset/iPhone6.png \
306+
objectivec/Tests/iOSTestHarness/Images.xcassets/AppIcon.appiconset/[email protected] \
307+
objectivec/Tests/iOSTestHarness/Images.xcassets/AppIcon.appiconset/[email protected] \
308+
objectivec/Tests/iOSTestHarness/Images.xcassets/AppIcon.appiconset/[email protected] \
309+
objectivec/Tests/iOSTestHarness/Images.xcassets/LaunchImage.launchimage/Contents.json \
310+
objectivec/Tests/iOSTestHarness/Info.plist \
311+
objectivec/Tests/iOSTestHarness/LaunchScreen.xib \
312+
objectivec/Tests/text_format_map_unittest_data.txt \
313+
objectivec/Tests/text_format_unittest_data.txt \
314+
objectivec/Tests/unittest_cycle.proto \
315+
objectivec/Tests/unittest_filter.proto \
316+
objectivec/Tests/unittest_name_mangling.proto \
317+
objectivec/Tests/unittest_objc.proto \
318+
objectivec/Tests/unittest_runtime_proto2.proto \
319+
objectivec/Tests/unittest_runtime_proto3.proto \
320+
objectivec/Tests/UnitTests-Bridging-Header.h \
321+
objectivec/Tests/UnitTests-Info.plist
200322

201323
python_EXTRA_DIST= \
202324
python/google/protobuf/internal/api_implementation.cc \
@@ -301,7 +423,7 @@ ruby_EXTRA_DIST= \
301423
ruby/tests/generated_code.rb \
302424
ruby/tests/generated_code_test.rb
303425

304-
all_EXTRA_DIST=$(java_EXTRA_DIST) $(javanano_EXTRA_DIST) $(python_EXTRA_DIST) $(ruby_EXTRA_DIST)
426+
all_EXTRA_DIST=$(java_EXTRA_DIST) $(javanano_EXTRA_DIST) $(objectivec_EXTRA_DIST) $(python_EXTRA_DIST) $(ruby_EXTRA_DIST)
305427

306428
EXTRA_DIST = $(@DIST_LANG@_EXTRA_DIST) \
307429
autogen.sh \
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,56 @@
1+
#!/bin/bash
2+
3+
# This script checks that the runtime version number constant in the compiler
4+
# source and in the runtime source is the same.
5+
#
6+
# A distro can be made of the protobuf sources with only a subset of the
7+
# languages, so if the compiler depended on the Objective C runtime, those
8+
# builds would break. At the same time, we don't want the runtime source
9+
# depending on the compiler sources; so two copies of the constant are needed.
10+
11+
set -eu
12+
13+
readonly ScriptDir=$(dirname "$(echo $0 | sed -e "s,^\([^/]\),$(pwd)/\1,")")
14+
readonly ProtoRootDir="${ScriptDir}/../.."
15+
16+
die() {
17+
echo "Error: $1"
18+
exit 1
19+
}
20+
21+
readonly ConstantName=GOOGLE_PROTOBUF_OBJC_GEN_VERSION
22+
23+
# Collect version from plugin sources.
24+
25+
readonly PluginSrc="${ProtoRootDir}/src/google/protobuf/compiler/objectivec/objectivec_file.cc"
26+
readonly PluginVersion=$( \
27+
cat "${PluginSrc}" \
28+
| sed -n -e "s:const int32_t ${ConstantName} = \([0-9]*\);:\1:p"
29+
)
30+
31+
if [[ -z "${PluginVersion}" ]] ; then
32+
die "Failed to fine ${ConstantName} in the plugin source (${PluginSrc})."
33+
fi
34+
35+
# Collect version from runtime sources.
36+
37+
readonly RuntimeSrc="${ProtoRootDir}/objectivec/GPBBootstrap.h"
38+
readonly RuntimeVersion=$( \
39+
cat "${RuntimeSrc}" \
40+
| sed -n -e "s:#define ${ConstantName} \([0-9]*\):\1:p"
41+
)
42+
43+
if [[ -z "${RuntimeVersion}" ]] ; then
44+
die "Failed to fine ${ConstantName} in the runtime source (${RuntimeSrc})."
45+
fi
46+
47+
# Compare them.
48+
49+
if [[ "${PluginVersion}" != "${RuntimeVersion}" ]] ; then
50+
die "Versions don't match!
51+
Plugin: ${PluginVersion} from ${PluginSrc}
52+
Runtime: ${RuntimeVersion} from ${RuntimeSrc}
53+
"
54+
fi
55+
56+
# Success
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,36 @@
1+
#!/bin/bash
2+
3+
# This script will generate the common descriptors needed by the Objective C
4+
# runtime.
5+
6+
# HINT: Flags passed to generate_descriptor_proto.sh will be passed directly
7+
# to make when building protoc. This is particularly useful for passing
8+
# -j4 to run 4 jobs simultaneously.
9+
10+
set -eu
11+
12+
readonly ScriptDir=$(dirname "$(echo $0 | sed -e "s,^\([^/]\),$(pwd)/\1,")")
13+
readonly ProtoRootDir="${ScriptDir}/../.."
14+
readonly ProtoC="${ProtoRootDir}/src/protoc"
15+
16+
pushd "${ProtoRootDir}" > /dev/null
17+
18+
# Compiler build fails if config.h hasn't been made yet (even if configure/etc.
19+
# have been run, so get that made first).
20+
make $@ config.h
21+
22+
# Make sure the compiler is current.
23+
cd src
24+
make $@ protoc
25+
26+
# These really should only be run when the inputs or compiler are newer than
27+
# the outputs.
28+
29+
# Needed by the runtime.
30+
./protoc --objc_out="${ProtoRootDir}/objectivec" google/protobuf/descriptor.proto
31+
32+
# Well known types that the library provides helpers for.
33+
./protoc --objc_out="${ProtoRootDir}/objectivec" google/protobuf/timestamp.proto
34+
./protoc --objc_out="${ProtoRootDir}/objectivec" google/protobuf/duration.proto
35+
36+
popd > /dev/null

0 commit comments

Comments
 (0)