@@ -6738,4 +6738,108 @@ final class BuildPlanTests: XCTestCase {
6738
6738
)
6739
6739
}
6740
6740
}
6741
+
6742
+ func testProductWithBinaryArtifactDependency( ) async throws {
6743
+ #if !os(macOS)
6744
+ try XCTSkipIf ( true , " Test is only supported on macOS " )
6745
+ #endif
6746
+
6747
+ let fs = InMemoryFileSystem (
6748
+ emptyFiles:
6749
+ " /testpackage/Sources/SwiftLib/lib.swift " ,
6750
+ " /testpackage/Sources/CLib/include/lib.h " ,
6751
+ " /testpackage/Sources/CLib/lib.c "
6752
+ )
6753
+
6754
+ try fs. createDirectory ( " /testpackagedep/SomeArtifact.xcframework " , recursive: true )
6755
+ try fs. writeFileContents (
6756
+ " /testpackagedep/SomeArtifact.xcframework/Info.plist " ,
6757
+ string: """
6758
+ <?xml version= " 1.0 " encoding= " UTF-8 " ?>
6759
+ <!DOCTYPE plist PUBLIC " -//Apple//DTD PLIST 1.0//EN " " http://www.apple.com/DTDs/PropertyList-1.0.dtd " >
6760
+ <plist version= " 1.0 " >
6761
+ <dict>
6762
+ <key>AvailableLibraries</key>
6763
+ <array>
6764
+ <dict>
6765
+ <key>LibraryIdentifier</key>
6766
+ <string>macos</string>
6767
+ <key>HeadersPath</key>
6768
+ <string>Headers</string>
6769
+ <key>LibraryPath</key>
6770
+ <string>libSomeArtifact.a</string>
6771
+ <key>SupportedArchitectures</key>
6772
+ <array>
6773
+ <string>arm64</string>
6774
+ <string>x86_64</string>
6775
+ </array>
6776
+ <key>SupportedPlatform</key>
6777
+ <string>macos</string>
6778
+ </dict>
6779
+ </array>
6780
+ <key>CFBundlePackageType</key>
6781
+ <string>XFWK</string>
6782
+ <key>XCFrameworkFormatVersion</key>
6783
+ <string>1.0</string>
6784
+ </dict>
6785
+ </plist>
6786
+ """
6787
+ )
6788
+
6789
+ let observability = ObservabilitySystem . makeForTesting ( )
6790
+ let graph = try loadModulesGraph (
6791
+ fileSystem: fs,
6792
+ manifests: [
6793
+ Manifest . createFileSystemManifest (
6794
+ displayName: " testpackagedep " ,
6795
+ path: " /testpackagedep " ,
6796
+ products: [
6797
+ ProductDescription ( name: " SomeArtifact " , type: . library( . static) , targets: [ " SomeArtifact " ] ) ,
6798
+ ] ,
6799
+ targets: [
6800
+ TargetDescription ( name: " SomeArtifact " , path: " SomeArtifact.xcframework " , type: . binary) ,
6801
+ ]
6802
+ ) ,
6803
+ Manifest . createRootManifest (
6804
+ displayName: " testpackage " ,
6805
+ path: " /testpackage " ,
6806
+ dependencies: [
6807
+ . localSourceControl( path: " /testpackagedep " , requirement: . upToNextMajor( from: " 1.0.0 " ) ) ,
6808
+ ] ,
6809
+ products: [
6810
+ ProductDescription ( name: " SwiftLib " , type: . library( . static) , targets: [ " SwiftLib " ] ) ,
6811
+ ProductDescription ( name: " CLib " , type: . library( . static) , targets: [ " CLib " ] ) ,
6812
+ ] ,
6813
+ targets: [
6814
+ TargetDescription ( name: " SwiftLib " , dependencies: [ " SomeArtifact " ] ) ,
6815
+ TargetDescription ( name: " CLib " , dependencies: [ " SomeArtifact " ] )
6816
+ ]
6817
+ ) ,
6818
+ ] ,
6819
+ binaryArtifacts: [
6820
+ . plain( " testpackagedep " ) : [
6821
+ " SomeArtifact " : . init( kind: . xcframework, originURL: nil , path: " /testpackagedep/SomeArtifact.xcframework " ) ,
6822
+ ] ,
6823
+ ] ,
6824
+ observabilityScope: observability. topScope
6825
+ )
6826
+ XCTAssertNoDiagnostics ( observability. diagnostics)
6827
+
6828
+ let plan = try await mockBuildPlan (
6829
+ graph: graph,
6830
+ fileSystem: fs,
6831
+ observabilityScope: observability. topScope
6832
+ )
6833
+
6834
+ let llbuild = LLBuildManifestBuilder (
6835
+ plan,
6836
+ fileSystem: fs,
6837
+ observabilityScope: observability. topScope
6838
+ )
6839
+ try llbuild. generateManifest ( at: " /manifest.yaml " )
6840
+ let contents : String = try fs. readFileContents ( " /manifest.yaml " )
6841
+
6842
+ XCTAssertMatch ( contents, . regex( #"args: \[.*"-I","/testpackagedep/SomeArtifact.xcframework/macos/Headers".*,"/testpackage/Sources/CLib/lib.c".*]"# ) )
6843
+ XCTAssertMatch ( contents, . regex( #"args: \[.*"-module-name","SwiftLib",.*"-I","/testpackagedep/SomeArtifact.xcframework/macos/Headers".*]"# ) )
6844
+ }
6741
6845
}
0 commit comments