@@ -85,6 +85,19 @@ extension SwiftBuildSupport.PIF.Workspace {
8585} 
8686
8787extension  SwiftBuildSupport . PIF . Project  { 
88+     fileprivate  func  target( id:  String )  throws  ->  ProjectModel . BaseTarget  { 
89+         let  matchingTargets :  [ ProjectModel . BaseTarget ]  =  underlying. targets. filter  { 
90+             return  $0. common. id. value ==  String ( id) 
91+         } 
92+         if  matchingTargets. isEmpty { 
93+             throw  StringError ( " No target named  \( id)  in PIF project " ) 
94+         }  else  if  matchingTargets. count >  1  { 
95+             throw  StringError ( " Multiple target named  \( id)  in PIF project " ) 
96+         }  else  { 
97+             return  matchingTargets [ 0 ] 
98+         } 
99+     } 
100+ 
88101    fileprivate  func  target( named name:  String )  throws  ->  ProjectModel . BaseTarget  { 
89102        let  matchingTargets  =  underlying. targets. filter  { 
90103            $0. common. name ==  name
@@ -135,6 +148,28 @@ struct PIFBuilderTests {
135148        } 
136149    } 
137150
151+     @Test   func  platformCCLibrary( )  async  throws  { 
152+         try await  withGeneratedPIF ( fromFixture:  " PIFBuilder/CCPackage " )  {  pif,  observabilitySystem in 
153+             let  releaseConfig  =  try . workspace
154+                 . project ( named:  " CCPackage " ) 
155+                 . target ( id:  " PACKAGE-TARGET:CCTarget " ) 
156+                 . buildConfig ( named:  " Release " ) 
157+ 
158+             for  platform  in  ProjectModel . BuildSettings. Platform. allCases { 
159+                 let  ld_flags  =  releaseConfig. settings [ . OTHER_LDFLAGS,  platform] 
160+                 if  [ . macOS,  . macCatalyst,  . iOS,  . watchOS,  . tvOS,  . xrOS,  . driverKit,  . freebsd] . contains ( platform)  { 
161+                      #expect( ld_flags ==  [ " -lc++ " ,  " $(inherited) " ] ,  " for platform  \( platform) " ) 
162+                 }  else  if  [ . android,  . linux,  . wasi,  . openbsd] . contains ( platform)  { 
163+                     #expect( ld_flags ==  [ " -lstdc++ " ,  " $(inherited) " ] ,  " for platform  \( platform) " )                     
164+                 }  else  if  [ . windows,  . _iOSDevice] . contains ( platform)  { 
165+                     #expect( ld_flags ==  nil ,  " for platform  \( platform) " ) 
166+                 }  else  { 
167+                     Issue . record ( " Unexpected platform  \( platform) " ) 
168+                 } 
169+             } 
170+         } 
171+     } 
172+ 
138173    @Test   func  pluginWithBinaryTargetDependency( )  async  throws  { 
139174        try await  withGeneratedPIF ( fromFixture:  " Miscellaneous/Plugins/BinaryTargetExePlugin " )  {  pif,  observabilitySystem in 
140175            // Verify that PIF generation succeeds for a package with a plugin that depends on a binary target
0 commit comments