Skip to content

Update CI to Swift 6 #171

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

Merged
merged 1 commit into from
Sep 24, 2024
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
139 changes: 72 additions & 67 deletions .github/workflows/sdks.yml

Large diffs are not rendered by default.

357 changes: 0 additions & 357 deletions android-overlay/foundation-fixes.patch

This file was deleted.

87 changes: 0 additions & 87 deletions android-overlay/import-android-devel.patch

This file was deleted.

31 changes: 0 additions & 31 deletions android-overlay/swift-argument-parser.patch

This file was deleted.

17 changes: 0 additions & 17 deletions android-overlay/swift-stdlib-modulemap.patch

This file was deleted.

15 changes: 0 additions & 15 deletions android-overlay/yams.patch

This file was deleted.

78 changes: 24 additions & 54 deletions get-packages-and-swift-source.swift
Original file line number Diff line number Diff line change
@@ -1,20 +1,22 @@
import Foundation

// The Termux packages to download and unpack
var termuxPackages = ["libicu", "libicu-static", "libandroid-spawn", "libcurl", "libxml2"]
var termuxPackages = ["libandroid-spawn", "libcurl", "libxml2"]
let termuxURL = "https://packages.termux.dev/apt/termux-main"

let swiftRepos = ["llvm-project", "swift", "swift-experimental-string-processing", "swift-corelibs-libdispatch",
"swift-corelibs-foundation", "swift-corelibs-xctest", "swift-syntax"]
"swift-corelibs-foundation", "swift-corelibs-xctest", "swift-syntax", "swift-collections",
"swift-foundation", "swift-foundation-icu"]

let extraSwiftRepos = ["swift-llbuild", "swift-package-manager", "swift-driver",
"swift-tools-support-core", "swift-argument-parser", "swift-crypto",
"Yams", "indexstore-db", "sourcekit-lsp", "swift-system",
"swift-collections", "swift-certificates", "swift-asn1"]
"swift-certificates", "swift-asn1", "swift-toolchain-sqlite"]
let appleRepos = ["swift-argument-parser", "swift-crypto", "swift-system", "swift-collections", "swift-certificates", "swift-asn1"]
let renameRepos = ["swift-llbuild" : "llbuild", "swift-package-manager" : "swiftpm", "Yams" : "yams"]
var repoTags = ["swift-system" : "1.3.0", "swift-collections" : "1.1.2", "swift-asn1" : "1.0.0",
"swift-certificates" : "1.0.1", "Yams" : "5.0.6", "swift-argument-parser" : "1.2.3",
"swift-crypto" : "3.0.0"]
"swift-crypto" : "3.0.0", "swift-toolchain-sqlite" : "1.0.1"]
if ProcessInfo.processInfo.environment["BUILD_SWIFT_PM"] != nil {
termuxPackages += ["ncurses", "libsqlite"]
}
Expand All @@ -27,8 +29,7 @@ guard let ANDROID_ARCH = ProcessInfo.processInfo.environment["ANDROID_ARCH"] els
fatalError("You must specify an ANDROID_ARCH environment variable.")
}

var sdkDir = "", icuVersion = "", icuMajorVersion = "", swiftVersion = "",
swiftBranch = "", swiftSnapshotDate = ""
var sdkDir = "", swiftVersion = "", swiftBranch = "", swiftSnapshotDate = ""

let tagRange = NSRange(SWIFT_TAG.startIndex..., in: SWIFT_TAG)
let tagExtract = try NSRegularExpression(pattern: "swift-([5-9]\\.[0-9]+)?\\.?[1-9]*-?([A-Z-]+)([0-9-]+[0-9])?")
Expand All @@ -49,13 +50,11 @@ if tagExtract.numberOfMatches(in: SWIFT_TAG, range: tagRange) == 1 {
}

if swiftBranch == "RELEASE" {
repoTags["swift-collections"] = "1.0.5"
repoTags["swift-system"] = "1.1.1"
repoTags["Yams"] = "5.0.1"
sdkDir = "swift-release-android-\(ANDROID_ARCH)-24-sdk"
} else {
if swiftVersion == "" {
repoTags["swift-argument-parser"] = "1.4.0"
repoTags["swift-collections"] = "1.1.3"
}
sdkDir = "swift-\(swiftVersion == "" ? "trunk" : "devel")-android-\(ANDROID_ARCH)-\(swiftSnapshotDate)-24-sdk"
}
Expand Down Expand Up @@ -186,17 +185,6 @@ for termuxPackage in termuxPackages {
"\(termuxURL)/\(packagePath)"])
}

if termuxPackage == "libicu" {
guard let icuVersionRange = packageName.range(of: "([0-9]+)\\.[0-9]", options: .regularExpression) else {
fatalError("couldn't extract ICU version from \(packageName)")
}
icuVersion = String(packageName[icuVersionRange])
guard let icuMajorVersionRange = icuVersion.range(of: "^[0-9]+", options: .regularExpression) else {
fatalError("couldn't extract ICU major version from \(icuVersion)")
}
icuMajorVersion = String(icuVersion[icuMajorVersionRange])
}

