-
Notifications
You must be signed in to change notification settings - Fork 1.4k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Add support for targets with mixed language sources #5919
base: main
Are you sure you want to change the base?
Conversation
@swift-ci please smoke test |
Thanks a lot for this, @ncooke3! The changes look good to me in general, I'll do are more in-depth review once we're closer to landing this. It would be good to unify mixed targets and the individual language targets at some point, but it seems reasonable to start this way. |
60e115a
to
76c5303
Compare
One bit I hadn't thought about until now is that we'd need to make the support conditional on the tools-version since we would not want authors accidentally creating packages that aren't actually backwards compatible. For existing tools-versions, we would probably want to preserve the error message about mixed sources not being supported. |
6083a00
to
28a527c
Compare
In 9456663, I added a suite of integration-style tests to document and test the behavior of mixed targets. Along the way, I tweaked the implementation, and added TODOs to further refine the implementation. Currently, not all of the added tests are passing– there are some gaps that I will be filling in over the next few days. I'm happy to break the PR up once it is ready for review. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks great! Just some miscellaneous nits ....
Fixtures/MixedTargets/BasicMixedTargets/MixedTargetWithCustomPaths/Sources/OldCar.m
Outdated
Show resolved
Hide resolved
Fixtures/MixedTargets/BasicMixedTargets/MixedTargetWithCustomPaths/Sources/OldCar.m
Outdated
Show resolved
Hide resolved
Fixtures/MixedTargets/BasicMixedTargets/MixedTargetWithCustomPaths/Sources/Transmission.h
Outdated
Show resolved
Hide resolved
Fixtures/MixedTargets/BasicMixedTargets/MixedTargetWithCustomPaths/Sources/Transmission.m
Outdated
Show resolved
Hide resolved
...res/MixedTargets/BasicMixedTargets/Sources/MixedTargetWithNestedPublicHeaders/Transmission.h
Outdated
Show resolved
Hide resolved
...res/MixedTargets/BasicMixedTargets/Sources/MixedTargetWithNestedPublicHeaders/Transmission.m
Outdated
Show resolved
Hide resolved
Fixtures/MixedTargets/BasicMixedTargets/Sources/SwiftTargetDependsOnMixedTarget/JunkYard.swift
Outdated
Show resolved
Hide resolved
d0d6484
to
41770f7
Compare
2e22eb1
to
80a9c8b
Compare
@swift-ci test |
Add support for targets with mixed language sources.
Motivation:
At the time of this PR, the package manager does not support targets with mixed language sources. This feature was motivated by the need for packages to contain mixed language sources for legacy and technical reasons.
Modifications:
Detailed design is explained in swiftlang/swift-evolution#1895
The diff is large but most of it comes from the suite of integration tests. I added many fixture tests to test many cases that arise when making a mixed target.
High Level Overview
MixedTarget
type to model targets with mixed language sourcesSwiftTarget
andClangTarget
.MixedTargetBuildDescription
type to model howMixedTarget
's should build.SwiftTargetBuildDescription
andClangTargetBuildDescription
.VFSOverlay
type to support VFS overlay directories.MixedTargetBuildDescription
when creating the VFS overlays needed to compile a mixed language target.ModuleMapGenerator
implementation to generate module maps for mixed language targets. This involves adding a submodule to the module map to expose the generated Swift interop header.PackageBuilder
to created a mixed language target instead of throwing an error when mixed language sources are detected (when sufficient Swift tools version is detected).FunctionalTests
target) tests to test mixed target use cases.Result:
Targets with mixed language sources can be built, tested, and depended on by other packages.
Development Workflow
I have added info to this Google Doc for instructions on how to use this implementation to build and test mixed language targets.