Skip to content

Commit 7ce677e

Browse files
authored
Merge pull request swiftlang#472 from swiftlang/automerge/merge-main-2025-04-30_22-51
Merge `main` into `release/6.2`
2 parents 0118c59 + 0a9c76a commit 7ce677e

File tree

89 files changed

+1171
-426
lines changed

Some content is hidden

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

89 files changed

+1171
-426
lines changed

.gitattributes

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
* text=auto eol=lf

.github/workflows/automerge.yml

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
name: Create PR to merge main into release branch
2+
# In the first period after branching the release branch, we typically want to include many changes from `main` in the release branch. This workflow automatically creates a PR every Monday to merge main into the release branch.
3+
# Later in the release cycle we should stop this practice to avoid landing risky changes by disabling this workflow. To do so, disable the workflow as described in https://docs.github.com/en/actions/managing-workflow-runs-and-deployments/managing-workflow-runs/disabling-and-enabling-a-workflow
4+
on:
5+
schedule:
6+
- cron: '0 9 * * MON'
7+
workflow_dispatch:
8+
jobs:
9+
create_merge_pr:
10+
name: Create PR to merge main into release branch
11+
uses: swiftlang/github-workflows/.github/workflows/create_automerge_pr.yml@main
12+
with:
13+
base_branch: release/6.2
14+
permissions:
15+
contents: write
16+
pull-requests: write
17+
if: (github.event_name == 'schedule' && github.repository == 'swiftlang/swift-build') || (github.event_name != 'schedule') # Ensure that we don't run this on a schedule in a fork

.github/workflows/pull_request.yml

Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
name: Pull request
2+
3+
on:
4+
pull_request:
5+
types: [opened, reopened, synchronize]
6+
7+
concurrency:
8+
group: ${{ github.workflow }}-${{ github.ref }}
9+
cancel-in-progress: true
10+
11+
jobs:
12+
tests:
13+
name: Test
14+
uses: swiftlang/github-workflows/.github/workflows/swift_package_test.yml@main
15+
with:
16+
linux_os_versions: '["noble", "jammy", "focal", "rhel-ubi9"]'
17+
linux_pre_build_command: command -v apt >/dev/null 2>&1 && apt update && apt install -y libsqlite3-dev libncurses-dev || (command -v yum >/dev/null 2>&1 && yum update -y && yum install -y sqlite-devel ncurses-devel)
18+
linux_build_command: 'swift test --no-parallel'
19+
linux_swift_versions: '["nightly-main", "nightly-6.2"]'
20+
windows_swift_versions: '["nightly-main"]'
21+
windows_build_command: 'swift test --no-parallel'
22+
soundness:
23+
name: Soundness
24+
uses: swiftlang/github-workflows/.github/workflows/soundness.yml@main
25+
with:
26+
license_header_check_project_name: "Swift"
27+
api_breakage_check_enabled: false
28+
unacceptable_language_check_enabled: false
29+
format_check_enabled: false

.license_header_template

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
@@===----------------------------------------------------------------------===@@
2+
@@
3+
@@ This source file is part of the Swift open source project
4+
@@
5+
@@ Copyright (c) YEARS Apple Inc. and the Swift project authors
6+
@@ Licensed under Apache License v2.0 with Runtime Library Exception
7+
@@
8+
@@ See http://swift.org/LICENSE.txt for license information
9+
@@ See http://swift.org/CONTRIBUTORS.txt for the list of Swift project authors
10+
@@
11+
@@===----------------------------------------------------------------------===@@

.licenseignore

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
**/*.mlmodel
2+
**/*.pbxproj
3+
**/*.png
4+
**/*.xcworkspacedata
5+
**/Package.swift
6+
.dir-locals.el
7+
.editorconfig
8+
CODEOWNERS
9+
Package.swift

CMakeLists.txt

Lines changed: 40 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,18 @@ cmake_minimum_required(VERSION 3.26...3.29)
1212
project(SwiftBuild
1313
LANGUAGES C CXX Swift)
1414

