Skip to content

Delete POSIX target #2055

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

Merged
merged 1 commit into from
Mar 25, 2019
Merged
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
18 changes: 4 additions & 14 deletions Package.swift
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,6 @@ let package = Package(
targets: [
"clibc",
"SPMLibc",
"POSIX",
"Basic",
"SPMUtility",
"SourceControl",
Expand All @@ -43,7 +42,6 @@ let package = Package(
targets: [
"clibc",
"SPMLibc",
"POSIX",
"Basic",
"SPMUtility",
"SourceControl",
Expand All @@ -67,7 +65,6 @@ let package = Package(
targets: [
"clibc",
"SPMLibc",
"POSIX",
"Basic",
"SPMUtility",
]
Expand All @@ -91,18 +88,14 @@ let package = Package(
/** Cross-platform access to bare `libc` functionality. */
name: "SPMLibc",
dependencies: ["clibc"]),
.target(
/** “Swifty” POSIX functions from libc */
name: "POSIX",
dependencies: ["SPMLibc"]),
.target(
/** Basic support library */
name: "Basic",
dependencies: ["SPMLibc", "POSIX"]),
dependencies: ["SPMLibc"]),
.target(
/** Abstractions for common operations, should migrate to Basic */
name: "SPMUtility",
dependencies: ["POSIX", "Basic"]),
dependencies: ["Basic"]),
.target(
/** Source control operations */
name: "SourceControl",
Expand Down Expand Up @@ -177,11 +170,11 @@ let package = Package(
.target(
/** Test support library */
name: "TestSupport",
dependencies: ["Basic", "POSIX", "PackageGraph", "PackageLoading", "SourceControl", "SPMUtility", "Commands"]),
dependencies: ["Basic", "PackageGraph", "PackageLoading", "SourceControl", "SPMUtility", "Commands"]),
.target(
/** Test support executable */
name: "TestSupportExecutable",
dependencies: ["Basic", "POSIX", "SPMUtility"]),
dependencies: ["Basic", "SPMUtility"]),

.testTarget(
name: "BasicTests",
Expand Down Expand Up @@ -223,9 +216,6 @@ let package = Package(
.testTarget(
name: "PackageGraphPerformanceTests",
dependencies: ["PackageGraph", "TestSupport"]),
.testTarget(
name: "POSIXTests",
dependencies: ["POSIX", "TestSupport"]),
.testTarget(
name: "SourceControlTests",
dependencies: ["SourceControl", "TestSupport"]),
Expand Down
1 change: 0 additions & 1 deletion Sources/Basic/FileSystem.swift
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,6 @@

import SPMLibc
import Foundation
import enum POSIX.SystemError

public enum FileSystemError: Swift.Error {
/// Access to the path is denied.
Expand Down
1 change: 0 additions & 1 deletion Sources/Basic/PathShims.swift
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,6 @@

import SPMLibc
import Foundation
import enum POSIX.SystemError

/// Returns the "real path" corresponding to `path` by resolving any symbolic links.
public func resolveSymlinks(_ path: AbsolutePath) -> AbsolutePath {
Expand Down
1 change: 0 additions & 1 deletion Sources/Basic/Process.swift
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,6 @@

import class Foundation.ProcessInfo

import enum POSIX.SystemError
import SPMLibc
import Dispatch

Expand Down
1 change: 0 additions & 1 deletion Sources/Basic/ProcessEnv.swift
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,6 @@

import Foundation
import SPMLibc
import enum POSIX.SystemError

/// Provides functionality related a process's enviorment.
public enum ProcessEnv {
Expand Down
2 changes: 1 addition & 1 deletion Sources/Basic/README.md
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
# Basic Library

This library contains the basic support facilities for `swiftpm`. It is layered
on `SPMLibc`, `POSIX`, and `Foundation`, and defines the shared data structures,
on `SPMLibc` and `Foundation`, and defines the shared data structures,
utilities, and algorithms for the rest of the package manager.

This library is also intended to contain the bulk of the cross-platform
Expand Down
72 changes: 70 additions & 2 deletions Sources/Basic/misc.swift
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,6 @@

import SPMLibc
import Foundation
import enum POSIX.SystemError

/// Replace the current process image with a new process image.
///
Expand All @@ -20,7 +19,7 @@ import enum POSIX.SystemError
public func exec(path: String, args: [String]) throws {
let cArgs = CStringArray(args)
guard execv(path, cArgs.cArray) != -1 else {
throw POSIX.SystemError.exec(errno, path: path, args: args)
throw SystemError.exec(errno, path: path, args: args)
}
}

Expand Down Expand Up @@ -148,3 +147,72 @@ extension AbsolutePath {
return URL(fileURLWithPath: pathString)
}
}

// FIXME: Eliminate or find a proper place for this.
public enum SystemError: Swift.Error {
case chdir(Int32, String)
case close(Int32)
case exec(Int32, path: String, args: [String])
case pipe(Int32)
case posix_spawn(Int32, [String])
case read(Int32)
case setenv(Int32, String)
case stat(Int32, String)
case symlink(Int32, String, dest: String)
case unsetenv(Int32, String)
case waitpid(Int32)
}

import func SPMLibc.strerror_r
import var SPMLibc.EINVAL
import var SPMLibc.ERANGE

extension SystemError: CustomStringConvertible {
public var description: String {
func strerror(_ errno: Int32) -> String {
var cap = 64
while cap <= 16 * 1024 {
var buf = [Int8](repeating: 0, count: cap)
let err = SPMLibc.strerror_r(errno, &buf, buf.count)
if err == EINVAL {
return "Unknown error \(errno)"
}
if err == ERANGE {
cap *= 2
continue
}
if err != 0 {
fatalError("strerror_r error: \(err)")
}
return "\(String(cString: buf)) (\(errno))"
}
fatalError("strerror_r error: \(ERANGE)")
}

switch self {
case .chdir(let errno, let path):
return "chdir error: \(strerror(errno)): \(path)"
case .close(let errno):
return "close error: \(strerror(errno))"
case .exec(let errno, let path, let args):
let joinedArgs = args.joined(separator: " ")
return "exec error: \(strerror(errno)): \(path) \(joinedArgs)"
case .pipe(let errno):
return "pipe error: \(strerror(errno))"
case .posix_spawn(let errno, let args):
return "posix_spawn error: \(strerror(errno)), `\(args)`"
case .read(let errno):
return "read error: \(strerror(errno))"
case .setenv(let errno, let key):
return "setenv error: \(strerror(errno)): \(key)"
case .stat(let errno, _):
return "stat error: \(strerror(errno))"
case .symlink(let errno, let path, let dest):
return "symlink error: \(strerror(errno)): \(path) -> \(dest)"
case .unsetenv(let errno, let key):
return "unsetenv error: \(strerror(errno)): \(key)"
case .waitpid(let errno):
return "waitpid error: \(strerror(errno))"
}
}
}
77 changes: 0 additions & 77 deletions Sources/POSIX/Error.swift

This file was deleted.

8 changes: 0 additions & 8 deletions Sources/POSIX/README.md

This file was deleted.

34 changes: 0 additions & 34 deletions Sources/POSIX/env.swift

This file was deleted.

1 change: 0 additions & 1 deletion Sources/SPMUtility/InterruptHandler.swift
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,6 @@
*/

import SPMLibc
import enum POSIX.SystemError
import Basic

/// Interrupt signal handling global variables
Expand Down
1 change: 0 additions & 1 deletion Tests/POSIXTests/XCTestManifests.swift

This file was deleted.