Skip to content

Commit 603e445

Browse files
Merge branch 'main' into automerge/merge-main-2025-09-01_09-02
2 parents da52352 + 04ca32d commit 603e445

File tree

271 files changed

+9059
-2169
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

271 files changed

+9059
-2169
lines changed

.editorconfig

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,3 +11,6 @@ xcode_trim_whitespace_on_empty_lines = true
1111

1212
[*.{yml,yaml}]
1313
indent_size = 2
14+
15+
[CMakeLists.txt]
16+
indent_size = 2

.github/scripts/linux_pre_build.sh

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -31,16 +31,16 @@ if command -v apt-get >/dev/null 2>&1 ; then # bookworm, noble, jammy
3131
# Android NDK
3232
dpkg_architecture="$(dpkg --print-architecture)"
3333
if [[ "$SKIP_ANDROID" != "1" ]] && [[ "$dpkg_architecture" == amd64 ]] ; then
34-
eval "$(cat /etc/lsb-release)"
35-
case "$DISTRIB_CODENAME" in
34+
eval "$(cat /etc/os-release)"
35+
case "$VERSION_CODENAME" in
3636
bookworm|jammy)
3737
: # Not available
3838
;;
3939
noble)
4040
apt-get install -y google-android-ndk-r26c-installer
4141
;;
4242
*)
43-
echo "Unknown distribution: $DISTRIB_CODENAME" >&2
43+
echo "Unable to fetch Android NDK for unknown Linux distribution: $VERSION_CODENAME" >&2
4444
exit 1
4545
esac
4646
else

.github/workflows/automerge.yml

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,8 @@ jobs:
1010
name: Create PR to merge main into release branch
1111
uses: swiftlang/github-workflows/.github/workflows/create_automerge_pr.yml@main
1212
with:
13-
base_branch: release/6.2
13+
head_branch: release/6.2
14+
base_branch: main
1415
permissions:
1516
contents: write
1617
pull-requests: write

.github/workflows/pull_request.yml

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -13,12 +13,14 @@ jobs:
1313
name: Test
1414
uses: swiftlang/github-workflows/.github/workflows/swift_package_test.yml@main
1515
with:
16-
linux_os_versions: '["noble", "jammy", "rhel-ubi9"]'
16+
linux_os_versions: '["amazonlinux2", "bookworm", "noble", "jammy", "rhel-ubi9"]'
1717
linux_pre_build_command: ./.github/scripts/linux_pre_build.sh
1818
linux_build_command: 'swift test --no-parallel'
1919
linux_swift_versions: '["nightly-main", "nightly-6.2"]'
2020
windows_swift_versions: '["nightly-main"]'
21-
windows_build_command: 'swift test --no-parallel'
21+
windows_build_command: 'Invoke-Program swift test --no-parallel'
22+
enable_linux_static_sdk_build: true
23+
linux_static_sdk_build_command: SWIFTBUILD_STATIC_LINK=1 LLBUILD_STATIC_LINK=1 swift build
2224
cmake-smoke-test:
2325
name: cmake-smoke-test
2426
uses: swiftlang/github-workflows/.github/workflows/swift_package_test.yml@main

.licenseignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,5 +5,6 @@
55
**/Package.swift
66
.dir-locals.el
77
.editorconfig
8+
.swift-version
89
CODEOWNERS
910
Package.swift

.swift-version

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
6.1.0

Package.swift

Lines changed: 16 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@ let appleOS = true
2020
let appleOS = false
2121
#endif
2222

23+
let isStaticBuild = Context.environment["SWIFTBUILD_STATIC_LINK"] != nil
2324
let useLocalDependencies = Context.environment["SWIFTCI_USE_LOCAL_DEPS"] != nil
2425
let useLLBuildFramework = Context.environment["SWIFTBUILD_LLBUILD_FWK"] != nil
2526