if !fmd.fileExists(atPath: cwd.appendingPathComponent(sdkDir)) {
print("Unpacking \(packageName)")
#if os(macOS)
Expand Down Expand Up @@ -224,35 +212,6 @@ if !fmd.fileExists(atPath: sdkPath) {
try fmd.removeItem(atPath: sdkPath.appendingPathComponent("usr/share/man"))
}

for iculib in ["data", "i18n", "io", "test", "tu", "uc"] {
if fmd.fileExists(atPath: sdkPath.appendingPathComponent("usr/lib/libicu\(iculib).so.\(icuMajorVersion)")) {
try fmd.removeItem(atPath: sdkPath.appendingPathComponent("usr/lib/libicu\(iculib).so"))
try fmd.removeItem(atPath: sdkPath.appendingPathComponent("usr/lib/libicu\(iculib).so.\(icuMajorVersion)"))

if ["io", "test", "tu"].contains(iculib) {
try fmd.removeItem(atPath: sdkPath.appendingPathComponent("usr/lib/libicu\(iculib).a"))
try fmd.removeItem(atPath: sdkPath.appendingPathComponent("usr/lib/libicu\(iculib).so.\(icuVersion)"))
} else {
try fmd.moveItem(atPath: sdkPath.appendingPathComponent("usr/lib/libicu\(iculib).so.\(icuVersion)"),
toPath: sdkPath.appendingPathComponent("usr/lib/libicu\(iculib).so"))
_ = runCommand("patchelf", with: ["--set-rpath", "$ORIGIN",
"\(sdkPath.appendingPathComponent("usr/lib/libicu\(iculib).so"))"])
_ = runCommand("patchelf", with: ["--set-soname", "libicu\(iculib).so",
"\(sdkPath.appendingPathComponent("usr/lib/libicu\(iculib).so"))"])

if iculib == "i18n" {
_ = runCommand("patchelf", with: ["--replace-needed", "libicuuc.so.\(icuMajorVersion)",
"libicuuc.so", "\(sdkPath.appendingPathComponent("usr/lib/libicui18n.so"))"])
}

if iculib == "uc" {
_ = runCommand("patchelf", with: ["--replace-needed", "libicudata.so.\(icuMajorVersion)",
"libicudata.so", "\(sdkPath.appendingPathComponent("usr/lib/libicuuc.so"))"])
}
}
}
}

_ = runCommand("patchelf", with: ["--set-rpath", "$ORIGIN",
"\(sdkPath.appendingPathComponent("usr/lib/libandroid-spawn.so"))",
"\(sdkPath.appendingPathComponent("usr/lib/libcurl.so"))",
Expand All @@ -262,20 +221,31 @@ for repo in swiftRepos {
print("Checking for \(repo) source")
if !fmd.fileExists(atPath: cwd.appendingPathComponent(repo)) {
print("Downloading and extracting \(repo) source")
let tag = repoTags[repo] ?? SWIFT_TAG
var repoOrg = "swiftlang"
if ["swift-corelibs-libdispatch", "swift-collections"].contains(repo) {
repoOrg = "apple"
}
_ = runCommand("curl", with: ["-f", "-L", "-O",
"https://github.com/apple/\(repo)/archive/refs/tags/\(SWIFT_TAG).tar.gz"])
_ = runCommand("tar", with: ["xf", "\(SWIFT_TAG).tar.gz"])
try fmd.moveItem(atPath: cwd.appendingPathComponent("\(repo)-\(SWIFT_TAG)"),
"https://github.com/\(repoOrg)/\(repo)/archive/refs/tags/\(tag).tar.gz"])
_ = runCommand("tar", with: ["xf", "\(tag).tar.gz"])
try fmd.moveItem(atPath: cwd.appendingPathComponent("\(repo)-\(tag)"),
toPath: cwd.appendingPathComponent(repo))
try fmd.removeItem(atPath: cwd.appendingPathComponent("\(SWIFT_TAG).tar.gz"))
try fmd.removeItem(atPath: cwd.appendingPathComponent("\(tag).tar.gz"))
}
}

if ProcessInfo.processInfo.environment["BUILD_SWIFT_PM"] != nil {
for repo in extraSwiftRepos {
let tag = repoTags[repo] ?? SWIFT_TAG
var repoOrg = "swiftlang"
if repo == "Yams" {
repoOrg = "jpsim"
} else if appleRepos.contains(repo) {
repoOrg = "apple"
}
_ = runCommand("curl", with: ["-f", "-L", "-O",
"https://github.com/\(repo == "Yams" ? "jpsim" : "apple")/\(repo)/archive/refs/tags/\(tag).tar.gz"])
"https://github.com/\(repoOrg)/\(repo)/archive/refs/tags/\(tag).tar.gz"])
_ = runCommand("tar", with: ["xf", "\(tag).tar.gz"])
try fmd.moveItem(atPath: cwd.appendingPathComponent("\(repo)-\(tag)"),
toPath: cwd.appendingPathComponent(renameRepos[repo] ?? repo))
Expand Down
52 changes: 52 additions & 0 deletions swift-android-ci-except-trunk.patch
Original file line number Diff line number Diff line change
@@ -0,0 +1,52 @@
diff --git a/llbuild/products/llbuildSwift/BuildSystemBindings.swift b/llbuild/products/llbuildSwift/BuildSystemBindings.swift
index 6962fff5..8f1bf502 100644
--- a/llbuild/products/llbuildSwift/BuildSystemBindings.swift
+++ b/llbuild/products/llbuildSwift/BuildSystemBindings.swift
@@ -17,8 +17,8 @@ import WinSDK
import Glibc
#elseif canImport(Musl)
import Musl
-#elseif canImport(Bionic)
-import Bionic
+#elseif canImport(Android)
+import Android
#else
#error("Missing libc or equivalent")
#endif
@@ -1293,7 +1293,7 @@ public final class BuildSystem {
#elseif os(Windows)
info.pointee.mod_time.seconds = UInt64(s.st_mtime)
info.pointee.mod_time.nanoseconds = 0
- #elseif canImport(Glibc) || canImport(Musl) || canImport(Bionic)
+ #elseif canImport(Glibc) || canImport(Musl) || canImport(Android)
info.pointee.mod_time.seconds = UInt64(s.st_mtim.tv_sec)
info.pointee.mod_time.nanoseconds = UInt64(s.st_mtim.tv_nsec)
#else
diff --git a/llbuild/unittests/CMakeLists.txt b/llbuild/unittests/CMakeLists.txt
index 92a1ee38..52273afb 100644
--- a/llbuild/unittests/CMakeLists.txt
+++ b/llbuild/unittests/CMakeLists.txt
@@ -6,9 +6,9 @@ function(add_llbuild_unittest test_dirname)
endfunction()

add_subdirectory(Basic)
-add_subdirectory(CAS)
+#add_subdirectory(CAS)
add_subdirectory(CAPI)
add_subdirectory(Core)
add_subdirectory(Evo)
add_subdirectory(BuildSystem)
-add_subdirectory(Ninja)
+#add_subdirectory(Ninja)
diff --git a/swiftpm/Sources/Basics/AsyncProcess.swift b/swiftpm/Sources/Basics/AsyncProcess.swift
--- a/swiftpm/Sources/Basics/AsyncProcess.swift
+++ b/swiftpm/Sources/Basics/AsyncProcess.swift
@@ -14,6 +14,8 @@

#if os(Windows)
import TSCLibc
+#elseif canImport(Android)
+import Android
#endif

#if os(Linux)
34 changes: 34 additions & 0 deletions swift-android-ci-trunk.patch
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
diff --git a/llbuild/unittests/CMakeLists.txt b/llbuild/unittests/CMakeLists.txt
index 92a1ee38..52273afb 100644
--- a/llbuild/unittests/CMakeLists.txt
+++ b/llbuild/unittests/CMakeLists.txt
@@ -6,4 +6,4 @@ function(add_llbuild_unittest test_dirname)
add_subdirectory(CAPI)
add_subdirectory(Core)
add_subdirectory(BuildSystem)
-add_subdirectory(Ninja)
+#add_subdirectory(Ninja)
diff --git a/swiftpm/Package.swift b/swiftpm/Package.swift
--- a/swiftpm/Package.swift
+++ b/swiftpm/Package.swift
@@ -198,7 +198,7 @@
name: "Basics",
dependencies: [
"_AsyncFileSystem",
- .target(name: "SPMSQLite3", condition: .when(platforms: [.macOS, .iOS, .tvOS, .watchOS, .visionOS, .macCatalyst, .linux])),
+ .target(name: "SPMSQLite3", condition: .when(platforms: [.macOS, .iOS, .tvOS, .watchOS, .visionOS, .macCatalyst, .linux, .android])),
.product(name: "SwiftToolchainCSQLite", package: "swift-toolchain-sqlite", condition: .when(platforms: [.windows])),
.product(name: "DequeModule", package: "swift-collections"),
.product(name: "OrderedCollections", package: "swift-collections"),
diff --git a/swiftpm/Sources/Basics/Concurrency/AsyncProcess.swift b/swiftpm/Sources/Basics/Concurrency/AsyncProcess.swift
--- a/swiftpm/Sources/Basics/Concurrency/AsyncProcess.swift
+++ b/swiftpm/Sources/Basics/Concurrency/AsyncProcess.swift
@@ -14,6 +14,8 @@

#if os(Windows)
import TSCLibc
+#elseif canImport(Android)
+import Android
#endif

#if os(Linux)
Loading
Loading