Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix missing lib/ directory in Ubuntu Noble SDK, remove unused toolchain components #193

Merged
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
Expand Up @@ -16,6 +16,14 @@ import SystemPackage
import struct Foundation.Data

extension SwiftSDKGenerator {
func createLibSymlink(sdkDirPath: FilePath) throws {
let libPath = sdkDirPath.appending("lib")
if !doesFileExist(at: libPath) {
logger.info("Adding lib symlink to usr/lib...")
try createSymlink(at: libPath, pointingTo: "usr/lib")
}
}

func fixAbsoluteSymlinks(sdkDirPath: FilePath) throws {
logger.info("Fixing up absolute symlinks...")

Expand Down
9 changes: 9 additions & 0 deletions Sources/SwiftSDKGenerator/SwiftSDKRecipes/LinuxRecipe.swift
Original file line number Diff line number Diff line change
Expand Up @@ -294,6 +294,15 @@ public struct LinuxRecipe: SwiftSDKRecipe {
)
}

logger.info("Removing unused toolchain components from target SDK...")
try await generator.removeToolchainComponents(
sdkDirPath,
platforms: unusedTargetPlatforms,
libraries: unusedHostLibraries,
binaries: unusedHostBinaries
)

try await generator.createLibSymlink(sdkDirPath: sdkDirPath)
try await generator.fixAbsoluteSymlinks(sdkDirPath: sdkDirPath)

// Swift 6.1 and later do not throw warnings about the SDKSettings.json file missing,
Expand Down
9 changes: 8 additions & 1 deletion Tests/SwiftSDKGeneratorTests/EndToEndTests.swift
Original file line number Diff line number Diff line change
Expand Up @@ -151,10 +151,11 @@ final class RepeatedBuildTests: XCTestCase {
struct SDKConfiguration {
var swiftVersion: String
var linuxDistributionName: String
var linuxDistributionVersion: String
var architecture: String
var withDocker: Bool

var bundleName: String { "\(linuxDistributionName)_\(architecture)_\(swiftVersion)-RELEASE\(withDocker ? "_with-docker" : "")" }
var bundleName: String { "\(linuxDistributionName)_\(linuxDistributionVersion)_\(architecture)_\(swiftVersion)-RELEASE\(withDocker ? "_with-docker" : "")" }

func withDocker(_ enabled: Bool = true) -> SDKConfiguration {
var res = self
Expand Down Expand Up @@ -308,6 +309,7 @@ final class Swift59_UbuntuEndToEndTests: XCTestCase {
let config = SDKConfiguration(
swiftVersion: "5.9.2",
linuxDistributionName: "ubuntu",
linuxDistributionVersion: "22.04",
architecture: "aarch64",
withDocker: false
)
Expand Down Expand Up @@ -337,6 +339,7 @@ final class Swift510_UbuntuEndToEndTests: XCTestCase {
let config = SDKConfiguration(
swiftVersion: "5.10.1",
linuxDistributionName: "ubuntu",
linuxDistributionVersion: "22.04",
architecture: "aarch64",
withDocker: false
)
Expand Down Expand Up @@ -366,6 +369,7 @@ final class Swift60_UbuntuEndToEndTests: XCTestCase {
let config = SDKConfiguration(
swiftVersion: "6.0.3",
linuxDistributionName: "ubuntu",
linuxDistributionVersion: "24.04",
architecture: "aarch64",
withDocker: false
)
Expand Down Expand Up @@ -395,6 +399,7 @@ final class Swift59_RHELEndToEndTests: XCTestCase {
let config = SDKConfiguration(
swiftVersion: "5.9.2",
linuxDistributionName: "rhel",
linuxDistributionVersion: "ubi9",
architecture: "aarch64",
withDocker: true // RHEL-based SDKs can only be built from containers
)
Expand All @@ -414,6 +419,7 @@ final class Swift510_RHELEndToEndTests: XCTestCase {
let config = SDKConfiguration(
swiftVersion: "5.10.1",
linuxDistributionName: "rhel",
linuxDistributionVersion: "ubi9",
architecture: "aarch64",
withDocker: true // RHEL-based SDKs can only be built from containers
)
Expand All @@ -433,6 +439,7 @@ final class Swift60_RHELEndToEndTests: XCTestCase {
let config = SDKConfiguration(
swiftVersion: "6.0.3",
linuxDistributionName: "rhel",
linuxDistributionVersion: "ubi9",
architecture: "aarch64",
withDocker: true // RHEL-based SDKs can only be built from containers
)
Expand Down