Skip to content

Commit c3b0135

Browse files
committed
build: use Foundation instead of C for getenv
`getenv` is different across different platforms. Use Foundation to abstract over the platform differences.
1 parent ce90205 commit c3b0135

File tree

1 file changed

+2
-8
lines changed

1 file changed

+2
-8
lines changed

Package.swift

Lines changed: 2 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -3,12 +3,6 @@
33
import PackageDescription
44
import Foundation
55

6-
#if canImport(Glibc)
7-
import Glibc
8-
#else
9-
import Darwin.C
10-
#endif
11-
126
let package = Package(
137
name: "SwiftSyntax",
148
targets: [
@@ -26,7 +20,7 @@ let swiftSyntaxTarget: PackageDescription.Target
2620

2721
/// If we are in a controlled CI environment, we can use internal compiler flags
2822
/// to speed up the build or improve it.
29-
if getenv("SWIFT_BUILD_SCRIPT_ENVIRONMENT") != nil {
23+
if ProcessInfo.processInfo.environment["SWIFT_BUILD_SCRIPT_ENVIRONMENT"] != nil {
3024
let groupFile = URL(fileURLWithPath: #file)
3125
.deletingLastPathComponent()
3226
.appendingPathComponent("utils")
@@ -51,7 +45,7 @@ let libraryType: Product.Library.LibraryType
5145

5246
/// When we're in a build-script environment, we want to build a dylib instead
5347
/// of a static library since we install the dylib into the toolchain.
54-
if getenv("SWIFT_BUILD_SCRIPT_ENVIRONMENT") != nil {
48+
if ProcessInfo.processInfo.environment["SWIFT_BUILD_SCRIPT_ENVIRONMENT"] != nil {
5549
libraryType = .dynamic
5650
} else {
5751
libraryType = .static

0 commit comments

Comments
 (0)