Skip to content

Generate Xcode project at custom path #188

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 11, 2016
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
7 changes: 4 additions & 3 deletions Sources/swift-build/main.swift
Original file line number Diff line number Diff line change
Expand Up @@ -90,13 +90,14 @@ do {
case .Version:
print("Apple Swift Package Manager 0.1")

case .GenerateXcodeproj:
case .GenerateXcodeproj(let xcodeprojPath):
let dirs = try directories()
let packages = try fetch(dirs.root)
let (modules, products) = try transmute(packages, rootdir: dirs.root)
let swiftModules = modules.flatMap{ $0 as? SwiftModule }

let path = try Xcodeproj.generate(path: try getcwd(), package: packages.last!, modules: swiftModules, products: products)

let xcodeprojFolder = try (xcodeprojPath ?? ".").abspath()
let path = try Xcodeproj.generate(path: xcodeprojFolder, package: packages.last!, modules: swiftModules, products: products)

print("generated:", path.prettied)
}
Expand Down
21 changes: 14 additions & 7 deletions Sources/swift-build/usage.swift
Original file line number Diff line number Diff line change
Expand Up @@ -18,11 +18,11 @@ func usage(print: (String) -> Void = { print($0) }) {
print("USAGE: swift build [options]")
print("")
print("MODES:")
print(" --configuration <value> Build with configuration (debug|release) [-c]")
print(" --clean[=<mode>] Delete artefacts (build|dist) [-k]")
print(" --init <mode> Creates a new Swift package (executable|library)")
print(" --fetch Fetch package dependencies")
print(" --generate-xcodeproj Generates an Xcode project for this package [-X]")
print(" --configuration <value> Build with configuration (debug|release) [-c]")
print(" --clean[=<mode>] Delete artefacts (build|dist) [-k]")
print(" --init <mode> Creates a new Swift package (executable|library)")
print(" --fetch Fetch package dependencies")
print(" --generate-xcodeproj [<path>] Generates an Xcode project for this package [-X]")
print("")
print("OPTIONS:")
print(" --chdir <value> Change working directory before any other operation [-C]")
Expand All @@ -44,7 +44,7 @@ enum Mode {
case Init(InitPackage.InitMode)
case Usage
case Version
case GenerateXcodeproj
case GenerateXcodeproj(String?)
}

struct Options {
Expand Down Expand Up @@ -148,7 +148,14 @@ func parse(commandLineArguments args: [String]) throws -> (Mode, Options) {
case (nil, .Fetch):
mode = .Fetch
case (nil, .GenerateXcodeproj):
mode = .GenerateXcodeproj
mode = .GenerateXcodeproj(nil)
switch try cruncher.peek() {
case .Name(let path)?:
mode = .GenerateXcodeproj(path)
cruncher.postPeekPop()
default:
break
}
}

case .Switch(.Chdir):
Expand Down