Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
@@ -0,0 +1,69 @@
<?xml version="1.0" encoding="UTF-8"?>
<Scheme
LastUpgradeVersion = "2600"
version = "1.7">
<BuildAction
parallelizeBuildables = "YES"
buildImplicitDependencies = "YES"
buildArchitectures = "Automatic">
<BuildActionEntries>
<BuildActionEntry
buildForTesting = "YES"
buildForRunning = "YES"
buildForProfiling = "YES"
buildForArchiving = "YES"
buildForAnalyzing = "YES">
<BuildableReference
BuildableIdentifier = "primary"
BlueprintIdentifier = "63A1B3E323FB4B26001B7732"
BuildableName = "SwiftFramework.framework"
BlueprintName = "SwiftFramework"
ReferencedContainer = "container:SwiftFramework.xcodeproj">
</BuildableReference>
</BuildActionEntry>
</BuildActionEntries>
</BuildAction>
<TestAction
buildConfiguration = "Debug"
selectedDebuggerIdentifier = "Xcode.DebuggerFoundation.Debugger.LLDB"
selectedLauncherIdentifier = "Xcode.DebuggerFoundation.Launcher.LLDB"
shouldUseLaunchSchemeArgsEnv = "YES"
shouldAutocreateTestPlan = "YES">
</TestAction>
<LaunchAction
buildConfiguration = "Debug"
selectedDebuggerIdentifier = "Xcode.DebuggerFoundation.Debugger.LLDB"
selectedLauncherIdentifier = "Xcode.DebuggerFoundation.Launcher.LLDB"
launchStyle = "0"
useCustomWorkingDirectory = "NO"
ignoresPersistentStateOnLaunch = "NO"
debugDocumentVersioning = "YES"
allowLocationSimulation = "YES">
</LaunchAction>
<ProfileAction
buildConfiguration = "Release"
shouldUseLaunchSchemeArgsEnv = "YES"
savedToolIdentifier = ""
useCustomWorkingDirectory = "NO"
debugDocumentVersioning = "YES">
<MacroExpansion>
<BuildableReference
BuildableIdentifier = "primary"
BlueprintIdentifier = "63A1B3E323FB4B26001B7732"
BuildableName = "SwiftFramework.framework"
BlueprintName = "SwiftFramework"
ReferencedContainer = "container:SwiftFramework.xcodeproj">
</BuildableReference>
</MacroExpansion>
</ProfileAction>
<AnalyzeAction
buildConfiguration = "Debug">
</AnalyzeAction>
<ArchiveAction
buildConfiguration = "Release"
revealArchiveInOrganizer = "YES">
</ArchiveAction>
<InstallAction
buildConfiguration = "Release">
</InstallAction>
</Scheme>
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ import struct Basics.SourceControlURL

import class PackageModel.Manifest
import class PackageModel.Module
import class PackageModel.BinaryModule
import class PackageModel.Product
import class PackageModel.SystemLibraryModule

Expand Down Expand Up @@ -629,8 +630,12 @@ extension PackagePIFProjectBuilder {
}

