Skip to content
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: 2 additions & 0 deletions .github/scripts/prebuild.sh
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,8 @@

set -e

df -h

if [[ $(uname) == Darwin ]] ; then
if [[ "$INSTALL_CMAKE" == "1" ]] ; then
mkdir -p "$RUNNER_TOOL_CACHE"
Expand Down
10 changes: 7 additions & 3 deletions .github/workflows/pull_request.yml
Original file line number Diff line number Diff line change
Expand Up @@ -19,14 +19,18 @@ jobs:
linux_os_versions: '["amazonlinux2", "bookworm", "noble", "jammy", "rhel-ubi9"]'
linux_swift_versions: '["nightly-main"]'
linux_pre_build_command: ./.github/scripts/prebuild.sh
linux_build_command: 'swift build'
linux_build_command: 'swift build --build-tests'
windows_swift_versions: '["nightly-main"]'
windows_pre_build_command: 'Invoke-Program .\.github\scripts\prebuild.ps1'
windows_build_command: 'Invoke-Program swift build'
windows_build_command: 'Invoke-Program swift build --build-tests'
enable_ios_checks: true
enable_macos_checks: true
macos_exclude_xcode_versions: "[{\"xcode_version\": \"16.3\"}, {\"xcode_version\": \"16.4\"}]"
macos_build_command: 'swift build'
macos_build_command: 'swift build --build-tests'
enable_android_sdk_build: true
android_sdk_build_command: "swift build --build-tests || df -h"
android_ndk_versions: '["r27d", "r29"]'
android_sdk_triples: '["aarch64-unknown-linux-android28"]'

soundness:
name: Soundness
Expand Down
24 changes: 21 additions & 3 deletions Package.swift
Original file line number Diff line number Diff line change
Expand Up @@ -83,13 +83,15 @@ let swiftPMProduct = (
]
)

let isStaticBuild = ProcessInfo.processInfo.environment["SWIFTPM_STATIC_LINK"] != nil

#if os(Windows)
let includeDynamicLibrary: Bool = false
let systemSQLitePkgConfig: String? = nil
#else
let includeDynamicLibrary: Bool = true
let includeDynamicLibrary: Bool = !isStaticBuild
var systemSQLitePkgConfig: String? = "sqlite3"
if ProcessInfo.processInfo.environment["SWIFTCI_INSTALL_RPATH_OS"] == "android" {
if ProcessInfo.processInfo.environment["SWIFTCI_INSTALL_RPATH_OS"] == "android" || isStaticBuild {
systemSQLitePkgConfig = nil
}
#endif
Expand Down Expand Up @@ -218,7 +220,12 @@ let package = Package(

// MARK: SwiftPM specific support libraries

.systemLibrary(name: "SPMSQLite3", pkgConfig: systemSQLitePkgConfig),
.target(
name: "SPMSQLite3",
dependencies: isStaticBuild ? [
.product(name: "SwiftToolchainCSQLite", package: "swift-toolchain-sqlite"),
] : []
),

.target(
name: "_AsyncFileSystem",
Expand Down Expand Up @@ -1171,3 +1178,14 @@ if !shouldUseSwiftBuildFramework {
]
}
}

if isStaticBuild {
package.targets = package.targets.filter { target in
target.type != .test && !target.name.hasSuffix("TestSupport")
}
package.products = package.products.filter { product in
!product.name.hasSuffix("TestSupport")
// FIXME: This probably doesn't produce a particularly useful result...
&& !["PackageDescription", "AppleProductTypes", "PackagePlugin"].contains(product.name)
}
}
12 changes: 10 additions & 2 deletions Sources/Basics/Concurrency/AsyncProcess.swift
Original file line number Diff line number Diff line change
Expand Up @@ -25,9 +25,13 @@ import func TSCclibc.SPM_posix_spawn_file_actions_addchdir_np_supported

@_implementationOnly
import func TSCclibc.SPM_posix_spawn_file_actions_addchdir_np

@_implementationOnly
import func TSCclibc.SPM_posix_spawnp
#else
private import func TSCclibc.SPM_posix_spawn_file_actions_addchdir_np_supported
private import func TSCclibc.SPM_posix_spawn_file_actions_addchdir_np
package import func TSCclibc.SPM_posix_spawn_file_actions_addchdir_np_supported
package import func TSCclibc.SPM_posix_spawn_file_actions_addchdir_np
package import func TSCclibc.SPM_posix_spawnp
#endif // #if USE_IMPL_ONLY_IMPORTS
#endif

Expand Down Expand Up @@ -687,7 +691,11 @@ package final class AsyncProcess {
}
let argv = CStringArray(resolvedArgs)
let env = CStringArray(environment.map { "\($0.0)=\($0.1)" })
#if canImport(Darwin)
let rv = posix_spawnp(&self.processID, argv.cArray[0]!, &fileActions, &attributes, argv.cArray, env.cArray)
#else
let rv = SPM_posix_spawnp(&self.processID, argv.cArray[0]!, &fileActions, &attributes, argv.cArray, env.cArray)
#endif

guard rv == 0 else {
throw SystemError.posix_spawn(rv, self.arguments)
Expand Down
2 changes: 1 addition & 1 deletion Sources/SPMSQLite3/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@

add_library(SPMSQLite3 INTERFACE)
target_include_directories(SPMSQLite3 INTERFACE
${CMAKE_CURRENT_SOURCE_DIR})
${CMAKE_CURRENT_SOURCE_DIR}/include)
target_link_libraries(SPMSQLite3 INTERFACE
SQLite::SQLite3)
if(CMAKE_SYSTEM_NAME STREQUAL OpenBSD)
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
module SPMSQLite3 [system] {
header "sqlite.h"
link "sqlite3"
export *
}
File renamed without changes.
Empty file added Sources/SPMSQLite3/sqlite.c
Empty file.
4 changes: 4 additions & 0 deletions Sources/swiftpm-testing-helper/Entrypoint.swift
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,10 @@
import Darwin.C
#elseif canImport(Android)
import Android
#elseif canImport(Glibc)
import Glibc
#elseif canImport(Musl)
import Musl
#endif

@main
Expand Down
2 changes: 2 additions & 0 deletions Tests/FunctionalTests/LibraryEvolutionXCFLinuxTests.swift
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,8 @@ private struct SwiftPMTests {
let arch = "aarch64"
#elseif arch(x86_64)
let arch = "x86_64"
#else
preconditionFailure("Unsupported platform or host arch for test")
#endif

let platform = "linux"
Expand Down
2 changes: 1 addition & 1 deletion Tests/IntegrationTests/SwiftPMTests.swift
Original file line number Diff line number Diff line change
Expand Up @@ -216,7 +216,7 @@ private struct SwiftPMTests {
#elseif arch(arm64)
hostArch = "arm64"
#else
precondition("Unsupported platform or host arch for test")
preconditionFailure("Unsupported platform or host arch for test")
#endif
switch buildSystem {
case .native:
Expand Down
Loading