Skip to content
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

[5.10] Fix platform conditions in Package.swift #432

Merged
merged 1 commit into from
Sep 18, 2023
Merged
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
32 changes: 11 additions & 21 deletions Package.swift
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,10 @@ let package = Package(
/** Shim target to import missing C headers in Darwin and Glibc modulemap. */
name: "TSCclibc",
dependencies: [],
exclude: CMakeFiles),
exclude: CMakeFiles,
cSettings: [
.define("_GNU_SOURCE", .when(platforms: [.linux])),
]),
.target(
/** Cross-platform access to bare `libc` functionality. */
name: "TSCLibc",
Expand All @@ -68,7 +71,13 @@ let package = Package(
"TSCclibc",
.product(name: "SystemPackage", package: "swift-system"),
],
exclude: CMakeFiles + ["README.md"]),
exclude: CMakeFiles + ["README.md"],
cxxSettings: [
.define("_CRT_SECURE_NO_WARNINGS", .when(platforms: [.windows])),
],
linkerSettings: [
.linkedLibrary("Pathcch", .when(platforms: [.windows])),
]),
.target(
/** Abstractions for common operations, should migrate to TSCBasic */
name: "TSCUtility",
Expand Down Expand Up @@ -111,22 +120,3 @@ let package = Package(
.package(path: "../swift-system"),
]
}

// FIXME: conditionalise these flags since SwiftPM 5.3 and earlier will crash
// for platforms they don't know about.
#if os(Windows)
if let TSCBasic = package.targets.first(where: { $0.name == "TSCBasic" }) {
TSCBasic.cxxSettings = [
.define("_CRT_SECURE_NO_WARNINGS", .when(platforms: [.windows])),
]
TSCBasic.linkerSettings = [
.linkedLibrary("Pathcch", .when(platforms: [.windows])),
]
}
#elseif os(Linux)
if let TSCclibc = package.targets.first(where: { $0.name == "TSCclibc" }) {
TSCclibc.cSettings = [
.define("_GNU_SOURCE", .when(platforms: [.linux])),
]
}
#endif