Skip to content

Commit bac34ec

Browse files
committed
Merge pull request #188 from czechboy0/hd/generate_xcodeproj_customize_path
Generate Xcode project at custom path
2 parents e22800c + 08bff5f commit bac34ec

File tree

2 files changed

+18
-10
lines changed

2 files changed

+18
-10
lines changed

Sources/swift-build/main.swift

+4-3
Original file line numberDiff line numberDiff line change
@@ -90,13 +90,14 @@ do {
9090
case .Version:
9191
print("Apple Swift Package Manager 0.1")
9292

93-
case .GenerateXcodeproj:
93+
case .GenerateXcodeproj(let xcodeprojPath):
9494
let dirs = try directories()
9595
let packages = try fetch(dirs.root)
9696
let (modules, products) = try transmute(packages, rootdir: dirs.root)
9797
let swiftModules = modules.flatMap{ $0 as? SwiftModule }
98-
99-
let path = try Xcodeproj.generate(path: try getcwd(), package: packages.last!, modules: swiftModules, products: products)
98+
99+
let xcodeprojFolder = try (xcodeprojPath ?? ".").abspath()
100+
let path = try Xcodeproj.generate(path: xcodeprojFolder, package: packages.last!, modules: swiftModules, products: products)
100101

101102
print("generated:", path.prettied)
102103
}

Sources/swift-build/usage.swift

+14-7
Original file line numberDiff line numberDiff line change
@@ -18,11 +18,11 @@ func usage(print: (String) -> Void = { print($0) }) {
1818
print("USAGE: swift build [options]")
1919
print("")
2020
print("MODES:")
21-
print(" --configuration <value> Build with configuration (debug|release) [-c]")
22-
print(" --clean[=<mode>] Delete artefacts (build|dist) [-k]")
23-
print(" --init <mode> Creates a new Swift package (executable|library)")
24-
print(" --fetch Fetch package dependencies")
25-
print(" --generate-xcodeproj Generates an Xcode project for this package [-X]")
21+
print(" --configuration <value> Build with configuration (debug|release) [-c]")
22+
print(" --clean[=<mode>] Delete artefacts (build|dist) [-k]")
23+
print(" --init <mode> Creates a new Swift package (executable|library)")
24+
print(" --fetch Fetch package dependencies")
25+
print(" --generate-xcodeproj [<path>] Generates an Xcode project for this package [-X]")
2626
print("")
2727
print("OPTIONS:")
2828
print(" --chdir <value> Change working directory before any other operation [-C]")
@@ -44,7 +44,7 @@ enum Mode {
4444
case Init(InitPackage.InitMode)
4545
case Usage
4646
case Version
47-
case GenerateXcodeproj
47+
case GenerateXcodeproj(String?)
4848
}
4949

5050
struct Options {
@@ -148,7 +148,14 @@ func parse(commandLineArguments args: [String]) throws -> (Mode, Options) {
148148
case (nil, .Fetch):
149149
mode = .Fetch
150150
case (nil, .GenerateXcodeproj):
151-
mode = .GenerateXcodeproj
151+
mode = .GenerateXcodeproj(nil)
152+
switch try cruncher.peek() {
153+
case .Name(let path)?:
154+
mode = .GenerateXcodeproj(path)
155+
cruncher.postPeekPop()
156+
default:
157+
break
158+
}
152159
}
153160

154161
case .Switch(.Chdir):

0 commit comments

Comments
 (0)