Skip to content

Commit 9cad848

Browse files
committed
Merge `swift build --fetch'
* Adapted --get to --fetch * Made --fetch a mode not an option
2 parents f3309a5 + 5fe1347 commit 9cad848

File tree

2 files changed

+17
-2
lines changed

2 files changed

+17
-2
lines changed

Sources/swift-build/main.swift

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -34,18 +34,25 @@ do {
3434
if let dir = opts.chdir {
3535
try chdir(dir)
3636
}
37+
38+
func fetch(root: String) throws -> [Package] {
39+
let manifest = try Manifest(path: root, Manifest.filename, baseURL: root)
40+
return try get(manifest)
41+
}
3742

3843
switch mode {
3944
case .Build(let conf):
4045
let dirs = try directories()
41-
let manifest = try Manifest(path: dirs.root, Manifest.filename, baseURL: dirs.root)
42-
let packages = try get(manifest)
46+
let packages = try fetch(dirs.root)
4347
let (modules, products) = try transmute(packages)
4448
let yaml = try describe(dirs.build, conf, modules, products, Xcc: opts.Xcc, Xld: opts.Xlinker)
4549
try build(YAMLPath: yaml, target: "default")
4650

4751
case .Init:
4852
try initPackage()
53+
54+
case .Fetch:
55+
try fetch(try directories().root)
4956

5057
case .Usage:
5158
usage()

Sources/swift-build/usage.swift

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -25,12 +25,14 @@ func usage(print: (String) -> Void = { print($0) }) {
2525
print(" dist - All of 'build' plus downloaded packages")
2626
print(" If no mode is given, 'build' is the default.")
2727
print(" --init Creates a new Swift project")
28+
print(" --fetch Fetch package dependencies")
2829
print("")
2930
print("OPTIONS:")
3031
print(" --chdir <value> Change working directory before any other operation [-C]")
3132
print(" -v[v] Increase verbosity of informational output")
3233
print(" -Xcc <flag> Pass flag through to all compiler instantiations")
3334
print(" -Xlinker <flag> Pass flag through to all linker instantiations")
35+
print(" --get Only pull down dependencies without building binaries")
3436
}
3537

3638
enum CleanMode: String {
@@ -41,6 +43,7 @@ enum CleanMode: String {
4143
enum Mode {
4244
case Build(Configuration)
4345
case Clean(CleanMode)
46+
case Fetch
4447
case Init
4548
case Usage
4649
case Version
@@ -132,6 +135,8 @@ func parse(commandLineArguments args: [String]) throws -> (Mode, Options) {
132135
}
133136
case (nil, .Version):
134137
mode = .Version
138+
case (nil, .Fetch):
139+
mode = .Fetch
135140
}
136141

137142
case .Switch(.Chdir):
@@ -171,6 +176,7 @@ extension Mode: CustomStringConvertible {
171176
switch self {
172177
case .Build(let conf): return "--build \(conf)"
173178
case .Clean(let cleanMode): return "--clean=\(cleanMode)"
179+
case .Fetch: return "--fetch"
174180
case .Init: return "--init"
175181
case .Usage: return "--help"
176182
case .Version: return "--version"
@@ -184,6 +190,7 @@ private struct Cruncher {
184190
enum TheMode: String {
185191
case Build = "--configuration"
186192
case Clean = "--clean"
193+
case Fetch = "--fetch"
187194
case Init = "--init"
188195
case Usage = "--help"
189196
case Version = "--version"
@@ -279,6 +286,7 @@ private func ==(lhs: Mode, rhs: Cruncher.Crunch.TheMode) -> Bool {
279286
switch lhs {
280287
case .Build: return rhs == .Build
281288
case .Clean: return rhs == .Clean
289+
case .Fetch: return rhs == .Fetch
282290
case .Init: return rhs == .Init
283291
case .Version: return rhs == .Version
284292
case .Usage: return rhs == .Usage

0 commit comments

Comments
 (0)