@@ -4881,6 +4881,72 @@ import SWBMacro
4881
4881
}
4882
4882
}
4883
4883
4884
+ @Test func targetConditionalLocation( ) async throws {
4885
+ try await withTemporaryDirectory { ( tmpDir: Path ) in
4886
+ let testWorkspace = TestWorkspace (
4887
+ " Workspace " ,
4888
+ sourceRoot: tmpDir. join ( " Test " ) ,
4889
+ projects: [ TestPackageProject (
4890
+ " aProject " ,
4891
+ groupTree: TestGroup ( " SomeFiles " , children: [
4892
+ TestFile ( " Project.xcconfig " ) ,
4893
+ ] ) ,
4894
+ buildConfigurations: [
4895
+ TestBuildConfiguration (
4896
+ " Debug " ,
4897
+ baseConfig: " Project.xcconfig " ,
4898
+ buildSettings: [
4899
+ " SDKROOT " : " macosx " ,
4900
+ " OTHER_CFLAGS " : " $(inherited) Project " ,
4901
+ " OTHER_LDFLAGS[target=Target] " : " $(inherited) Project " ,
4902
+ " SUPPORTED_PLATFORMS " : " $(AVAILABLE_PLATFORMS) " ,
4903
+ " SUPPORTS_MACCATALYST " : " YES " ,
4904
+ ] )
4905
+ ] ,
4906
+ targets: [
4907
+ TestStandardTarget ( " Target " , type: . application) ,
4908
+ ] )
4909
+ ] )
4910
+ let workspace = try await testWorkspace. load ( getCore ( ) )
4911
+
4912
+ let context = try await contextForTestData ( workspace)
4913
+ let buildRequestContext = BuildRequestContext ( workspaceContext: context)
4914
+ let testProject = context. workspace. projects [ 0 ]
4915
+ let parameters = BuildParameters ( action: . build, configuration: " Debug " , activeRunDestination: . macOS)
4916
+
4917
+ let projectXcconfigPath = testWorkspace. sourceRoot. join ( " aProject/Project.xcconfig " )
4918
+ try await context. fs. writeFileContents ( projectXcconfigPath) { stream in
4919
+ stream <<<
4920
+ """
4921
+ OTHER_CFLAGS = XCConfig
4922
+ OTHER_LDFLAGS[target=Target] = XCConfig
4923
+ """
4924
+ }
4925
+
4926
+ do {
4927
+ let settings = Settings ( workspaceContext: context, buildRequestContext: buildRequestContext, parameters: parameters, project: testProject, target: testProject. targets [ 0 ] )
4928
+
4929
+ do {
4930
+ #expect( settings. globalScope. evaluate ( BuiltinMacros . OTHER_CFLAGS) == [ " XCConfig " , " Project " ] )
4931
+ let macro = settings. globalScope. table. lookupMacro ( BuiltinMacros . OTHER_CFLAGS)
4932
+ #expect( macro != nil )
4933
+ #expect( macro? . location == nil )
4934
+ #expect( macro? . next? . location == . init( path: projectXcconfigPath, startLine: 1 , endLine: 1 , startColumn: 15 , endColumn: 24 ) )
4935
+ #expect( macro? . next? . next == nil )
4936
+ }
4937
+
4938
+ do {
4939
+ #expect( settings. globalScope. evaluate ( BuiltinMacros . OTHER_LDFLAGS) == [ " XCConfig " , " Project " ] )
4940
+ let macro = settings. globalScope. table. lookupMacro ( BuiltinMacros . OTHER_LDFLAGS)
4941
+ #expect( macro != nil )
4942
+ #expect( macro? . location == nil )
4943
+ #expect( macro? . next? . location == . init( path: projectXcconfigPath, startLine: 2 , endLine: 2 , startColumn: 31 , endColumn: 40 ) )
4944
+ #expect( macro? . next? . next == nil )
4945
+ }
4946
+ }
4947
+ }
4948
+ }
4949
+
4884
4950
@Test ( . requireSDKs( . macOS, . iOS) )
4885
4951
func platformConditionals( ) async throws {
4886
4952
let testWorkspace = try await TestWorkspace (
0 commit comments