File tree Expand file tree Collapse file tree 3 files changed +37
-1
lines changed Expand file tree Collapse file tree 3 files changed +37
-1
lines changed Original file line number Diff line number Diff line change 1111//===----------------------------------------------------------------------===//
1212
1313import Basics
14+ import PackageGraph
1415import PackageLoading
1516import PackageModel
1617import struct PackageGraph. ModulesGraph
@@ -23,6 +24,9 @@ import enum TSCBasic.ProcessEnv
2324
2425/// Target description for a Clang target i.e. C language family target.
2526package final class ClangTargetBuildDescription {
27+ /// The package this target belongs to.
28+ package let package : ResolvedPackage
29+
2630 /// The target described by this target.
2731 package let target : ResolvedTarget
2832
@@ -109,6 +113,7 @@ package final class ClangTargetBuildDescription {
109113
110114 /// Create a new target description with target and build parameters.
111115 init (
116+ package : ResolvedPackage ,
112117 target: ResolvedTarget ,
113118 toolsVersion: ToolsVersion ,
114119 additionalFileRules: [ FileRuleDescription ] = [ ] ,
@@ -122,6 +127,7 @@ package final class ClangTargetBuildDescription {
122127 throw InternalError ( " underlying target type mismatch \( target) " )
123128 }
124129
130+ self . package = package
125131 self . clangTarget = clangTarget
126132 self . fileSystem = fileSystem
127133 self . target = target
Original file line number Diff line number Diff line change @@ -394,8 +394,13 @@ public class BuildPlan: SPMBuildCore.BuildPlan {
394394 )
395395 )
396396 case is ClangTarget :
397+ guard let package = graph. package ( for: target) else {
398+ throw InternalError ( " package not found for \( target) " )
399+ }
400+
397401 targetMap [ target. id] = try . clang(
398402 ClangTargetBuildDescription (
403+ package : package ,
399404 target: target,
400405 toolsVersion: toolsVersion,
401406 additionalFileRules: additionalFileRules,
Original file line number Diff line number Diff line change @@ -49,8 +49,33 @@ final class ClangTargetBuildDescriptionTests: XCTestCase {
4949
5050 private func makeTargetBuildDescription( ) throws -> ClangTargetBuildDescription {
5151 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+
5269 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,
5479 toolsVersion: . current,
5580 buildParameters: mockBuildParameters (
5681 toolchain: try UserToolchain . default,
You can’t perform that action at this time.
0 commit comments