apple / swift-protobuf

Plugin and runtime library for using protobuf with Swift
Apache License 2.0
4.57k stars 451 forks source link

SwiftProtobufPlugin: Add support for ProtoPathModuleMappings swift opt #1450

Open ripplexyz opened 1 year ago

ripplexyz commented 1 year ago

Can we add support for https://github.com/apple/swift-protobuf/blob/main/Documentation/PLUGIN.md#generation-option-protopathmodulemappings---swift-module-names-for-proto-paths in SwiftProtobufPlugin?

This option allows us to distribute proto files in multiple swift modules.

For example: Core

Auth

And Auth SPM package depends on Core SPM package.

FranzBusch commented 1 year ago

Are those modules in the same package or different packages?

When I implemented the plugins I tried to add cross module package dependency support but we are currently not having the right information in the plugin to make this work. I also think we do not want to use ProtoPathModule mappings for this but rather just rely on the Swift module names and infer it from there.

thomasvl commented 1 year ago

If SwiftPM doesn't expose what's needed for this automatically, should we do something in the mean time?

thomasvl commented 1 year ago

@FranzBusch @tbkka Thoughts on adding something for folks in the mean time? If/when SwiftPM gets the support to not need this, we can always do a major version bump and drop it. Without something, it seems like you can't have protos in one module depend on protos provided from another module.

FranzBusch commented 1 year ago

I don't think we should add support for the ProtoPathModuleMapping in the SPM plugin. We ought to be able to model this differently with SPM especially in the face of Xcode plugins that just have a totally different semantic of targets than SPM targets. We always need to make sure that the files are part of a target and we cannot just pass arbitrary paths to the generated build commands. However, the current ProtoPathModuleMapping just works on arbitrary paths.