@@ -70,7 +71,11 @@ func swiftSettings(languageMode: SwiftLanguageMode) -> [SwiftSetting] {
7071
let package = Package(
7172
name: "SwiftBuild",
7273
defaultLocalization: "en",
73-
platforms: [.macOS("13.0"), .iOS("17.0"), .macCatalyst("17.0")],
74+
platforms: [
75+
.macOS(.v14),
76+
.iOS("17.0"),
77+
.macCatalyst("17.0"),
78+
],
7479
products: [
7580
.executable(name: "swbuild", targets: ["swbuild"]),
7681
.executable(name: "SWBBuildServiceBundle", targets: ["SWBBuildServiceBundle"]),
@@ -204,7 +209,7 @@ let package = Package(
204209
.product(name: "SystemPackage", package: "swift-system", condition: .when(platforms: [.linux, .openbsd, .android, .windows, .custom("freebsd")])),
205210
],
206211
exclude: ["CMakeLists.txt"],
207-
swiftSettings: swiftSettings(languageMode: .v5)),
212+
swiftSettings: swiftSettings(languageMode: .v6)),
208213
.target(
209214
name: "SWBCAS",
210215
dependencies: ["SWBUtil", "SWBCSupport"],
@@ -369,7 +374,7 @@ let package = Package(
369374
// Perf tests
370375
.testTarget(
371376
name: "SWBBuildSystemPerfTests",
372-
dependencies: ["SWBBuildSystem", "SWBTestSupport"],
377+
dependencies: ["SWBBuildSystem", "SWBTestSupport", "SwiftBuildTestSupport"],
373378
swiftSettings: swiftSettings(languageMode: .v6)),
374379
.testTarget(
375380
name: "SWBCASPerfTests",
@@ -443,6 +448,12 @@ for target in package.targets {
443448
}
444449
}
445450

451+
if isStaticBuild {
452+
package.targets = package.targets.filter { target in
453+
target.type != .test && !target.name.hasSuffix("TestSupport")
454+
}
455+
}
456+
446457
// `SWIFTCI_USE_LOCAL_DEPS` configures if dependencies are locally available to build
447458
if useLocalDependencies {
448459
package.dependencies += [
@@ -455,11 +466,11 @@ if useLocalDependencies {
455466
}
456467
} else {
457468
package.dependencies += [
458-
.package(url: "https://github.com/swiftlang/swift-driver.git", branch: "release/6.2"),
469+
.package(url: "https://github.com/swiftlang/swift-driver.git", branch: "main"),
459470
.package(url: "https://github.com/apple/swift-system.git", .upToNextMajor(from: "1.5.0")),
460471
.package(url: "https://github.com/apple/swift-argument-parser.git", from: "1.0.3"),
461472
]
462473
if !useLLBuildFramework {
463-
package.dependencies += [.package(url: "https://github.com/swiftlang/swift-llbuild.git", branch: "release/6.2"),]
474+
package.dependencies += [.package(url: "https://github.com/swiftlang/swift-llbuild.git", branch: "main"),]
464475
}
465476
}

README.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -12,11 +12,11 @@ When building SwiftPM from sources which include Swift Build integration, passin
1212

1313
### With Xcode
1414

15-
Changes to swift-build can also be tested in Xcode using the `launch-xcode` command plugin provided by the package. Run `swift package --disable-sandbox launch-xcode` from your checkout of swift-build to launch a copy of the currently `xcode-select`ed Xcode.app configured to use your modified copy of the build system service. This workflow is currently supported when using Xcode 16.2.
15+
Changes to swift-build can also be tested in Xcode using the `launch-xcode` command plugin provided by the package. Run `swift package --disable-sandbox launch-xcode` from your checkout of swift-build to launch a copy of the currently `xcode-select`ed Xcode.app configured to use your modified copy of the build system service. This workflow is generally only supported when using the latest available Xcode version.
1616

1717
### With xcodebuild
1818

19-
Changes to swift-build can also be tested in xcodebuild using the `run-xcodebuild` command plugin provided by the package. Run `swift package --disable-sandbox run-xcodebuild` from your checkout of swift-build to run xcodebuild from the currently `xcode-select`ed Xcode.app configured to use your modified copy of the build system service. Arguments followed by `--` will be forwarded to xcodebuild unmodified. This workflow is currently supported when using Xcode 16.2.
19+
Changes to swift-build can also be tested in xcodebuild using the `run-xcodebuild` command plugin provided by the package. Run `swift package --disable-sandbox run-xcodebuild` from your checkout of swift-build to run xcodebuild from the currently `xcode-select`ed Xcode.app configured to use your modified copy of the build system service. Arguments followed by `--` will be forwarded to xcodebuild unmodified. This workflow is generally only supported when using the latest available Xcode version.
2020

2121
### Debugging
2222

Sources/SWBAndroidPlatform/AndroidSDK.swift

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -57,10 +57,6 @@ public import Foundation
5757

5858
let metaPath = ndkPath.path.join("meta")
5959

60-
guard #available(macOS 14, *) else {
61-
throw StubError.error("Unsupported macOS version")
62-
}
63-
6460
if version < Self.minimumNDKVersion {
6561
throw Error.unsupportedVersion(path: ndkPath, minimumVersion: Self.minimumNDKVersion)
6662
}

Sources/SWBAndroidPlatform/Plugin.swift

Lines changed: 43 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ public import SWBCore
1515
import SWBMacro
1616
import Foundation
1717

18-
@PluginExtensionSystemActor public func initializePlugin(_ manager: PluginManager) {
18+
public let initializePlugin: PluginInitializationFunction = { manager in
1919
let plugin = AndroidPlugin()
2020
manager.register(AndroidPlatformSpecsExtension(), type: SpecificationsExtensionPoint.self)
2121
manager.register(AndroidEnvironmentExtension(plugin: plugin), type: EnvironmentExtensionPoint.self)
@@ -149,26 +149,44 @@ struct AndroidPlatformExtension: PlatformInfoExtension {
149149
hostOperatingSystem: context.hostOperatingSystem
150150
)) ?? []
151151

152-
let swiftSettings: [String: PropertyListItem]
153-
// FIXME: We need a way to narrow down the list, possibly by passing down a Swift SDK identifier from SwiftPM
154-
// The resource path should be the same for all triples in an Android Swift SDK
155-
if let androidSwiftSDK = androidSwiftSDKs.only, let swiftResourceDir = Set(androidSwiftSDK.targetTriples.values.map { tripleProperties in androidSwiftSDK.path.join(tripleProperties.swiftResourcesPath) }).only {
156-
swiftSettings = [
157-
"SWIFT_LIBRARY_PATH": .plString(swiftResourceDir.join("android").str),
158-
"SWIFT_RESOURCE_DIR": .plString(swiftResourceDir.str),
159-
"SWIFT_TARGET_TRIPLE": .plString("$(CURRENT_ARCH)-unknown-$(SWIFT_PLATFORM_TARGET_PREFIX)$(LLVM_TARGET_TRIPLE_SUFFIX)"),
160-
"LIBRARY_SEARCH_PATHS": "$(inherited) $(SWIFT_RESOURCE_DIR)/../$(__ANDROID_TRIPLE_$(CURRENT_ARCH))",
161-
].merging(abis.map {
162-
("__ANDROID_TRIPLE_\($0.value.llvm_triple.arch)", .plString($0.value.triple))
163-
}, uniquingKeysWith: { _, new in new })
164-
} else {
165-
swiftSettings = [:]
166-
}
152+
return try androidSwiftSDKs.map { androidSwiftSDK in
153+
let perArchSwiftResourceDirs = try Dictionary(grouping: androidSwiftSDK.targetTriples, by: { try LLVMTriple($0.key).arch }).mapValues {
154+
let paths = Set($0.compactMap { $0.value.swiftResourcesPath })
155+
guard let path = paths.only else {
156+
throw StubError.error("The resource path should be the same for all triples of the same architecture in an Android Swift SDK")
157+
}
158+
return Path(path)
159+
}
160+
161+
return sdk(
162+
canonicalName: androidSwiftSDK.identifier,
163+
androidPlatform: androidPlatform,
164+
androidNdk: androidNdk,
165+
defaultProperties: defaultProperties,
166+
customProperties: [
167+
"SWIFT_TARGET_TRIPLE": .plString("$(CURRENT_ARCH)-unknown-$(SWIFT_PLATFORM_TARGET_PREFIX)$(LLVM_TARGET_TRIPLE_SUFFIX)"),
168+
"LIBRARY_SEARCH_PATHS": "$(inherited) $(SWIFT_RESOURCE_DIR)/../$(__ANDROID_TRIPLE_$(CURRENT_ARCH))",
169+
].merging(perArchSwiftResourceDirs.map {
170+
[
171+
("SWIFT_LIBRARY_PATH[arch=\($0.key)]", .plString($0.value.join("android").str)),
172+
("SWIFT_RESOURCE_DIR[arch=\($0.key)]", .plString($0.value.str)),
173+
]
174+
}.flatMap { $0 }, uniquingKeysWith: { _, new in new }).merging(abis.map {
175+
("__ANDROID_TRIPLE_\($0.value.llvm_triple.arch)", .plString($0.value.triple))
176+
}, uniquingKeysWith: { _, new in new }))
177+
} + [
178+
// Fallback SDK for when there are no Swift SDKs (Android SDK is still usable for C/C++-only code)
179+
sdk(androidPlatform: androidPlatform, androidNdk: androidNdk, defaultProperties: defaultProperties)
180+
]
181+
}
167182

168-
return [(androidNdk.sysroot.path, androidPlatform, [
183+
private func sdk(canonicalName: String? = nil, androidPlatform: Platform, androidNdk: AndroidSDK.NDK, defaultProperties: [String: PropertyListItem], customProperties: [String: PropertyListItem] = [:]) -> (path: Path, platform: SWBCore.Platform?, data: [String: PropertyListItem]) {
184+
return (androidNdk.sysroot.path, androidPlatform, [
169185
"Type": .plString("SDK"),
170-
"Version": .plString("0.0.0"),
171-
"CanonicalName": .plString("android"),
186+
"Version": .plString(androidNdk.version.description),
187+
"CanonicalName": .plString(canonicalName ?? "android\(androidNdk.version.description)"),
188+
// "android.ndk" is an alias for the "Android SDK without a Swift SDK" scenario in order for tests to deterministically pick a single Android destination regardless of how many Android Swift SDKs may be installed.
189+
"Aliases": .plArray([.plString("android")] + (canonicalName == nil ? [.plString("android.ndk")] : [])),
172190
"IsBaseSDK": .plBool(true),
173191
"DefaultProperties": .plDict([
174192
"PLATFORM_NAME": .plString("android"),
@@ -178,14 +196,14 @@ struct AndroidPlatformExtension: PlatformInfoExtension {
178196
// FIXME: Make this configurable in a better way so we don't need to push build settings at the SDK definition level
179197
"LLVM_TARGET_TRIPLE_OS_VERSION": .plString("$(SWIFT_PLATFORM_TARGET_PREFIX)"),
180198
"LLVM_TARGET_TRIPLE_SUFFIX": .plString("-android$($(DEPLOYMENT_TARGET_SETTING_NAME))"),
181-
].merging(swiftSettings, uniquingKeysWith: { _, new in new })),
199+
].merging(customProperties, uniquingKeysWith: { _, new in new })),
182200
"SupportedTargets": .plDict([
183201
"android": .plDict([
184-
"Archs": .plArray(abis.map { .plString($0.value.llvm_triple.arch) }),
202+
"Archs": .plArray(androidNdk.abis.map { .plString($0.value.llvm_triple.arch) }),
185203
"DeploymentTargetSettingName": .plString("ANDROID_DEPLOYMENT_TARGET"),
186-
"DefaultDeploymentTarget": .plString("\(deploymentTargetRange.min)"),
187-
"MinimumDeploymentTarget": .plString("\(deploymentTargetRange.min)"),
188-
"MaximumDeploymentTarget": .plString("\(deploymentTargetRange.max)"),
204+
"DefaultDeploymentTarget": .plString("\(androidNdk.deploymentTargetRange.min)"),
205+
"MinimumDeploymentTarget": .plString("\(androidNdk.deploymentTargetRange.min)"),
206+
"MaximumDeploymentTarget": .plString("\(androidNdk.deploymentTargetRange.max)"),
189207
"LLVMTargetTripleEnvironment": .plString("android"), // FIXME: androideabi for armv7!
190208
"LLVMTargetTripleSys": .plString("linux"),
191209
"LLVMTargetTripleVendor": .plString("none"),
@@ -194,7 +212,7 @@ struct AndroidPlatformExtension: PlatformInfoExtension {
194212
"Toolchains": .plArray([
195213
.plString("android")
196214
])
197-
])]
215+
])
198216
}
199217
}
200218

0 commit comments

Comments
 (0)