File tree 3 files changed +37
-1
lines changed
3 files changed +37
-1
lines changed Original file line number Diff line number Diff line change 11
11
//===----------------------------------------------------------------------===//
12
12
13
13
import Basics
14
+ import PackageGraph
14
15
import PackageLoading
15
16
import PackageModel
16
17
import struct PackageGraph. ModulesGraph
@@ -23,6 +24,9 @@ import enum TSCBasic.ProcessEnv
23
24
24
25
/// Target description for a Clang target i.e. C language family target.
25
26
package final class ClangTargetBuildDescription {
27
+ /// The package this target belongs to.
28
+ package let package : ResolvedPackage
29
+
26
30
/// The target described by this target.
27
31
package let target : ResolvedTarget
28
32
@@ -109,6 +113,7 @@ package final class ClangTargetBuildDescription {
109
113
110
114
/// Create a new target description with target and build parameters.
111
115
init (
116
+ package : ResolvedPackage ,
112
117
target: ResolvedTarget ,
113
118
toolsVersion: ToolsVersion ,
114
119
additionalFileRules: [ FileRuleDescription ] = [ ] ,
@@ -122,6 +127,7 @@ package final class ClangTargetBuildDescription {
122
127
throw InternalError ( " underlying target type mismatch \( target) " )
123
128
}
124
129
130
+ self . package = package
125
131
self . clangTarget = clangTarget
126
132
self . fileSystem = fileSystem
127
133
self . target = target
Original file line number Diff line number Diff line change @@ -394,8 +394,13 @@ public class BuildPlan: SPMBuildCore.BuildPlan {
394
394
)
395
395
)
396
396
case is ClangTarget :
397
+ guard let package = graph. package ( for: target) else {
398
+ throw InternalError ( " package not found for \( target) " )
399
+ }
400
+
397
401
targetMap [ target. id] = try . clang(
398
402
ClangTargetBuildDescription (
403
+ package : package ,
399
404
target: target,
400
405
toolsVersion: toolsVersion,
401
406
additionalFileRules: additionalFileRules,
Original file line number Diff line number Diff line change @@ -49,8 +49,33 @@ final class ClangTargetBuildDescriptionTests: XCTestCase {
49
49
50
50
private func makeTargetBuildDescription( ) throws -> ClangTargetBuildDescription {
51
51
let observability = ObservabilitySystem . makeForTesting ( verbose: false )
52
+
53
+ let manifest = Manifest . createRootManifest (
54
+ displayName: " dummy " ,
55
+ toolsVersion: . v5,
56
+ targets: [ try TargetDescription ( name: " dummy " ) ]
57
+ )
58
+
59
+ let target = try makeResolvedTarget ( )
60
+
61
+ let package = Package ( identity: . plain( " dummy " ) ,
62
+ manifest: manifest,
63
+ path: . root,
64
+ targets: [ target. underlying] ,
65
+ products: [ ] ,
66
+ targetSearchPath: . root,
67
+ testTargetSearchPath: . root)
68
+
52
69
return try ClangTargetBuildDescription (
53
- target: try makeResolvedTarget ( ) ,
70
+ package : . init( underlying: package ,
71
+ defaultLocalization: nil ,
72
+ supportedPlatforms: [ ] ,
73
+ dependencies: [ ] ,
74
+ targets: [ target] ,
75
+ products: [ ] ,
76
+ registryMetadata: nil ,
77
+ platformVersionProvider: . init( implementation: . minimumDeploymentTargetDefault) ) ,
78
+ target: target,
54
79
toolsVersion: . current,
55
80
buildParameters: mockBuildParameters (
56
81
toolchain: try UserToolchain . default,
You can’t perform that action at this time.
0 commit comments