Skip to content

Testing Windows CI #165

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

Closed
wants to merge 5 commits into from
Closed
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
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
Swift Build
aSwift Build
=======

Swift Build is a high-level build system based on [llbuild](https://github.com/swiftlang/swift-llbuild) with great support for building Swift. It is used by Xcode to build Xcode projects and Swift packages, and by Swift Playground. It can also be used as the Swift Package Manager build system in preview form when passing `--build-system swiftbuild`.
Expand Down
15 changes: 10 additions & 5 deletions Sources/SWBCore/ToolchainRegistry.swift
Original file line number Diff line number Diff line change
Expand Up @@ -274,6 +274,7 @@ public final class Toolchain: Hashable, Sendable {
defaultSettingsWhenPrimary = settingsItems
}
defaultSettingsWhenPrimary["TOOLCHAIN_DIR"] = .plString(path.str)
defaultSettingsWhenPrimary["TOOLCHAIN_VERSION"] = .plString(version.description)

var executableSearchPaths = [
path.join("usr").join("bin"),
Expand Down Expand Up @@ -507,15 +508,19 @@ public final class ToolchainRegistry: @unchecked Sendable {
/// Look up the toolchain with the given identifier.
public func lookup(_ identifier: String) -> Toolchain? {
let lowercasedIdentifier = identifier.lowercased()
if ["default", "xcode"].contains(lowercasedIdentifier) {
if hostOperatingSystem == .macOS {
if hostOperatingSystem == .macOS {
if ["default", "xcode"].contains(lowercasedIdentifier) {
return toolchainsByIdentifier[ToolchainRegistry.defaultToolchainIdentifier] ?? toolchainsByAlias[lowercasedIdentifier]
} else {
// On non-Darwin, assume if there is only one registered toolchain, it is the default.
return toolchainsByIdentifier[ToolchainRegistry.defaultToolchainIdentifier] ?? toolchainsByAlias[lowercasedIdentifier] ?? toolchainsByIdentifier.values.only
return toolchainsByIdentifier[identifier] ?? toolchainsByAlias[lowercasedIdentifier]
}
} else {
return toolchainsByIdentifier[identifier] ?? toolchainsByAlias[lowercasedIdentifier]
// On non-Darwin, assume if there is only one registered toolchain, it is the default.
if ["default", "xcode"].contains(lowercasedIdentifier) || identifier == ToolchainRegistry.defaultToolchainIdentifier {
return toolchainsByIdentifier[ToolchainRegistry.defaultToolchainIdentifier] ?? toolchainsByAlias[lowercasedIdentifier] ?? toolchainsByIdentifier.values.only
} else {
return toolchainsByIdentifier[identifier] ?? toolchainsByAlias[lowercasedIdentifier]
}
}
}

Expand Down
6 changes: 6 additions & 0 deletions Sources/SWBWindowsPlatform/WindowsLibtool.xcspec
Original file line number Diff line number Diff line change
Expand Up @@ -46,9 +46,15 @@
Type = Path;
DefaultValue = "llvm-lib.exe";
},
{
Name = "LIBTOOL_USE_RESPONSE_FILE";
Type = Boolean;
DefaultValue = YES;
},
{
Name = __INPUT_FILE_LIST_PATH__;
Type = Path;
Condition = "$(LIBTOOL_USE_RESPONSE_FILE)";
// this is set up for us as a read-only property
DefaultValue = "$(LINK_FILE_LIST_$(variant)_$(arch))";
CommandLineArgs = (
Expand Down
2 changes: 1 addition & 1 deletion Tests/SWBCoreTests/CoreTests.swift
Original file line number Diff line number Diff line change
Expand Up @@ -178,7 +178,7 @@ import Foundation
}
}

@Test
@Test(.requireHostOS(.macOS))
func toolchainLoading() async throws {
// Validate that we loaded the default toolchain.
let defaultToolchain = try #require(await getCore().toolchainRegistry.lookup("default"), "no default toolchain")
Expand Down
2 changes: 1 addition & 1 deletion Tests/SWBCoreTests/ShellScriptEnvironmentTests.swift
Original file line number Diff line number Diff line change
Expand Up @@ -157,7 +157,7 @@ import SWBTestSupport
}

/// Test that default and overriding build settings defined in a toolchain are exported.
@Test(.skipIfEnvironmentVariableSet(key: "EXTERNAL_TOOLCHAINS_DIR"))
@Test(.requireHostOS(.macOS), .skipIfEnvironmentVariableSet(key: "EXTERNAL_TOOLCHAINS_DIR"))
func exportingToolchainSettings() async throws {
try await withTemporaryDirectory { tmpDirPath in
// Toolchains are only loaded from the localFS, so we can't use a PseudoFS here.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3932,12 +3932,11 @@ fileprivate struct SwiftTaskConstructionTests: CoreBasedTests {
targets: [
TestStandardTarget(
"TargetName",
type: .framework,
type: .dynamicLibrary,
buildConfigurations: [
TestBuildConfiguration("Debug", buildSettings: [
"SWIFT_WARNINGS_AS_WARNINGS_GROUPS": "Unsafe DeprecatedDeclaration",
"SWIFT_EXEC": swiftCompilerPath.str,
"CODE_SIGN_IDENTITY": "",
"SDKROOT": "$(HOST_PLATFORM)",
"SUPPORTED_PLATFORMS": "$(HOST_PLATFORM)",
]),
Expand Down Expand Up @@ -3978,12 +3977,11 @@ fileprivate struct SwiftTaskConstructionTests: CoreBasedTests {
targets: [
TestStandardTarget(
"TargetName",
type: .framework,
type: .dynamicLibrary,
buildConfigurations: [
TestBuildConfiguration("Debug", buildSettings: [
"SWIFT_WARNINGS_AS_ERRORS_GROUPS": "UnknownWarningGroup PreconcurrencyImport",
"SWIFT_EXEC": swiftCompilerPath.str,
"CODE_SIGN_IDENTITY": "",
"SDKROOT": "$(HOST_PLATFORM)",
"SUPPORTED_PLATFORMS": "$(HOST_PLATFORM)",
]),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ fileprivate struct ServiceConsoleTests {
let output = String(decoding: data, as: UTF8.self)

// Verify there were no errors.
#expect(output == "swbuild> \n")
#expect(output == "swbuild> \(String.newline)")

// Assert the tool exited successfully.
await #expect(try promise.value == .exit(0))
Expand Down