Skip to content

Commit 9e52092

Browse files
committed
option is always present, and emits diagnostic error if used on unsupported platform.
1 parent efb4346 commit 9e52092

File tree

3 files changed

+19
-13
lines changed

3 files changed

+19
-13
lines changed

Package.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ let macOSPlatform: SupportedPlatform
2020
if let deploymentTarget = ProcessInfo.processInfo.environment["SWIFTPM_MACOS_DEPLOYMENT_TARGET"] {
2121
macOSPlatform = .macOS(deploymentTarget)
2222
} else {
23-
macOSPlatform = .macOS(.v10_13)
23+
macOSPlatform = .macOS(.v10_10)
2424
}
2525

2626
let package = Package(

Sources/Commands/Options.swift

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -112,10 +112,8 @@ public class ToolOptions {
112112
archs.count > 1 ? .xcode : _buildSystem
113113
}
114114

115-
#if os(macOS)
116115
/// The location of the netrc file which should be use for authentication when downloading binary target artifacts
117116
public var netrcFilePath: AbsolutePath?
118-
#endif
119117

120118
public var _buildSystem: BuildSystemKind = .native
121119

Sources/Commands/SwiftTool.swift

Lines changed: 18 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -474,16 +474,11 @@ public class SwiftTool<Options: ToolOptions> {
474474
option: parser.add(option: "--build-system", kind: BuildSystemKind.self, usage: nil),
475475
to: { $0._buildSystem = $1 })
476476

477-
#if os(macOS)
478-
if #available(macOS 10.13, *) {
479-
// implementation of the netrc reader depends upon macOS 10.13
480-
binder.bind(
481-
option: parser.add(
482-
option: "--netrc-file", kind: PathArgument.self,
483-
usage: "Absolute path to netrc file for downloading binary target artifacts"),
484-
to: { $0.netrcFilePath = $1.path })
485-
}
486-
#endif
477+
binder.bind(
478+
option: parser.add(
479+
option: "--netrc-file", kind: PathArgument.self,
480+
usage: "Absolute path to netrc file for downloading binary target artifacts (macOS >=10.13)"),
481+
to: { $0.netrcFilePath = $1.path })
487482

488483
// Let subclasses bind arguments.
489484
type(of: self).defineArguments(parser: parser, binder: binder)
@@ -574,6 +569,19 @@ public class SwiftTool<Options: ToolOptions> {
574569
if result.exists(arg: "--arch") && result.exists(arg: "--triple") {
575570
diagnostics.emit(.mutuallyExclusiveArgumentsError(arguments: ["--arch", "--triple"]))
576571
}
572+
573+
if result.exists(arg: "--netrc-file") {
574+
// --netrc-file option only supported on macOS >=10.13
575+
#if os(macOS)
576+
if #available(macOS 10.13, *) {
577+
// ok, check succeeds
578+
diagnostics.emit(error: "--netrc-file option is only supported on macOS >=10.13")
579+
} else {
580+
}
581+
#else
582+
diagnostics.emit(error: "--netrc-file option is only supported on macOS >=10.13")
583+
#endif
584+
}
577585
}
578586

579587
class func defineArguments(parser: ArgumentParser, binder: ArgumentBinder<Options>) {

0 commit comments

Comments
 (0)