Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
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 9cad848
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 2 deletions.
11 changes: 9 additions & 2 deletions Sources/swift-build/main.swift
Expand Up @@ -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()
Expand Down
8 changes: 8 additions & 0 deletions Sources/swift-build/usage.swift
Expand Up @@ -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 {
Expand All @@ -41,6 +43,7 @@ enum CleanMode: String {
enum Mode {
case Build(Configuration)
case Clean(CleanMode)
case Fetch
case Init
case Usage
case Version
Expand Down Expand Up @@ -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):
Expand Down Expand Up @@ -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"
Expand All @@ -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"
Expand Down Expand Up @@ -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
Expand Down

0 comments on commit 9cad848

Please sign in to comment.