@@ -79,13 +79,15 @@ PROTOS_DIRS=Conformance protoc-gen-swiftTests SwiftProtobuf SwiftProtobufPluginL
79
79
clean \
80
80
compile-tests \
81
81
compile-tests-multimodule \
82
+ compile-tests-internalimportsbydefault \
82
83
default \
83
84
docs \
84
85
install \
85
86
pod-lib-lint \
86
87
reference \
87
88
regenerate \
88
89
regenerate-compiletests-multimodule-protos \
90
+ copy-compiletests-internalimportsbydefault-protos \
89
91
regenerate-compiletests-protos \
90
92
regenerate-conformance-protos \
91
93
regenerate-fuzz-protos \
@@ -194,19 +196,33 @@ test-plugin: build ${PROTOC_GEN_SWIFT}
194
196
--tfiws_opt=ProtoPathModuleMappings=Protos/CompileTests/MultiModule/module_mappings.pbascii \
195
197
--tfiws_out=_test/CompileTests/MultiModule \
196
198
` (find Protos/CompileTests/MultiModule -type f -name " *.proto" )`
199
+ @mkdir -p _test/CompileTests/InternalImportsByDefault
200
+ ${GENERATE_SRCS} \
201
+ -I Protos/CompileTests/InternalImportsByDefault \
202
+ --tfiws_opt=Visibility=Public \
203
+ --tfiws_opt=UseAccessLevelOnImports=true \
204
+ --tfiws_out=_test/CompileTests/InternalImportsByDefault \
205
+ ` (find Protos/CompileTests/InternalImportsByDefault -type f -name " *.proto" )`
197
206
diff -ru _test Reference
198
207
199
208
# Test the SPM plugin.
200
209
test-spm-plugin :
201
210
env PROTOC_PATH=$(shell realpath ${PROTOC}) ${SWIFT} test --package-path PluginExamples
202
211
203
- compile-tests : compile-tests-multimodule
212
+ compile-tests : \
213
+ compile-tests-multimodule \
214
+ compile-tests-internalimportsbydefault
204
215
205
- # Test that ensure generating public into multiple modules with `import public`
216
+ # Test that ensures generating public into multiple modules with `import public`
206
217
# yields buildable code.
207
218
compile-tests-multimodule :
208
219
${SWIFT} test --package-path CompileTests/MultiModule
209
220
221
+ # Test that ensures that using access level modifiers on imports yields code that's buildable
222
+ # when `InternalImportsByDefault` is enabled on the module.
223
+ compile-tests-internalimportsbydefault :
224
+ env PROTOC_PATH=$(shell realpath ${PROTOC}) ${SWIFT} build --package-path CompileTests/InternalImportsByDefault
225
+
210
226
211
227
# Rebuild the reference files by running the local version of protoc-gen-swift
212
228
# against our menagerie of sample protos.
@@ -240,6 +256,13 @@ reference: build ${PROTOC_GEN_SWIFT}
240
256
--tfiws_opt=ProtoPathModuleMappings=Protos/CompileTests/MultiModule/module_mappings.pbascii \
241
257
--tfiws_out=Reference/CompileTests/MultiModule \
242
258
` (find Protos/CompileTests/MultiModule -type f -name " *.proto" )`
259
+ @mkdir -p Reference/CompileTests/InternalImportsByDefault
260
+ ${GENERATE_SRCS} \
261
+ -I Protos/CompileTests/InternalImportsByDefault \
262
+ --tfiws_opt=Visibility=Public \
263
+ --tfiws_opt=UseAccessLevelOnImports=true \
264
+ --tfiws_out=Reference/CompileTests/InternalImportsByDefault \
265
+ ` (find Protos/CompileTests/InternalImportsByDefault -type f -name " *.proto" )`
243
266
244
267
#
245
268
# Rebuild the generated .pb.swift test files by running
@@ -494,10 +517,12 @@ regenerate-conformance-protos: build ${PROTOC_GEN_SWIFT}
494
517
` find Protos/Conformance -type f -name " *.proto" `
495
518
496
519
# Rebuild just the protos used by the CompileTests.
497
- regenerate-compiletests-protos : regenerate-compiletests-multimodule-protos
520
+ regenerate-compiletests-protos : \
521
+ regenerate-compiletests-multimodule-protos \
522
+ copy-compiletests-internalimportsbydefault-protos
498
523
499
524
# Update the CompileTests/MultiModule files.
500
- # NOTE: Any changes here must be done of the "test-plugin" target so it
525
+ # NOTE: Any changes here must also be done on the "test-plugin" target so it
501
526
# generates in the same way.
502
527
regenerate-compiletests-multimodule-protos : build ${PROTOC_GEN_SWIFT}
503
528
find CompileTests/MultiModule -name " *.pb.swift" -exec rm -f {} \;
@@ -508,6 +533,12 @@ regenerate-compiletests-multimodule-protos: build ${PROTOC_GEN_SWIFT}
508
533
--tfiws_out=CompileTests/MultiModule \
509
534
` (find Protos/CompileTests/MultiModule -type f -name " *.proto" )`
510
535
536
+ # We use the plugin for the InternalImportsByDefault test, so we don't actually need to regenerate
537
+ # anything. However, to keep the protos centralised in a single place (the Protos directory),
538
+ # this simply copies those files to the InternalImportsByDefault package in case they change.
539
+ copy-compiletests-internalimportsbydefault-protos :
540
+ @cp Protos/CompileTests/InternalImportsByDefault/* CompileTests/InternalImportsByDefault/Sources/InternalImportsByDefault/Protos
541
+
511
542
# Helper to check if there is a protobuf checkout as expected.
512
543
check-for-protobuf-checkout :
513
544
@if [ ! -d " ${GOOGLE_PROTOBUF_CHECKOUT} /src/google/protobuf" ]; then \
0 commit comments