Skip to content

Commit 2a76401

Browse files
committed
Simplify build command
1 parent 2e1defb commit 2a76401

1 file changed

Lines changed: 10 additions & 22 deletions

File tree

Plugins/VercelPackager/VercelOutput.swift

Lines changed: 10 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -504,6 +504,14 @@ extension VercelOutput {
504504

505505
extension VercelOutput {
506506

507+
public var swiftBuildDirectory: Path {
508+
projectDirectory.appending(".build")
509+
}
510+
511+
public var swiftBuildReleaseDirectory: Path {
512+
swiftBuildDirectory.appending("release")
513+
}
514+
507515
public func buildProduct(_ product: Product) async throws -> Path {
508516
print("")
509517
print("-------------------------------------------------------------------------")
@@ -544,26 +552,6 @@ extension VercelOutput {
544552
private func buildDockerProduct(_ product: Product) async throws -> Path {
545553
let dockerToolPath = try context.tool(named: "docker").path
546554
let baseImage = "swift:\(context.package.toolsVersion.major).\(context.package.toolsVersion.minor)-amazonlinux2"
547-
let buildCommand = "swift build -c release -Xswiftc -Osize -Xlinker -S --product \(product.name) --static-swift-stdlib"
548-
549-
// get the build output path
550-
let buildOutputPathCommand = "\(buildCommand) --show-bin-path"
551-
let dockerBuildOutputPath = try Shell.execute(
552-
executable: dockerToolPath,
553-
arguments: [
554-
"run",
555-
"--platform", "linux/\(architecture.rawValue)",
556-
"--rm",
557-
"-v", "\(context.package.directory.string):/workspace",
558-
"-w", "/workspace",
559-
baseImage,
560-
"bash", "-cl", buildOutputPathCommand
561-
]
562-
)
563-
guard let buildPathOutput = dockerBuildOutputPath.split(separator: "\n").last else {
564-
throw BuildError.failedParsingDockerOutput(dockerBuildOutputPath)
565-
}
566-
let buildOutputPath = Path(buildPathOutput.replacingOccurrences(of: "/workspace", with: context.package.directory.string))
567555

568556
// build the product
569557
try Shell.execute(
@@ -575,12 +563,12 @@ extension VercelOutput {
575563
"-v", "\(context.package.directory.string):/workspace",
576564
"-w", "/workspace",
577565
baseImage,
578-
"bash", "-cl", buildCommand
566+
"bash", "-cl", "swift build -c release --static-swift-stdlib"
579567
]
580568
)
581569

582570
// ensure the final binary built correctly
583-
let productPath = buildOutputPath.appending(product.name)
571+
let productPath = swiftBuildReleaseDirectory.appending(product.name)
584572
guard fs.fileExists(atPath: productPath.string) else {
585573
Diagnostics.error("expected '\(product.name)' binary at \"\(productPath.string)\"")
586574
throw BuildError.productExecutableNotFound(product.name)

0 commit comments

Comments
 (0)