15+
set(CMAKE_ARCHIVE_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/lib)
16+
set(CMAKE_LIBRARY_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/lib)
17+
set(CMAKE_RUNTIME_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/bin)
18+
19+
set(CMAKE_INSTALL_RPATH "$<IF:$<PLATFORM_ID:Darwin>,@loader_path/..,$ORIGIN>")
20+
set(CMAKE_INSTALL_REMOVE_ENVIRONMENT_RPATH YES)
21+
22+
set(CMAKE_MSVC_RUNTIME_LIBRARY MultiThreadedDLL)
23+
set(CMAKE_Swift_MODULE_DIRECTORY ${CMAKE_BINARY_DIR}/swift)
24+
25+
option(BUILD_SHARED_LIBS "Build shared libraries by default" YES)
26+
1527
set(CMAKE_C_VISIBILITY hidden)
1628
set(CMAKE_CXX_VISIBILITY hidden)
1729
set(CMAKE_CXX_STANDARD 17)
@@ -35,7 +47,33 @@ add_compile_options("$<$<COMPILE_LANGUAGE:Swift>:SHELL:-package-name SwiftBuild>
3547
# rdar://137809703
3648
# "$<$<COMPILE_LANGUAGE:Swift>:SHELL:-enable-upcoming-feature RegionBasedIsolation>"
3749
"$<$<COMPILE_LANGUAGE:Swift>:SHELL:-enable-upcoming-feature ExistentialAny>"
38-
"$<$<COMPILE_LANGUAGE:Swift>:SHELL:-enable-upcoming-feature InternalImportsByDefault>")
50+
"$<$<COMPILE_LANGUAGE:Swift>:SHELL:-enable-upcoming-feature InternalImportsByDefault>"
51+
"$<$<COMPILE_LANGUAGE:Swift>:SHELL:-no-toolchain-stdlib-rpath>"
52+
# Turn off autolinking within this project to reduce linker overhead.
53+
"$<$<COMPILE_LANGUAGE:Swift>:SHELL:-Xfrontend -disable-autolink-library -Xfrontend SWBLibc>"
54+
"$<$<COMPILE_LANGUAGE:Swift>:SHELL:-Xfrontend -disable-autolink-library -Xfrontend SWBAndroidPlatform>"
55+
"$<$<COMPILE_LANGUAGE:Swift>:SHELL:-Xfrontend -disable-autolink-library -Xfrontend SWBApplePlatform>"
56+
"$<$<COMPILE_LANGUAGE:Swift>:SHELL:-Xfrontend -disable-autolink-library -Xfrontend SWBBuildService>"
57+
"$<$<COMPILE_LANGUAGE:Swift>:SHELL:-Xfrontend -disable-autolink-library -Xfrontend SWBCLibc>"
58+
"$<$<COMPILE_LANGUAGE:Swift>:SHELL:-Xfrontend -disable-autolink-library -Xfrontend SWBGenericUnixPlatform>"
59+
"$<$<COMPILE_LANGUAGE:Swift>:SHELL:-Xfrontend -disable-autolink-library -Xfrontend SWBTaskConstruction>"
60+
"$<$<COMPILE_LANGUAGE:Swift>:SHELL:-Xfrontend -disable-autolink-library -Xfrontend SWBUtil>"
61+
"$<$<COMPILE_LANGUAGE:Swift>:SHELL:-Xfrontend -disable-autolink-library -Xfrontend SWBUniversalPlatform>"
62+
"$<$<COMPILE_LANGUAGE:Swift>:SHELL:-Xfrontend -disable-autolink-library -Xfrontend SWBWindowsPlatform>"
63+
"$<$<COMPILE_LANGUAGE:Swift>:SHELL:-Xfrontend -disable-autolink-library -Xfrontend SwiftBuild>"
64+
"$<$<COMPILE_LANGUAGE:Swift>:SHELL:-Xfrontend -disable-autolink-library -Xfrontend SWBWebAssemblyPlatform>"
65+
"$<$<COMPILE_LANGUAGE:Swift>:SHELL:-Xfrontend -disable-autolink-library -Xfrontend SWBCSupport>"
66+
"$<$<COMPILE_LANGUAGE:Swift>:SHELL:-Xfrontend -disable-autolink-library -Xfrontend SWBMacro>"
67+
"$<$<COMPILE_LANGUAGE:Swift>:SHELL:-Xfrontend -disable-autolink-library -Xfrontend SWBProjectModel>"
68+
"$<$<COMPILE_LANGUAGE:Swift>:SHELL:-Xfrontend -disable-autolink-library -Xfrontend SWBTaskExecution>"
69+
"$<$<COMPILE_LANGUAGE:Swift>:SHELL:-Xfrontend -disable-autolink-library -Xfrontend SWBServiceCore>"
70+
"$<$<COMPILE_LANGUAGE:Swift>:SHELL:-Xfrontend -disable-autolink-library -Xfrontend SWBQNXPlatform>"
71+
"$<$<COMPILE_LANGUAGE:Swift>:SHELL:-Xfrontend -disable-autolink-library -Xfrontend SWBProtocol>"
72+
"$<$<COMPILE_LANGUAGE:Swift>:SHELL:-Xfrontend -disable-autolink-library -Xfrontend SWBLLBuild>"
73+
"$<$<COMPILE_LANGUAGE:Swift>:SHELL:-Xfrontend -disable-autolink-library -Xfrontend SWBCore>"
74+
"$<$<COMPILE_LANGUAGE:Swift>:SHELL:-Xfrontend -disable-autolink-library -Xfrontend SWBCAS>"
75+
"$<$<COMPILE_LANGUAGE:Swift>:SHELL:-Xfrontend -disable-autolink-library -Xfrontend SWBBuildSystem>"
76+
"$<$<COMPILE_LANGUAGE:Swift>:SHELL:-Xfrontend -disable-autolink-library -Xfrontend SWBCore>")
3977

