Skip to content

Commit

Permalink
Add configuration option
Browse files Browse the repository at this point in the history
  • Loading branch information
JosephDuffy committed Nov 13, 2020
1 parent ea66417 commit 46d0d55
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 2 deletions.
4 changes: 4 additions & 0 deletions Sources/BuildCommand/BuildCommand.swift
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,9 @@ public struct BuildCommand: ParsableCommand {
@Option()
var scheme: String

@Option()
var configuration: String?

@Option()
var buildDirectory: String?

Expand All @@ -42,6 +45,7 @@ public struct BuildCommand: ParsableCommand {
project: project.map { URL(fileURLWithPath: $0, isDirectory: true) },
workspace: workspace.map { URL(fileURLWithPath: $0, isDirectory: true) },
scheme: scheme,
configuration: configuration,
buildDirectory: buildDirectory.map { URL(fileURLWithPath: $0, isDirectory: true) },
enableVerboseLogging: globalOptions.verbose
)
Expand Down
18 changes: 16 additions & 2 deletions Sources/BuildRunner/BuildRunner.swift
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,8 @@ public final class BuildRunner {
- parameter versionSpecifier: The version of the platform to test.
- parameter project: The path of the project. Can be `nil` if inside a directory with an Xcode project, Xcode workspace, or a swift package.
- parameter workspace: The path of the workfspace. Can be `nil` if inside a directory with an Xcode project, Xcode workspace, or a swift package.
- parameter scheme: The scheme to test. For swift packages this is the target.
- parameter scheme: The scheme to buikd. For swift packages this is the target.
- parameter configuration: The configuration to build.
- parameter buildDirectory: The directory place the build artifacts in to. Unlike `xcodebuild` this is related to the working directory, not the project.
*/
public static func build(
Expand All @@ -22,6 +23,7 @@ public final class BuildRunner {
project: URL?,
workspace: URL?,
scheme: String,
configuration: String?,
buildDirectory: URL?,
enableVerboseLogging: Bool = false
) throws {
Expand Down Expand Up @@ -50,6 +52,11 @@ public final class BuildRunner {
command.append(workspace.path)
}

configuration.map { configuration in
command.append("-configuration")
command.append(configuration)
}

buildDirectory.map { buildDirectory in
command.append("BUILD_DIR=\(buildDirectory.path)")
}
Expand All @@ -64,7 +71,8 @@ public final class BuildRunner {
- parameter versionSpecifier: The version of the platform to test.
- parameter project: The path of the project. Can be `nil` if inside a directory with an Xcode project, Xcode workspace, or a swift package.
- parameter workspace: The path of the workfspace. Can be `nil` if inside a directory with an Xcode project, Xcode workspace, or a swift package.
- parameter scheme: The scheme to test. For swift packages this is the target.
- parameter scheme: The scheme to archive. For swift packages this is the target.
- parameter configuration: The configuration to archive.
- parameter archivePath: The path to output the archive to. If the path doesn't end in `.xcarchive` it will be automatically appended.
*/
public static func archive(
Expand All @@ -73,6 +81,7 @@ public final class BuildRunner {
project: URL?,
workspace: URL?,
scheme: String,
configuration: String?,
archivePath: String?,
enableVerboseLogging: Bool = false
) throws {
Expand Down Expand Up @@ -101,6 +110,11 @@ public final class BuildRunner {
command.append(workspace.path)
}

configuration.map { configuration in
command.append("-configuration")
command.append(configuration)
}

archivePath.map { archivePath in
command.append("-archivePath")
command.append(archivePath)
Expand Down

0 comments on commit 46d0d55

Please sign in to comment.