Skip to content

Commit badd7f1

Browse files
committed
Update CMakeLists
1 parent 99241a6 commit badd7f1

File tree

6 files changed

+55
-18
lines changed

6 files changed

+55
-18
lines changed

Package.swift

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -184,7 +184,9 @@ let package = Package(
184184

185185
.systemLibrary(name: "SPMSQLite3", pkgConfig: systemSQLitePkgConfig),
186186

187-
.target(name: "Environment"),
187+
.target(
188+
name: "Environment",
189+
exclude: ["CMakeLists.txt"]),
188190

189191
.target(
190192
name: "Basics",

Sources/Basics/CMakeLists.txt

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ add_library(Basics
2525
Concurrency/ThreadSafeKeyValueStore.swift
2626
Concurrency/TokenBucket.swift
2727
DispatchTimeInterval+Extensions.swift
28-
Environment.swift
28+
EnvironmentVariables.swift
2929
Errors.swift
3030
FileSystem/AbsolutePath.swift
3131
FileSystem/FileSystem+Extensions.swift
@@ -73,6 +73,7 @@ add_library(Basics
7373
Vendor/Triple.swift
7474
Vendor/Triple+Platforms.swift)
7575
target_link_libraries(Basics PUBLIC
76+
Environment
7677
SwiftCollections::DequeModule
7778
SwiftCollections::OrderedCollections
7879
SwiftSystem::SystemPackage

Sources/Basics/EnvironmentVariables.swift

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -60,7 +60,7 @@ extension TSCBasic.Process {
6060
}
6161

6262
extension TSCBasic.Process {
63-
static package func popen(
63+
package static func popen(
6464
arguments: [String],
6565
environment: Environment,
6666
loggingHandler: LoggingHandler? = nil,
@@ -71,7 +71,7 @@ extension TSCBasic.Process {
7171
}
7272

7373
@discardableResult
74-
static package func popen(
74+
package static func popen(
7575
arguments: [String],
7676
environment: Environment,
7777
loggingHandler: LoggingHandler? = nil
@@ -80,23 +80,23 @@ extension TSCBasic.Process {
8080
}
8181

8282
@discardableResult
83-
static package func popen(
83+
package static func popen(
8484
args: String...,
8585
environment: Environment,
8686
loggingHandler: LoggingHandler? = nil
8787
) throws -> ProcessResult {
8888
try popen(arguments: args, environmentBlock: .init(environment), loggingHandler: loggingHandler)
8989
}
9090

91-
static package func popen(
91+
package static func popen(
9292
arguments: [String],
9393
environment: Environment,
9494
loggingHandler: LoggingHandler? = nil
9595
) async throws -> ProcessResult {
9696
try await popen(arguments: arguments, environmentBlock: .init(environment), loggingHandler: loggingHandler)
9797
}
9898

99-
static package func popen(
99+
package static func popen(
100100
args: String...,
101101
environment: Environment,
102102
loggingHandler: LoggingHandler? = nil
@@ -107,7 +107,7 @@ extension TSCBasic.Process {
107107

108108
extension TSCBasic.Process {
109109
@discardableResult
110-
static package func checkNonZeroExit(
110+
package static func checkNonZeroExit(
111111
arguments: [String],
112112
environment: Environment,
113113
loggingHandler: LoggingHandler? = nil
@@ -116,7 +116,7 @@ extension TSCBasic.Process {
116116
}
117117

118118
@discardableResult
119-
static package func checkNonZeroExit(
119+
package static func checkNonZeroExit(
120120
arguments: [String],
121121
environment: Environment,
122122
loggingHandler: LoggingHandler? = nil
@@ -125,7 +125,7 @@ extension TSCBasic.Process {
125125
}
126126

127127
@discardableResult
128-
static package func checkNonZeroExit(
128+
package static func checkNonZeroExit(
129129
args: String...,
130130
environment: Environment,
131131
loggingHandler: LoggingHandler? = nil
@@ -135,7 +135,7 @@ extension TSCBasic.Process {
135135

136136

137137
@discardableResult
138-
static package func checkNonZeroExit(
138+
package static func checkNonZeroExit(
139139
args: String...,
140140
environment: Environment,
141141
loggingHandler: LoggingHandler? = nil

Sources/CMakeLists.txt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@ add_subdirectory(Commands)
1515
add_subdirectory(CompilerPluginSupport)
1616
add_subdirectory(CoreCommands)
1717
add_subdirectory(DriverSupport)
18+
add_subdirectory(Environment)
1819
add_subdirectory(LLBuildManifest)
1920
add_subdirectory(PackageDescription)
2021
add_subdirectory(PackageFingerprint)

Sources/Environment/CMakeLists.txt

Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
1+
# This source file is part of the Swift open source project
2+
#
3+
# Copyright (c) 2014 - 2021 Apple Inc. and the Swift project authors
4+
# Licensed under Apache License v2.0 with Runtime Library Exception
5+
#
6+
# See http://swift.org/LICENSE.txt for license information
7+
# See http://swift.org/CONTRIBUTORS.txt for Swift project authors
8+
9+
add_library(Environment
10+
Environment.swift
11+
EnvironmentKey.swift)
12+
target_link_libraries(Build PUBLIC
13+
TSCBasic
14+
Basics
15+
PackageGraph
16+
SPMBuildCore)
17+
target_link_libraries(Build PRIVATE
18+
DriverSupport
19+
LLBuildManifest
20+
SPMLLBuild
21+
SwiftDriver)
22+
target_link_libraries(Build INTERFACE
23+
llbuildSwift)
24+
25+
# NOTE(compnerd) workaround for CMake not setting up include flags yet
26+
set_target_properties(Build PROPERTIES
27+
INTERFACE_INCLUDE_DIRECTORIES ${CMAKE_Swift_MODULE_DIRECTORY})
28+
29+
install(TARGETS Build
30+
ARCHIVE DESTINATION lib
31+
LIBRARY DESTINATION lib
32+
RUNTIME DESTINATION bin)
33+
set_property(GLOBAL APPEND PROPERTY SwiftPM_EXPORTS Environment)

Sources/Environment/Environment.swift

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -53,15 +53,15 @@ extension Environment {
5353
self.storage = .init()
5454
}
5555

56-
public subscript(_ key: EnvironmentKey) -> String? {
56+
package subscript(_ key: EnvironmentKey) -> String? {
5757
_read { yield self.storage[key] }
5858
_modify { yield &self.storage[key] }
5959
}
6060
}
6161

6262
// MARK: - Conversions between Dictionary<String, String>
6363
extension Environment {
64-
public init(_ dictionary: [String: String]) {
64+
package init(_ dictionary: [String: String]) {
6565
self.storage = .init()
6666
let sorted = dictionary.sorted { $0.key < $1.key }
6767
for (key, value) in sorted {
@@ -71,7 +71,7 @@ extension Environment {
7171
}
7272

7373
extension Dictionary<String, String> {
74-
public init(_ environment: Environment) {
74+
package init(_ environment: Environment) {
7575
self.init()
7676
let sorted = environment.sorted { $0.key < $1.key }
7777
for (key, value) in sorted {
@@ -82,7 +82,7 @@ extension Dictionary<String, String> {
8282

8383
// MARK: - Path Modification
8484
extension Environment {
85-
public mutating func prependPath(key: EnvironmentKey, value: String) {
85+
package mutating func prependPath(key: EnvironmentKey, value: String) {
8686
guard !value.isEmpty else { return }
8787
if let existing = self[key] {
8888
self[key] = "\(value)\(Self.pathValueDelimiter)\(existing)"
@@ -91,7 +91,7 @@ extension Environment {
9191
}
9292
}
9393

94-
public mutating func appendPath(key: EnvironmentKey, value: String) {
94+
package mutating func appendPath(key: EnvironmentKey, value: String) {
9595
guard !value.isEmpty else { return }
9696
if let existing = self[key] {
9797
self[key] = "\(existing)\(Self.pathValueDelimiter)\(value)"
@@ -100,7 +100,7 @@ extension Environment {
100100
}
101101
}
102102

103-
public static var pathValueDelimiter: String {
103+
package static var pathValueDelimiter: String {
104104
#if os(Windows)
105105
";"
106106
#else
@@ -239,7 +239,7 @@ extension Environment {
239239
/// Returns a copy of `self` with known non-cacheable keys removed.
240240
///
241241
/// - Issue: rdar://107029374
242-
public var cachable: Environment {
242+
package var cachable: Environment {
243243
var cachable = Environment()
244244
for (key, value) in self {
245245
if !EnvironmentKey.nonCachable.contains(key) {

0 commit comments

Comments
 (0)