4078
# Prefer the static initialization for the plugins.
4179
add_compile_definitions(USE_STATIC_PLUGIN_INITIALIZATION)
@@ -50,3 +88,4 @@ find_package(Threads)
5088
find_package(SQLite3)
5189

5290
add_subdirectory(Sources)
91+
add_subdirectory(cmake/modules)

CODEOWNERS

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
* @jakepetroules @mirza-garibovic @mhrawdon @neonichu @owenv
1+
* @aciidgh @jakepetroules @mirza-garibovic @mhrawdon @neonichu @owenv
22
*XCStrings* @matthewseaman @kulpreetchilana @jakepetroules @mirza-garibovic @mhrawdon @neonichu @owenv
33
*StringCatalog* @matthewseaman @kulpreetchilana @jakepetroules @mirza-garibovic @mhrawdon @neonichu @owenv
4-
*Preview* @jonathanpenn @jakepetroules @mirza-garibovic @mhrawdon @neonichu @owenv
4+
*Preview* @jonathanpenn @jakepetroules @mirza-garibovic @mhrawdon @neonichu @owenv

Package.swift

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -135,6 +135,7 @@ let package = Package(
135135
swiftSettings: swiftSettings(languageMode: .v5)),
136136
.target(
137137
name: "SWBCSupport",
138+
exclude: ["empty.swift"],
138139
publicHeadersPath: ".",
139140
cSettings: [
140141
.define("_CRT_SECURE_NO_WARNINGS", .when(platforms: [.windows])),

Plugins/cmake-smoke-test/cmake-smoke-test.swift

Lines changed: 40 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -17,48 +17,56 @@ import Foundation
1717
struct CMakeSmokeTest: CommandPlugin {
1818
func performCommand(context: PluginContext, arguments: [String]) async throws {
1919
var args = ArgumentExtractor(arguments)
20-
2120
let hostOS = try OS.host()
2221

22+
guard args.extractFlag(named: "disable-sandbox") > 0 else {
23+
throw Errors.missingRequiredOption("--disable-sandbox")
24+
}
25+
2326
guard let cmakePath = args.extractOption(named: "cmake-path").last else { throw Errors.missingRequiredOption("--cmake-path") }
2427
print("using cmake at \(cmakePath)")
2528
let cmakeURL = URL(filePath: cmakePath)
2629
guard let ninjaPath = args.extractOption(named: "ninja-path").last else { throw Errors.missingRequiredOption("--ninja-path") }
2730
print("using ninja at \(ninjaPath)")
2831
let ninjaURL = URL(filePath: ninjaPath)
29-
guard let sysrootPath = args.extractOption(named: "sysroot-path").last else { throw Errors.missingRequiredOption("--sysroot-path") }
30-
print("using sysroot at \(sysrootPath)")
32+
let sysrootPath = args.extractOption(named: "sysroot-path").last
33+
if let sysrootPath {
34+
print("using sysroot at \(sysrootPath)")
35+
}
3136

3237
let moduleCachePath = context.pluginWorkDirectoryURL.appending(component: "module-cache").path()
3338

3439
let swiftBuildURL = context.package.directoryURL
3540
let swiftBuildBuildURL = context.pluginWorkDirectoryURL.appending(component: "swift-build")
3641
print("swift-build: \(swiftBuildURL.path())")
3742

38-
let swiftToolsSupportCoreURL = try findSiblingRepository("swift-tools-support-core", swiftBuildURL: swiftBuildURL)
43+
let swiftToolsSupportCoreURL = try findDependency("swift-tools-support-core", pluginContext: context)
3944
let swiftToolsSupportCoreBuildURL = context.pluginWorkDirectoryURL.appending(component: "swift-tools-support-core")
4045

41-
let swiftSystemURL = try findSiblingRepository("swift-system", swiftBuildURL: swiftBuildURL)
46+
let swiftSystemURL = try findDependency("swift-system", pluginContext: context)
4247
let swiftSystemBuildURL = context.pluginWorkDirectoryURL.appending(component: "swift-system")
4348

44-
let llbuildURL = try findSiblingRepository("llbuild", swiftBuildURL: swiftBuildURL)
49+
let llbuildURL = try findDependency("swift-llbuild", pluginContext: context)
4550
let llbuildBuildURL = context.pluginWorkDirectoryURL.appending(component: "llbuild")
4651

47-
let swiftArgumentParserURL = try findSiblingRepository("swift-argument-parser", swiftBuildURL: swiftBuildURL)
52+
let swiftArgumentParserURL = try findDependency("swift-argument-parser", pluginContext: context)
4853
let swiftArgumentParserBuildURL = context.pluginWorkDirectoryURL.appending(component: "swift-argument-parser")
4954

50-
let swiftDriverURL = try findSiblingRepository("swift-driver", swiftBuildURL: swiftBuildURL)
55+
let swiftDriverURL = try findDependency("swift-driver", pluginContext: context)
5156
let swiftDriverBuildURL = context.pluginWorkDirectoryURL.appending(component: "swift-driver")
5257

5358
for url in [swiftToolsSupportCoreBuildURL, swiftSystemBuildURL, llbuildBuildURL, swiftArgumentParserBuildURL, swiftDriverBuildURL, swiftBuildBuildURL] {
5459
try FileManager.default.createDirectory(at: url, withIntermediateDirectories: true)
5560
}
5661

57-
let sharedSwiftFlags = [
58-
"-sdk", sysrootPath,
62+
var sharedSwiftFlags = [
5963
"-module-cache-path", moduleCachePath
6064
]
6165

66+
if let sysrootPath {
67+
sharedSwiftFlags += ["-sdk", sysrootPath]
68+
}
69+
6270
let cMakeProjectArgs = [
6371
"-DArgumentParser_DIR=\(swiftArgumentParserBuildURL.appending(components: "cmake", "modules").path())",
6472
"-DLLBuild_DIR=\(llbuildBuildURL.appending(components: "cmake", "modules").path())",
@@ -107,11 +115,28 @@ struct CMakeSmokeTest: CommandPlugin {
107115
print("Built swift-build")
108116
}
109117

110-
func findSiblingRepository(_ name: String, swiftBuildURL: URL) throws -> URL {
111-
let url = swiftBuildURL.deletingLastPathComponent().appending(component: name)
112-
print("\(name): \(url.path())")
113-
guard FileManager.default.fileExists(atPath: url.path()) else { throw Errors.missingRepository(url.path()) }
114-
return url
118+
func findDependency(_ name: String, pluginContext: PluginContext) throws -> URL {
119+
var stack: [Package] = pluginContext.package.dependencies.map { $0.package }
120+
var visited = Set(stack.map { $0.id })
121+
var transitiveDependencies = pluginContext.package.dependencies.map { $0.package }
122+
while let current = stack.popLast() {
123+
for dependency in current.dependencies {
124+
guard visited.insert(dependency.package.id).inserted else {
125+
continue
126+
}
127+
transitiveDependencies.append(dependency.package)
128+
stack.append(dependency.package)
129+
}
130+
}
131+
guard let dependency = transitiveDependencies.first(where: { $0.id == name }) else {
132+
throw Errors.missingRepository(name)
133+
}
134+
let dependencyURL = dependency.directoryURL
135+
print("\(name): \(dependencyURL.path())")
136+
guard FileManager.default.fileExists(atPath: dependencyURL.path()) else {
137+
throw Errors.missingRepository(dependencyURL.path())
138+
}
139+
return dependencyURL
115140
}
116141
}
117142

Sources/SWBAndroidPlatform/CMakeLists.txt

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@ file(CONFIGURE
2828
]]
2929
ESCAPE_QUOTES @ONLY NEWLINE_STYLE LF)
3030

31-
add_library(SWBAndroidPlatform STATIC
31+
add_library(SWBAndroidPlatform
3232
AndroidSDK.swift
3333
Plugin.swift)
3434
target_link_libraries(SWBAndroidPlatform PUBLIC
@@ -37,3 +37,11 @@ target_link_libraries(SWBAndroidPlatform PUBLIC
3737
SWBUtil)
3838
target_sources(SWBAndroidPlatform PRIVATE
3939
"${CMAKE_CURRENT_BINARY_DIR}/resource_bundle_accessor.swift")
40+
41+
set_target_properties(SWBAndroidPlatform PROPERTIES
42+
INTERFACE_INCLUDE_DIRECTORIES ${CMAKE_Swift_MODULE_DIRECTORY})
43+
44+
set_property(GLOBAL APPEND PROPERTY SWIFTBUILD_EXPORTS SWBAndroidPlatform)
45+
46+
install(TARGETS SWBAndroidPlatform
47+
ARCHIVE DESTINATION "${SwiftBuild_INSTALL_LIBDIR}")

0 commit comments

Comments
 (0)