case .binary:
guard let binaryModule = moduleDependency.underlying as? BinaryModule else {
log(.error, "'\(moduleDependency.name)' is a binary dependency, but its underlying module was not")
break
}
let binaryReference = self.binaryGroup.addFileReference { id in
FileReference(id: id, path: moduleDependency.path.pathString)
FileReference(id: id, path: (binaryModule.artifactPath.pathString))
}
if shouldLinkProduct {
self.project[keyPath: sourceModuleTargetKeyPath].addLibrary { id in
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -339,8 +339,12 @@ extension PackagePIFProjectBuilder {

switch moduleDependency.type {
case .binary:
guard let binaryModule = moduleDependency.underlying as? BinaryModule else {
log(.error, "'\(moduleDependency.name)' is a binary dependency, but its underlying module was not")
break
}
let binaryFileRef = self.binaryGroup.addFileReference { id in
FileReference(id: id, path: moduleDependency.path.pathString)
FileReference(id: id, path: binaryModule.artifactPath.pathString)
}
let toolsVersion = self.package.manifest.toolsVersion
self.project[keyPath: mainModuleTargetKeyPath].addLibrary { id in
Expand Down Expand Up @@ -720,7 +724,7 @@ extension PackagePIFProjectBuilder {

if let binaryTarget = moduleDependency.underlying as? BinaryModule {
let binaryFileRef = self.binaryGroup.addFileReference { id in
FileReference(id: id, path: binaryTarget.path.pathString)
FileReference(id: id, path: binaryTarget.artifactPath.pathString)
}
let toolsVersion = package.manifest.toolsVersion
self.project[keyPath: libraryUmbrellaTargetKeyPath].addLibrary { id in
Expand Down
6 changes: 3 additions & 3 deletions Sources/_IntegrationTestSupport/Helpers.swift
Original file line number Diff line number Diff line change
Expand Up @@ -113,7 +113,7 @@ package func _sh(
}

public func binaryTargetsFixture(_ closure: (AbsolutePath) async throws -> Void) async throws {
try await fixture(name: "BinaryTargets") { fixturePath in
try await fixture(name: "BinaryTargets", removeFixturePathOnDeinit: false) { fixturePath in
let inputsPath = fixturePath.appending(component: "Inputs")
let packagePath = fixturePath.appending(component: "TestBinary")

Expand Down Expand Up @@ -157,7 +157,7 @@ public func binaryTargetsFixture(_ closure: (AbsolutePath) async throws -> Void)
let projectPath = subpath.appending(component: "SwiftFramework.xcodeproj")
try sh(
xcodebuild, "-project", projectPath, "-scheme", "SwiftFramework",
"-derivedDataPath", tmpDir, "COMPILER_INDEX_STORE_ENABLE=NO"
"-derivedDataPath", tmpDir, "COMPILER_INDEX_STORE_ENABLE=NO", "DEPLOYMENT_LOCATION=NO"
)
let frameworkPath = try AbsolutePath(
validating: "Build/Products/Debug/SwiftFramework.framework",
Expand Down Expand Up @@ -186,4 +186,4 @@ extension AsyncProcessResult {
\((try? utf8stderrOutput()) ?? "")
"""
}
}
}
92 changes: 43 additions & 49 deletions Tests/IntegrationTests/SwiftPMTests.swift
Original file line number Diff line number Diff line change
Expand Up @@ -20,65 +20,59 @@ import struct SPMBuildCore.BuildSystemProvider
.tags(Tag.TestSize.large)
)
private struct SwiftPMTests {
@Test(.requireHostOS(.macOS))
func binaryTargets() async throws {
await withKnownIssue("error: the path does not point to a valid framework:") {
try await binaryTargetsFixture { fixturePath in
do {
await withKnownIssue("error: local binary target ... does not contain a binary artifact") {
let runOutput = try await executeSwiftRun(
fixturePath,
"exe",
buildSystem: .native,
)
#expect(!runOutput.stderr.contains("error:"))
#expect(
runOutput.stdout == """
@Test(.requireHostOS(.macOS), arguments: [BuildSystemProvider.Kind.native, .swiftbuild])
func binaryTargets(buildSystem: BuildSystemProvider.Kind) async throws {
try await binaryTargetsFixture { fixturePath in
do {
let runOutput = try await executeSwiftRun(
fixturePath,
"exe",
buildSystem: buildSystem,
)
#expect(!runOutput.stderr.contains("error:"))
#expect(
runOutput.stdout == """
SwiftFramework()
Library(framework: SwiftFramework.SwiftFramework())

"""
)
}
}

do {
await withKnownIssue("error: local binary target ... does not contain a binary artifact") {
let runOutput = try await executeSwiftRun(fixturePath, "cexe", buildSystem: .native)
#expect(!runOutput.stderr.contains("error:"))
#expect(runOutput.stdout.contains("<CLibrary: "))
}
}
)
}

do {
let invalidPath = fixturePath.appending(component: "SwiftFramework.xcframework")
do {
let runOutput = try await executeSwiftRun(fixturePath, "cexe", buildSystem: buildSystem)
#expect(!runOutput.stderr.contains("error:"))
#expect(runOutput.stdout.contains("<CLibrary: "))
}

await #expect {
try await executeSwiftPackage(
fixturePath,
extraArgs: ["compute-checksum", invalidPath.pathString],
buildSystem: .native,
)
} throws: { error in
// The order of supported extensions is not ordered, and changes.
// '...supported extensions are: zip, tar.gz, tar'
// '...supported extensions are: tar.gz, zip, tar'
// Only check for the start of that string.
// TODO: error.stderr.contains("error: unexpected file type; supported extensions are:")
return true
}
do {
let invalidPath = fixturePath.appending(component: "SwiftFramework.xcframework")

let validPath = fixturePath.appending(component: "SwiftFramework.zip")
let packageOutput = try await executeSwiftPackage(
await #expect {
try await executeSwiftPackage(
fixturePath,
extraArgs: ["compute-checksum", validPath.pathString],
extraArgs: ["compute-checksum", invalidPath.pathString],
buildSystem: .native,
)
#expect(
packageOutput.stdout.spm_chomp()
== "d1f202b1bfe04dea30b2bc4038f8059dcd75a5a176f1d81fcaedb6d3597d1158"
)
} throws: { error in
// The order of supported extensions is not ordered, and changes.
// '...supported extensions are: zip, tar.gz, tar'
// '...supported extensions are: tar.gz, zip, tar'
// Only check for the start of that string.
// TODO: error.stderr.contains("error: unexpected file type; supported extensions are:")
return true
}

let validPath = fixturePath.appending(component: "SwiftFramework.zip")
let packageOutput = try await executeSwiftPackage(
fixturePath,
extraArgs: ["compute-checksum", validPath.pathString],
buildSystem: .native,
)
#expect(
packageOutput.stdout.spm_chomp()
== "d1f202b1bfe04dea30b2bc4038f8059dcd75a5a176f1d81fcaedb6d3597d1158"
)
}
}
}
Expand Down