Permalink
Browse files

Merge `swift build --fetch'

* Adapted --get to --fetch
* Made --fetch a mode not an option
  • Loading branch information...
mxcl committed Feb 17, 2016
2 parents f3309a5 + 5fe1347 commit 9cad84893dde5118d074036e1659a71f8d33a51a
Showing with 17 additions and 2 deletions.
  1. +9 −2 Sources/swift-build/main.swift
  2. +8 −0 Sources/swift-build/usage.swift
@@ -34,18 +34,25 @@ do {
if let dir = opts.chdir {
try chdir(dir)
}
func fetch(root: String) throws -> [Package] {
let manifest = try Manifest(path: root, Manifest.filename, baseURL: root)
return try get(manifest)
}
switch mode {
case .Build(let conf):
let dirs = try directories()
let manifest = try Manifest(path: dirs.root, Manifest.filename, baseURL: dirs.root)
let packages = try get(manifest)
let packages = try fetch(dirs.root)
let (modules, products) = try transmute(packages)
let yaml = try describe(dirs.build, conf, modules, products, Xcc: opts.Xcc, Xld: opts.Xlinker)
try build(YAMLPath: yaml, target: "default")
case .Init:
try initPackage()
case .Fetch:
try fetch(try directories().root)
case .Usage:
usage()
@@ -25,12 +25,14 @@ func usage(print: (String) -> Void = { print($0) }) {
print(" dist - All of 'build' plus downloaded packages")
print(" If no mode is given, 'build' is the default.")
print(" --init Creates a new Swift project")
print(" --fetch Fetch package dependencies")
print("")
print("OPTIONS:")
print(" --chdir <value> Change working directory before any other operation [-C]")
print(" -v[v] Increase verbosity of informational output")
print(" -Xcc <flag> Pass flag through to all compiler instantiations")
print(" -Xlinker <flag> Pass flag through to all linker instantiations")
print(" --get Only pull down dependencies without building binaries")
}
enum CleanMode: String {
@@ -41,6 +43,7 @@ enum CleanMode: String {
enum Mode {
case Build(Configuration)
case Clean(CleanMode)
case Fetch
case Init
case Usage
case Version
@@ -132,6 +135,8 @@ func parse(commandLineArguments args: [String]) throws -> (Mode, Options) {
}
case (nil, .Version):
mode = .Version
case (nil, .Fetch):
mode = .Fetch
}
case .Switch(.Chdir):
@@ -171,6 +176,7 @@ extension Mode: CustomStringConvertible {
switch self {
case .Build(let conf): return "--build \(conf)"
case .Clean(let cleanMode): return "--clean=\(cleanMode)"
case .Fetch: return "--fetch"
case .Init: return "--init"
case .Usage: return "--help"
case .Version: return "--version"
@@ -184,6 +190,7 @@ private struct Cruncher {
enum TheMode: String {
case Build = "--configuration"
case Clean = "--clean"
case Fetch = "--fetch"
case Init = "--init"
case Usage = "--help"
case Version = "--version"
@@ -279,6 +286,7 @@ private func ==(lhs: Mode, rhs: Cruncher.Crunch.TheMode) -> Bool {
switch lhs {
case .Build: return rhs == .Build
case .Clean: return rhs == .Clean
case .Fetch: return rhs == .Fetch
case .Init: return rhs == .Init
case .Version: return rhs == .Version
case .Usage: return rhs == .Usage

0 comments on commit 9cad848

Please sign in to comment.