Skip to content
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

Add --project-root option to generate command. #828

Merged
merged 3 commits into from
Apr 8, 2020
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
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
#### Added
- Improve speed of metadata parsing and dependency resolution. [#803](https://github.com/yonaskolb/XcodeGen/pull/803) @michaeleisel
- Improve support for iOS sticker packs and add support for `launchAutomaticallySubstyle` to run schemes. [#824](https://github.com/yonaskolb/XcodeGen/pull/824) @scelis
- Add --project-root option to generate command. [#828](https://github.com/yonaskolb/XcodeGen/pull/828) @ileitch

#### Fixed
- Fixed issue when linking and embeding static frameworks: they should be linked and NOT embed. [#820](https://github.com/yonaskolb/XcodeGen/pull/820) @acecilia
Expand Down
4 changes: 2 additions & 2 deletions Sources/ProjectSpec/SpecLoader.swift
Original file line number Diff line number Diff line change
Expand Up @@ -15,10 +15,10 @@ public class SpecLoader {
self.version = version
}

public func loadProject(path: Path, variables: [String: String] = [:]) throws -> Project {
public func loadProject(path: Path, projectRoot: Path? = nil, variables: [String: String] = [:]) throws -> Project {
let spec = try SpecFile(path: path)
let resolvedDictionary = spec.resolvedDictionary(variables: variables)
let project = try Project(basePath: spec.basePath, jsonDictionary: resolvedDictionary)
let project = try Project(basePath: projectRoot ?? spec.basePath, jsonDictionary: resolvedDictionary)

self.project = project
projectDictionary = resolvedDictionary
Expand Down
5 changes: 4 additions & 1 deletion Sources/XcodeGenCLI/Commands/ProjectCommand.swift
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,9 @@ class ProjectCommand: Command {
@Key("-s", "--spec", description: "The path to the project spec file. Defaults to project.yml")
var spec: Path?

@Key("-r", "--project-root", description: "The path to the project root directory. Defaults to the directory containing the project spec.")
brentleyjones marked this conversation as resolved.
Show resolved Hide resolved
var projectRoot: Path?

@Flag("-n", "--no-env", description: "Disable environment variable expansions")
var disableEnvExpansion: Bool

Expand All @@ -38,7 +41,7 @@ class ProjectCommand: Command {
let variables: [String: String] = disableEnvExpansion ? [:] : ProcessInfo.processInfo.environment

do {
project = try specLoader.loadProject(path: projectSpecPath, variables: variables)
project = try specLoader.loadProject(path: projectSpecPath, projectRoot: projectRoot, variables: variables)
} catch {
throw GenerationError.projectSpecParsingError(error)
}
Expand Down