Skip to content

Commit 4ce94bf

Browse files
authored
Add plugin support section
1 parent be40a22 commit 4ce94bf

File tree

1 file changed

+65
-0
lines changed

1 file changed

+65
-0
lines changed

proposals/0403-swiftpm-mixed-language-targets.md

Lines changed: 65 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -177,6 +177,69 @@ example demonstrates all the possible public headers that can be imported from
177177
#import "MixedPackage-Swift.h"
178178
```
179179

180+
## Plugin Support
181+
182+
Package manager plugins should be able to process mixed language source
183+
targets. The following type will be added to the `PackagePlugin` module
184+
to represent a mixed language target in a plugin's context.
185+
186+
This API was created by joining together the properties of the existing
187+
`SwiftSourceModuleTarget` and `ClangSourceModuleTarget` types
188+
([source][Swift-Clang-SourceModuleTarget]).
189+
190+
```swift
191+
/// Represents a target consisting of a source code module compiled using both the Clang and Swift compiler.
192+
public struct MixedSourceModuleTarget: SourceModuleTarget {
193+
/// Unique identifier for the target.
194+
public let id: ID
195+
196+
/// The name of the target, as defined in the package manifest. This name
197+
/// is unique among the targets of the package in which it is defined.
198+
public let name: String
199+
200+
/// The kind of module, describing whether it contains unit tests, contains
201+
/// the main entry point of an executable, or neither.
202+
public let kind: ModuleKind
203+
204+
/// The absolute path of the target directory in the local file system.
205+
public let directory: Path
206+
207+
/// Any other targets on which this target depends, in the same order as
208+
/// they are specified in the package manifest. Conditional dependencies
209+
/// that do not apply have already been filtered out.
210+
public let dependencies: [TargetDependency]
211+
212+
/// The name of the module produced by the target (derived from the target
213+
/// name, though future SwiftPM versions may allow this to be customized).
214+
public let moduleName: String
215+
216+
/// The source files that are associated with this target (any files that
217+
/// have been excluded in the manifest have already been filtered out).
218+
public let sourceFiles: FileList
219+
220+
/// Any custom compilation conditions specified for the target's Swift sources.
221+
public let swiftCompilationConditions: [String]
222+
223+
/// Any preprocessor definitions specified for the target's Clang sources.
224+
public let clangPreprocessorDefinitions: [String]
225+
226+
/// Any custom header search paths specified for the Clang target.
227+
public let headerSearchPaths: [String]
228+
229+
/// The directory containing public C headers, if applicable. This will
230+
/// only be set for targets that have a directory of a public headers.
231+
public let publicHeadersDirectory: Path?
232+
233+
/// Any custom linked libraries required by the module, as specified in the
234+
/// package manifest.
235+
public let linkedLibraries: [String]
236+
237+
/// Any custom linked frameworks required by the module, as specified in the
238+
/// package manifest.
239+
public let linkedFrameworks: [String]
240+
}
241+
```
242+
180243

181244
## Detailed design
182245

@@ -509,3 +572,5 @@ feature will continue to [throw an error][mixed-target-error].
509572
[should-emit-header]: https://github.com/apple/swift-package-manager/blob/6478e2724b8bf77856ff358cba5f59a4a62978bf/Sources/Build/BuildDescription/SwiftTargetBuildDescription.swift#L732-L735
510573

511574
[swift-emit-header-fr]: https://forums.swift.org/t/se-0403-package-manager-mixed-language-target-support/66202/31
575+
576+
[Swift-Clang-SourceModuleTarget]: https://github.com/apple/swift-package-manager/blob/8e512308530f808e9ef0cd149f4f632339c65bc4/Sources/PackagePlugin/PackageModel.swift#L231-L319

0 commit comments

Comments
 (0)