11
11
//===----------------------------------------------------------------------===//
12
12
13
13
import ArgumentParser
14
- @ _spi ( SwiftPMInternal ) import Basics
14
+ import Basics
15
15
import CoreCommands
16
16
import Foundation
17
17
import PackageGraph
@@ -233,9 +233,7 @@ public struct SwiftRunCommand: AsyncSwiftCommand {
233
233
let runnerPath : AbsolutePath
234
234
let arguments : [ String ]
235
235
236
- let toolchain = try swiftCommandState. getTargetToolchain ( )
237
-
238
- if let debugger = toolchain. swiftSDK. toolset. knownTools [ . debugger] ,
236
+ if let debugger = try swiftCommandState. getTargetToolchain ( ) . swiftSDK. toolset. knownTools [ . debugger] ,
239
237
let debuggerPath = debugger. path {
240
238
runnerPath = debuggerPath
241
239
arguments = debugger. extraCLIOptions + [ productAbsolutePath. pathString] + options. arguments
@@ -244,23 +242,11 @@ public struct SwiftRunCommand: AsyncSwiftCommand {
244
242
arguments = options. arguments
245
243
}
246
244
247
- // For Linux, need to point LD_LIBRARY_PATH at the swift runtime
248
- let environment : [ String : String ] ?
249
- if toolchain. targetTriple. isLinux ( ) {
250
- var current = Environment . current
251
- let pathVar : EnvironmentKey = " LD_LIBRARY_PATH "
252
- current. prependPath ( key: pathVar, value: try toolchain. linuxSwiftStdlib. pathString)
253
- environment = . init( current)
254
- } else {
255
- environment = nil
256
- }
257
-
258
245
try self . run (
259
246
fileSystem: swiftCommandState. fileSystem,
260
247
executablePath: runnerPath,
261
248
originalWorkingDirectory: swiftCommandState. originalWorkingDirectory,
262
- arguments: arguments,
263
- environment: environment
249
+ arguments: arguments
264
250
)
265
251
} catch Diagnostics . fatalError {
266
252
throw ExitCode . failure
@@ -308,8 +294,7 @@ public struct SwiftRunCommand: AsyncSwiftCommand {
308
294
fileSystem: FileSystem ,
309
295
executablePath: AbsolutePath ,
310
296
originalWorkingDirectory: AbsolutePath ,
311
- arguments: [ String ] ,
312
- environment: [ String : String ] ? = nil
297
+ arguments: [ String ]
313
298
) throws {
314
299
// Make sure we are running from the original working directory.
315
300
let cwd : AbsolutePath ? = fileSystem. currentWorkingDirectory
@@ -318,7 +303,7 @@ public struct SwiftRunCommand: AsyncSwiftCommand {
318
303
}
319
304
320
305
let pathRelativeToWorkingDirectory = executablePath. relative ( to: originalWorkingDirectory)
321
- try execute ( path: executablePath. pathString, args: [ pathRelativeToWorkingDirectory. pathString] + arguments, env : environment )
306
+ try execute ( path: executablePath. pathString, args: [ pathRelativeToWorkingDirectory. pathString] + arguments)
322
307
}
323
308
324
309
/// Determines if a path points to a valid swift file.
@@ -342,7 +327,7 @@ public struct SwiftRunCommand: AsyncSwiftCommand {
342
327
}
343
328
344
329
/// A safe wrapper of TSCBasic.exec.
345
- private func execute( path: String , args: [ String ] , env : [ String : String ] ? ) throws -> Never {
330
+ private func execute( path: String , args: [ String ] ) throws -> Never {
346
331
#if !os(Windows)
347
332
// Dispatch will disable almost all asynchronous signals on its worker threads, and this is called from `async`
348
333
// context. To correctly `exec` a freshly built binary, we will need to:
@@ -373,13 +358,6 @@ public struct SwiftRunCommand: AsyncSwiftCommand {
373
358
#endif /* os(FreeBSD) || os(OpenBSD) */
374
359
#endif
375
360
376
- if let env {
377
- // set the env before we exec.
378
- // TODO: we should really use execve here.
379
- // Though, Windows doesn't really exec anyway.
380
- try env. forEach { try ProcessEnv . setVar ( $0, value: $1) }
381
- }
382
-
383
361
try TSCBasic . exec ( path: path, args: args)
384
362
}
385
363
0 commit comments