forked from apple/swift-protobuf
-
Notifications
You must be signed in to change notification settings - Fork 2
/
Makefile
648 lines (586 loc) · 24.8 KB
/
Makefile
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
#
# Key targets in this makefile:
#
# make build
# Build the runtime library and plugin
# make test
# Build everything, run both plugin and library tests:
# Plugin test verifies that plugin output matches the "Reference" files
# exactly
# Library test exercises most features of the generated code
# make regenerate
# Recompile all the necessary protos
# (requires protoc in path)
# make test-xcode[-NAME]:
# Runs the tests in the Xcode project in the requested mode(s).
#
# Caution: 'test' does not 'regenerate', so if you've made changes to the code
# generation, you'll need to do more than just 'test':
# 1. 'make build' to build the plugin
# 2. 'make regenerate' to rebuild the Swift code from protos using the new
# plugin
# 3. 'make build' again to recompile everything with the regenerated protos
# 4. 'make test' to run the test suites
#
# How to run a 'swift' executable that supports the 'swift update', 'swift build',
# 'swift test', etc commands.
SWIFT=swift
# How to run a working version of protoc. Invoke make with PROTOC=[path] to
# override this value, i.e. -
# make [TARGET] PROTOC=../protobuf/src/protoc
PROTOC=protoc
# How to run awk on your system
AWK=awk
# Installation directory
BINDIR=/usr/local/bin
# Install tool name
INSTALL=install
# Where to find a google/protobuf checkout. Defaults be being beside this
# checkout. Invoke make with GOOGLE_PROTOBUF_CHECKOUT=[PATH_TO_CHECKOUT] to
# override this value, i.e. -
# make [TARGET] GOOGLE_PROTOBUF_CHECKOUT=[PATH_TO_CHECKOUT]
GOOGLE_PROTOBUF_CHECKOUT?=../protobuf
# Helpers for the common parts of source generation.
#
# To ensure that the local version of the plugin is always used (and not a
# previously installed one), we use a custom output name (-tfiws_out).
PROTOC_GEN_SWIFT=.build/debug/protoc-gen-swift
GENERATE_SRCS_BASE=${PROTOC} --plugin=protoc-gen-tfiws=${PROTOC_GEN_SWIFT}
# Until the flag isn't needed, add the flag to enable proto3 optional.
GENERATE_SRCS=${GENERATE_SRCS_BASE} -I Protos --experimental_allow_proto3_optional
# Where to find the Swift conformance test runner executable.
SWIFT_CONFORMANCE_PLUGIN=.build/debug/Conformance
# If you have already build conformance-test-runner in
# a nearby directory, just set the full path here and
# we'll use it instead.
CONFORMANCE_HOST=${GOOGLE_PROTOBUF_CHECKOUT}/conformance/conformance-test-runner
# NOTE: TEST_PROTOS, LIBRARY_PROTOS, and PLUGIN_PROTOS are all full paths so
# eventually we might be able to do proper dependencies and use them as inputs
# for other rules (we'll also likely need outputs).
#
# But since plugin is also Swift code using the runtime, there's a bit of
# recursion that doesn't lend itself to easily being resolved; as the build
# could create a new plugin that in turn could cause new sources need to
# generated, which in turns means the plugin needs to be rebuilt...
#
# It might be easier in the long run to give up on make, and instead have a
# script that does the build and then generation and checks to see if generated
# source change, and if it doesn't errors out to have the developer restart
# the process so they stabilize.
# Protos used for the unit and functional tests
TEST_PROTOS= \
Protos/conformance/conformance.proto \
Protos/generated_swift_names_enums.proto \
Protos/generated_swift_names_enum_cases.proto \
Protos/generated_swift_names_fields.proto \
Protos/generated_swift_names_messages.proto \
Protos/google/protobuf/any_test.proto \
Protos/google/protobuf/map_proto2_unittest.proto \
Protos/google/protobuf/map_unittest.proto \
Protos/google/protobuf/test_messages_proto3.proto \
Protos/google/protobuf/unittest.proto \
Protos/google/protobuf/unittest_arena.proto \
Protos/google/protobuf/unittest_custom_options.proto \
Protos/google/protobuf/unittest_drop_unknown_fields.proto \
Protos/google/protobuf/unittest_embed_optimize_for.proto \
Protos/google/protobuf/unittest_empty.proto \
Protos/google/protobuf/unittest_import.proto \
Protos/google/protobuf/unittest_import_lite.proto \
Protos/google/protobuf/unittest_import_public.proto \
Protos/google/protobuf/unittest_import_public_lite.proto \
Protos/google/protobuf/unittest_lite.proto \
Protos/google/protobuf/unittest_lite_imports_nonlite.proto \
Protos/google/protobuf/unittest_mset.proto \
Protos/google/protobuf/unittest_mset_wire_format.proto \
Protos/google/protobuf/unittest_no_field_presence.proto \
Protos/google/protobuf/unittest_no_generic_services.proto \
Protos/google/protobuf/unittest_optimize_for.proto \
Protos/google/protobuf/unittest_preserve_unknown_enum.proto \
Protos/google/protobuf/unittest_preserve_unknown_enum2.proto \
Protos/google/protobuf/unittest_proto3.proto \
Protos/google/protobuf/unittest_proto3_arena.proto \
Protos/google/protobuf/unittest_proto3_optional.proto \
Protos/google/protobuf/unittest_well_known_types.proto \
Protos/unittest_swift_all_required_types.proto \
Protos/unittest_swift_cycle.proto \
Protos/unittest_swift_enum.proto \
Protos/unittest_swift_enum_optional_default.proto \
Protos/unittest_swift_enum_proto3.proto \
Protos/unittest_swift_extension.proto \
Protos/unittest_swift_extension2.proto \
Protos/unittest_swift_extension3.proto \
Protos/unittest_swift_extension4.proto \
Protos/unittest_swift_fieldorder.proto \
Protos/unittest_swift_groups.proto \
Protos/unittest_swift_naming.proto \
Protos/unittest_swift_naming_no_prefix.proto \
Protos/unittest_swift_naming_number_prefix.proto \
Protos/unittest_swift_oneof_all_required.proto \
Protos/unittest_swift_oneof_merging.proto \
Protos/unittest_swift_performance.proto \
Protos/unittest_swift_reserved.proto \
Protos/unittest_swift_reserved_ext.proto \
Protos/unittest_swift_runtime_proto2.proto \
Protos/unittest_swift_runtime_proto3.proto \
Protos/unittest_swift_startup.proto
# TODO: The library and plugin Protos come directly from google sources.
# There should be an easy way to copy the Google versions from a protobuf
# checkout into this project.
# Protos that are embedded into the SwiftProtobuf runtime library module
LIBRARY_PROTOS= \
Protos/google/protobuf/any.proto \
Protos/google/protobuf/api.proto \
Protos/google/protobuf/descriptor.proto \
Protos/google/protobuf/duration.proto \
Protos/google/protobuf/empty.proto \
Protos/google/protobuf/field_mask.proto \
Protos/google/protobuf/source_context.proto \
Protos/google/protobuf/struct.proto \
Protos/google/protobuf/timestamp.proto \
Protos/google/protobuf/type.proto \
Protos/google/protobuf/wrappers.proto
# Protos that are used internally by the plugin
PLUGIN_PROTOS= \
Protos/google/protobuf/compiler/plugin.proto \
Protos/SwiftProtobufPluginLibrary/swift_protobuf_module_mappings.proto
# Protos that are used by the conformance test runner.
CONFORMANCE_PROTOS= \
Protos/conformance/conformance.proto \
Protos/google/protobuf/test_messages_proto2.proto \
Protos/google/protobuf/test_messages_proto3.proto
SWIFT_DESCRIPTOR_TEST_PROTOS= \
Protos/pluginlib_descriptor_test.proto \
Protos/pluginlib_descriptor_test2.proto \
${PLUGIN_PROTOS}
XCODEBUILD_EXTRAS =
# Invoke make with XCODE_SKIP_OPTIMIZER=1 to suppress the optimizer when
# building the Xcode projects. For Release builds, this is a non trivial speed
# up for compilation
XCODE_SKIP_OPTIMIZER=0
ifeq "$(XCODE_SKIP_OPTIMIZER)" "1"
XCODEBUILD_EXTRAS += SWIFT_OPTIMIZATION_LEVEL=-Onone
endif
# Invoke make with XCODE_ANALYZE=1 to enable the analyzer while building the
# Xcode projects.
XCODE_ANALYZE=0
ifeq "$(XCODE_ANALYZE)" "1"
XCODEBUILD_EXTRAS += RUN_CLANG_STATIC_ANALYZER=YES CLANG_STATIC_ANALYZER_MODE=deep
endif
# Invoke make with XCODE_NOISY to get the default output of everything little
# thing Xcode does.
XCODE_NOISY=0
ifeq "$(XCODE_NOISY)" "0"
XCODEBUILD_EXTRAS += -quiet
endif
.PHONY: \
all \
build \
check \
check-for-protobuf-checkout \
check-proto-files \
check-version-numbers \
clean \
conformance-host \
default \
docs \
install \
reference \
regenerate \
regenerate-conformance-protos \
regenerate-library-protos \
regenerate-plugin-protos \
regenerate-test-protos \
test \
test-all \
test-everything \
test-plugin \
test-runtime \
test-xcode \
test-xcode-debug \
test-xcode-release \
test-xcode-iOS \
test-xcode-iOS-debug \
test-xcode-iOS-release \
test-xcode-macOS \
test-xcode-macOS-debug \
test-xcode-macOS-release \
test-xcode-tvOS \
test-xcode-tvOS-debug \
test-xcode-tvOS-release \
test-xcode-watchOS \
test-xcode-watchOS-debug \
test-xcode-watchOS-release \
update-proto-files
.NOTPARALLEL: \
test-xcode-iOS-debug \
test-xcode-iOS-release \
test-xcode-macOS-debug \
test-xcode-macOS-release \
test-xcode-tvOS-debug \
test-xcode-tvOS-release \
test-xcode-watchOS-debug \
test-xcode-watchOS-release
default: build
all: build
# This also rebuilds LinuxMain.swift to include all of the test cases.
# (The awk script is very fast, so re-running it on every build is reasonable,
# but we only update the file when it changes to avoid extra builds.)
# (Someday, 'swift test' will learn how to auto-discover test cases on Linux,
# at which time this will no longer be needed.)
build:
@${AWK} -f DevTools/CollectTests.awk Tests/*/Test_*.swift > Tests/LinuxMain.swift.new
@if ! cmp -s Tests/LinuxMain.swift.new Tests/LinuxMain.swift; then \
cp Tests/LinuxMain.swift.new Tests/LinuxMain.swift; \
echo "FYI: Tests/LinuxMain.swift Updated"; \
fi
@rm Tests/LinuxMain.swift.new
${SWIFT} build
# Anything that needs the plugin should do a build.
${PROTOC_GEN_SWIFT}: build
# Does it really make sense to install a debug build, or should this be forcing
# a release build and then installing that instead?
install: build
${INSTALL} ${PROTOC_GEN_SWIFT} ${BINDIR}
clean:
swift package clean
rm -rf .build _test ${PROTOC_GEN_SWIFT} DescriptorTestData.bin \
Performance/_generated Performance/_results Protos/mined_words.txt \
docs build
find . -name '*~' | xargs rm -f
# Build a local copy of the API documentation, using the same process used
# by cocoadocs.org.
docs:
@if which jazzy >/dev/null; then \
jazzy; \
else \
echo "Jazzy not installed, use 'gem install jazzy' or download from https://github.com/realm/jazzy"; \
fi
#
# Test the runtime and the plugin
#
# This must pass before any commit.
#
check test: build test-runtime test-plugin test-conformance check-version-numbers
# Test everything (runtime, plugin, xcode project)
test-all test-everything: test test-xcode
# Check the version numbers are all in sync.
check-version-numbers:
@DevTools/LibraryVersions.py --validate
#
# The Swift test suite includes unit tests for the runtime library
# and functional tests for the Swift code generated by the plugin.
#
test-runtime: build
${SWIFT} test
#
# Test the plugin by itself:
# * Translate every proto in Protos into Swift using local protoc-gen-swift
# * Put result in _test directory
# * Compare output with reference output in Reference directory
# * If generated output and reference output don't match exactly, fail.
#
# Of course, this will fail if you've made any changes to the generated output.
# In that case, you'll need to do the following before committing:
# * `make regenerate` to rebuild the protos used by the runtime and plugin
# * `make test-runtime` to verify that the runtime works correctly with the new changes
# * `make reference` to update the Reference directory
# * MANUALLY go through `git diff Reference` to verify that the generated Swift changed in the way you expect
# * `make clean build test` to do a final check
#
# Note: Some of these protos define the same package.(message|enum)s, so they
# can't be done in a single protoc/proto-gen-swift invoke and have to be done
# one at a time instead.
test-plugin: build ${PROTOC_GEN_SWIFT}
@rm -rf _test && mkdir _test
for p in `find Protos/ -type f -name '*.proto'`; do \
${GENERATE_SRCS} --tfiws_out=_test $$p || exit 1; \
done
diff -ru _test Reference
#
# Rebuild the reference files by running the local version of protoc-gen-swift
# against our menagerie of sample protos.
#
# If you do this, you MUST MANUALLY verify these files before checking them in,
# since the new checkin will become the new master reference.
#
# Note: Some of these protos define the same package.(message|enum)s, so they
# can't be done in a single protoc/proto-gen-swift invoke and have to be done
# one at a time instead.
reference: build ${PROTOC_GEN_SWIFT}
@rm -rf Reference && mkdir Reference
for p in `find Protos/ -type f -name '*.proto'`; do \
${GENERATE_SRCS} --tfiws_out=Reference $$p || exit 1; \
done
#
# Rebuild the generated .pb.swift test files by running
# protoc over all the relevant inputs.
#
# Before running this, ensure that:
# * protoc-gen-swift is built and installed somewhere in your system PATH
# * protoc is built and installed
# * PROTOC at the top of this file is set correctly
#
regenerate: \
regenerate-library-protos \
regenerate-plugin-protos \
regenerate-test-protos \
regenerate-conformance-protos \
Tests/SwiftProtobufPluginLibraryTests/DescriptorTestData.swift
# Rebuild just the protos included in the runtime library
regenerate-library-protos: build ${PROTOC_GEN_SWIFT}
find Sources/SwiftProtobuf -name "*.pb.swift" -exec rm -f {} \;
${GENERATE_SRCS} \
--tfiws_opt=FileNaming=DropPath \
--tfiws_opt=Visibility=Public \
--tfiws_out=Sources/SwiftProtobuf \
${LIBRARY_PROTOS}
# Rebuild just the protos used by the plugin
regenerate-plugin-protos: build ${PROTOC_GEN_SWIFT}
find Sources/SwiftProtobufPluginLibrary -name "*.pb.swift" -exec rm -f {} \;
${GENERATE_SRCS} \
--tfiws_opt=FileNaming=DropPath \
--tfiws_opt=Visibility=Public \
--tfiws_out=Sources/SwiftProtobufPluginLibrary \
${PLUGIN_PROTOS}
# Rebuild just the protos used by the runtime test suite
# Note: Some of these protos define the same package.(message|enum)s, so they
# can't be done in a single protoc/proto-gen-swift invoke and have to be done
# one at a time instead.
regenerate-test-protos: build ${PROTOC_GEN_SWIFT} Protos/generated_swift_names_enums.proto Protos/generated_swift_names_enum_cases.proto Protos/generated_swift_names_fields.proto Protos/generated_swift_names_messages.proto
find Tests/SwiftProtobufTests -name "*.pb.swift" -exec rm -f {} \;
${GENERATE_SRCS} \
--tfiws_opt=FileNaming=DropPath \
--tfiws_out=Tests/SwiftProtobufTests \
${TEST_PROTOS}
Tests/SwiftProtobufPluginLibraryTests/DescriptorTestData.swift: build ${PROTOC_GEN_SWIFT} ${SWIFT_DESCRIPTOR_TEST_PROTOS}
# Until the flag isn't needed, add the flag to enable proto3 optional.
@${PROTOC} \
--experimental_allow_proto3_optional \
--include_imports \
--descriptor_set_out=DescriptorTestData.bin \
-I Protos \
${SWIFT_DESCRIPTOR_TEST_PROTOS}
@rm -f $@
@echo '// See Makefile how this is generated.' >> $@
@echo '// swift-format-ignore-file' >> $@
@echo 'import Foundation' >> $@
@echo 'let fileDescriptorSetBytes: [UInt8] = [' >> $@
@xxd -i < DescriptorTestData.bin >> $@
@echo ']' >> $@
@echo 'let fileDescriptorSetData = Data(fileDescriptorSetBytes)' >> $@
#
# Collect a list of words that appear in the SwiftProtobuf library
# source. These are words that may cause problems for generated code.
#
# The logic here builds a word list as follows:
# = Look at every Swift source file in the library
# = Take every line with the word 'public', 'func', or 'var'
# = Remove any comments from the line.
# = Break each such line into words (stripping all punctuation)
# = Remove words that differ only in case
#
# Selecting lines with 'public', 'func' or 'var' ensures we get every
# public protocol, struct, enum, or class name, as well as every
# method or property defined in a public protocol, struct, or class.
# It also gives us a large collection of Swift names.
Protos/mined_words.txt: Sources/SwiftProtobuf/*
@echo Building $@
@cat Sources/SwiftProtobuf/* | \
grep -E '\b(public|func|var)\b' | \
grep -vE '\b(private|internal|fileprivate)\b' | \
sed -e 's|//.*$$||g' | \
sed -e 's/[^a-zA-Z0-9_]/ /g' | \
tr " " "\n" | \
sed -e 's/^_//' | \
sort -uf | \
grep '^[a-zA-Z_]' > $@
# Build some proto files full of landmines
#
# This takes the word list Protos/mined_words.txt and uses
# it to build several proto files:
# = Build a message with one `int32` field for each word
# = Build an enum with a case for each such word
# = Build a message with a submessage named with each word
# = Build a message with an enum named with each word
#
# If the Swift compiler can actually compile the result, that suggests
# we can correctly handle every symbol in the library itself that
# might cause problems. Failures compiling this indicate weaknesses
# in protoc-gen-swift's name sanitization logic.
#
Protos/generated_swift_names_fields.proto: Protos/mined_words.txt
@echo Building $@
@rm $@
@echo '// See Makefile for the logic that generates this' >> $@
@echo '// Protoc errors imply this file is being generated incorrectly' >> $@
@echo '// Swift compile errors are probably bugs in protoc-gen-swift' >> $@
@echo 'syntax = "proto3";' >> $@
@echo 'package protobuf_unittest_generated;' >> $@
@echo 'message GeneratedSwiftReservedFields {' >> $@
@cat Protos/mined_words.txt | awk 'BEGIN{n = 1} {print " int32 " $$1 " = " n ";"; n += 1 }' >> $@
@echo '}' >> $@
Protos/generated_swift_names_enum_cases.proto: Protos/mined_words.txt
@echo Building $@
@rm $@
@echo '// See Makefile for the logic that generates this' >> $@
@echo '// Protoc errors imply this file is being generated incorrectly' >> $@
@echo '// Swift compile errors are probably bugs in protoc-gen-swift' >> $@
@echo 'syntax = "proto3";' >> $@
@echo 'package protobuf_unittest_generated;' >> $@
@echo 'enum GeneratedSwiftReservedEnum {' >> $@
@echo ' NONE = 0;' >> $@
@cat Protos/mined_words.txt | awk 'BEGIN{n = 1} {print " " $$1 " = " n ";"; n += 1 }' >> $@
@echo '}' >> $@
Protos/generated_swift_names_messages.proto: Protos/mined_words.txt
@echo Building $@
@rm $@
@echo '// See Makefile for the logic that generates this' >> $@
@echo '// Protoc errors imply this file is being generated incorrectly' >> $@
@echo '// Swift compile errors are probably bugs in protoc-gen-swift' >> $@
@echo 'syntax = "proto3";' >> $@
@echo 'package protobuf_unittest_generated;' >> $@
@echo 'message GeneratedSwiftReservedMessages {' >> $@
@cat Protos/mined_words.txt | awk '{print " message " $$1 " { int32 " $$1 " = 1; }"}' >> $@
@echo '}' >> $@
Protos/generated_swift_names_enums.proto: Protos/mined_words.txt
@echo Building $@
@rm $@
@echo '// See Makefile for the logic that generates this' >> $@
@echo '// Protoc errors imply this file is being generated incorrectly' >> $@
@echo '// Swift compile errors are probably bugs in protoc-gen-swift' >> $@
@echo 'syntax = "proto3";' >> $@
@echo 'package protobuf_unittest_generated;' >> $@
@echo 'message GeneratedSwiftReservedEnums {' >> $@
@cat Protos/mined_words.txt | awk '{print " enum " $$1 " { NONE_" $$1 " = 0; }"}' >> $@
@echo '}' >> $@
# Rebuild just the protos used by the conformance test runner.
regenerate-conformance-protos: build ${PROTOC_GEN_SWIFT}
find Sources/Conformance -name "*.pb.swift" -exec rm -f {} \;
${GENERATE_SRCS} \
--tfiws_opt=FileNaming=DropPath \
--tfiws_out=Sources/Conformance \
${CONFORMANCE_PROTOS}
# Helper to check if there is a protobuf checkout as expected.
check-for-protobuf-checkout:
@if [ ! -d "${GOOGLE_PROTOBUF_CHECKOUT}/src/google/protobuf" ]; then \
echo "ERROR: ${GOOGLE_PROTOBUF_CHECKOUT} does not appear to be a checkout of"; \
echo "ERROR: github.com/protocolbuffers/protobuf. Please check it out or set"; \
echo "ERROR: GOOGLE_PROTOBUF_CHECKOUT to point to a checkout."; \
exit 1; \
fi
#
# Helper to update the .proto files copied from the protocolbuffers/protobuf distro.
#
update-proto-files: check-for-protobuf-checkout
@rm -rf Protos/conformance && mkdir Protos/conformance
@cp -v "${GOOGLE_PROTOBUF_CHECKOUT}"/conformance/*.proto Protos/conformance/
@rm -rf Protos/google && mkdir -p Protos/google/protobuf/compiler
@cp -v "${GOOGLE_PROTOBUF_CHECKOUT}"/src/google/protobuf/*.proto Protos/google/protobuf/
@cp -v "${GOOGLE_PROTOBUF_CHECKOUT}"/src/google/protobuf/compiler/*.proto Protos/google/protobuf/compiler/
#
# Helper to see if update-proto-files should be done
#
check-proto-files: check-for-protobuf-checkout
@for p in `cd ${GOOGLE_PROTOBUF_CHECKOUT} && ls conformance/*.proto`; do \
diff -u "${GOOGLE_PROTOBUF_CHECKOUT}/$$p" "Protos/$$p" \
|| (echo "ERROR: Time to do a 'make update-proto-files'" && exit 1); \
done
@for p in `cd ${GOOGLE_PROTOBUF_CHECKOUT}/src && ls google/protobuf/*.proto | grep -v test`; do \
diff -u "${GOOGLE_PROTOBUF_CHECKOUT}/src/$$p" "Protos/$$p" \
|| (echo "ERROR: Time to do a 'make update-proto-files'" && exit 1); \
done
@for p in `cd ${GOOGLE_PROTOBUF_CHECKOUT}/src && ls google/protobuf/compiler/*.proto`; do \
diff -u "${GOOGLE_PROTOBUF_CHECKOUT}/src/$$p" "Protos/$$p" \
|| (echo "ERROR: Time to do a 'make update-proto-files'" && exit 1); \
done
# Runs the conformance tests.
test-conformance: build check-for-protobuf-checkout $(CONFORMANCE_HOST) Sources/Conformance/failure_list_swift.txt Sources/Conformance/text_format_failure_list_swift.txt
( \
ABS_PBDIR=`cd ${GOOGLE_PROTOBUF_CHECKOUT}; pwd`; \
$${ABS_PBDIR}/conformance/conformance-test-runner \
--enforce_recommended \
--failure_list Sources/Conformance/failure_list_swift.txt \
--text_format_failure_list Sources/Conformance/text_format_failure_list_swift.txt\
$(SWIFT_CONFORMANCE_PLUGIN); \
)
# The 'conformance-host' program is part of the protobuf project.
# It generates test cases, feeds them to our plugin, and verifies the results:
conformance-host $(CONFORMANCE_HOST): check-for-protobuf-checkout
@if [ ! -f "${GOOGLE_PROTOBUF_CHECKOUT}/Makefile" ]; then \
echo "No Makefile, running autogen.sh and configure." ; \
( cd ${GOOGLE_PROTOBUF_CHECKOUT} && \
./autogen.sh && \
./configure ) \
fi
$(MAKE) -C ${GOOGLE_PROTOBUF_CHECKOUT}/src
$(MAKE) -C ${GOOGLE_PROTOBUF_CHECKOUT}/conformance
# Helpers to put the Xcode project through all modes.
# Grouping targets
test-xcode: test-xcode-iOS test-xcode-macOS test-xcode-tvOS test-xcode-watchOS
test-xcode-iOS: test-xcode-iOS-debug test-xcode-iOS-release
test-xcode-macOS: test-xcode-macOS-debug test-xcode-macOS-release
test-xcode-tvOS: test-xcode-tvOS-debug test-xcode-tvOS-release
test-xcode-watchOS: test-xcode-watchOS-debug test-xcode-watchOS-release
test-xcode-debug: test-xcode-iOS-debug test-xcode-macOS-debug test-xcode-tvOS-debug test-xcode-watchOS-debug
test-xcode-release: test-xcode-iOS-release test-xcode-macOS-release test-xcode-tvOS-release test-xcode-watchOS-release
# The individual ones
# 4s - 32bit, 6s - 64bit
test-xcode-iOS-debug:
# 9+ seems to not like concurrent testing with the iPhone 4s simulator.
xcodebuild -project SwiftProtobuf.xcodeproj \
-scheme SwiftProtobuf_iOS \
-configuration Debug \
-destination "platform=iOS Simulator,name=iPhone 8,OS=latest" \
-destination "platform=iOS Simulator,name=iPhone 4s,OS=9.0" \
-disable-concurrent-destination-testing \
test $(XCODEBUILD_EXTRAS)
# 4s - 32bit, 6s - 64bit
# Release defaults to not supporting testing, so add ENABLE_TESTABILITY=YES
# to ensure the main library gets testing support.
test-xcode-iOS-release:
# 9+ seems to not like concurrent testing with the iPhone 4s simulator.
xcodebuild -project SwiftProtobuf.xcodeproj \
-scheme SwiftProtobuf_iOS \
-configuration Release \
-destination "platform=iOS Simulator,name=iPhone 8,OS=latest" \
-destination "platform=iOS Simulator,name=iPhone 4s,OS=9.0" \
-disable-concurrent-destination-testing \
test ENABLE_TESTABILITY=YES $(XCODEBUILD_EXTRAS)
test-xcode-macOS-debug:
xcodebuild -project SwiftProtobuf.xcodeproj \
-scheme SwiftProtobuf_macOS \
-configuration Debug \
build test $(XCODEBUILD_EXTRAS)
# Release defaults to not supporting testing, so add ENABLE_TESTABILITY=YES
# to ensure the main library gets testing support.
test-xcode-macOS-release:
xcodebuild -project SwiftProtobuf.xcodeproj \
-scheme SwiftProtobuf_macOS \
-configuration Release \
build test ENABLE_TESTABILITY=YES $(XCODEBUILD_EXTRAS)
test-xcode-tvOS-debug:
xcodebuild -project SwiftProtobuf.xcodeproj \
-scheme SwiftProtobuf_tvOS \
-configuration Debug \
-destination "platform=tvOS Simulator,name=Apple TV,OS=latest" \
build test $(XCODEBUILD_EXTRAS)
# Release defaults to not supporting testing, so add ENABLE_TESTABILITY=YES
# to ensure the main library gets testing support.
test-xcode-tvOS-release:
xcodebuild -project SwiftProtobuf.xcodeproj \
-scheme SwiftProtobuf_tvOS \
-configuration Release \
-destination "platform=tvOS Simulator,name=Apple TV,OS=latest" \
build test ENABLE_TESTABILITY=YES $(XCODEBUILD_EXTRAS)
# watchOS doesn't support tests, just do a build.
test-xcode-watchOS-debug:
xcodebuild -project SwiftProtobuf.xcodeproj \
-scheme SwiftProtobuf_watchOS \
-configuration Debug \
build $(XCODEBUILD_EXTRAS)
# watchOS doesn't support tests, just do a build.
test-xcode-watchOS-release:
xcodebuild -project SwiftProtobuf.xcodeproj \
-scheme SwiftProtobuf_watchOS \
-configuration Release \
build $(XCODEBUILD_EXTRAS)