-
Notifications
You must be signed in to change notification settings - Fork 89
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Signed-off-by: Matt Pennig <[email protected]>
- Loading branch information
Showing
6 changed files
with
345 additions
and
84 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,5 +1,6 @@ | ||
import ArgumentParser | ||
import Darwin | ||
import Foundation | ||
import ToolCommon | ||
|
||
@main | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,32 @@ | ||
import ToolCommon | ||
|
||
extension UsageError { | ||
static func buildMarker(_ path: String) -> Self { | ||
.init(message: """ | ||
error: Build marker (\(path)) doesn't exist. If you manually cleared Derived \ | ||
Data, you need to close and re-open the project for the file to be created \ | ||
again. Using the "Clean Build Folder" command instead (⇧ ⌘ K) won't trigger \ | ||
this error. If this error still happens after re-opening the project, please \ | ||
file a bug report here: \ | ||
https://github.com/MobileNativeFoundation/rules_xcodeproj/issues/new?template=bug.md | ||
""") | ||
} | ||
|
||
static func pifCache(_ path: String) -> Self { | ||
.init(message: """ | ||
error: PIFCache (\(path)) doesn't exist. If you manually cleared Derived \ | ||
Data, you need to close and re-open the project for the PIFCache to be created \ | ||
again. Using the "Clean Build Folder" command instead (⇧ ⌘ K) won't trigger \ | ||
this error. If this error still happens after re-opening the project, please \ | ||
file a bug report here: \ | ||
https://github.com/MobileNativeFoundation/rules_xcodeproj/issues/new?template=bug.md | ||
""") | ||
} | ||
|
||
static func buildRequest(_ path: String) -> Self { | ||
.init(message: """ | ||
error: Couldn't find a build-request.json file inside \(path)". Please file a bug \ | ||
report here: https://github.com/MobileNativeFoundation/rules_xcodeproj/issues/new?template=bug.md | ||
""") | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,79 @@ | ||
enum PIF { | ||
struct Project: Decodable { | ||
let targets: [String] | ||
} | ||
|
||
struct Target: Decodable { | ||
struct BuildConfiguration: Decodable { | ||
let name: String | ||
let buildSettings: [String: String] | ||
} | ||
|
||
let guid: String | ||
let buildConfigurations: [BuildConfiguration] | ||
} | ||
} | ||
|
||
struct BuildRequest: Decodable { | ||
let command: String = "build" // TODO: support other commands (e.g. "buildFiles") | ||
let configurationName: String | ||
let configuredTargets: [String] | ||
let platform: String | ||
|
||
enum Root: CodingKey { | ||
case configuredTargets | ||
case parameters | ||
|
||
enum ConfiguredTargets: CodingKey { | ||
case guid | ||
} | ||
enum Parameters: CodingKey { | ||
case activeRunDestination | ||
case configurationName | ||
|
||
enum ActiveRunDestination: CodingKey { | ||
case platform | ||
} | ||
} | ||
} | ||
|
||
init(from decoder: Decoder) throws { | ||
let root = try decoder.container(keyedBy: Root.self) | ||
let parameters = try root.nestedContainer(keyedBy: Root.Parameters.self, forKey: .parameters) | ||
|
||
// configurationName | ||
self.configurationName = try parameters.decode(String.self, forKey: .configurationName) | ||
|
||
// configuredTargets | ||
var configuredTargets = try root.nestedUnkeyedContainer(forKey: .configuredTargets) | ||
var decodedTargets = [String]() | ||
while !configuredTargets.isAtEnd { | ||
let target = try configuredTargets.nestedContainer(keyedBy: Root.ConfiguredTargets.self) | ||
decodedTargets.append(try target.decode(String.self, forKey: .guid)) | ||
} | ||
self.configuredTargets = decodedTargets | ||
|
||
// platform | ||
let activeRunDestination = try parameters.nestedContainer(keyedBy: Root.Parameters.ActiveRunDestination.self, forKey: .activeRunDestination) | ||
self.platform = try activeRunDestination.decode(String.self, forKey: .platform) | ||
} | ||
} | ||
|
||
enum Output { | ||
typealias Map = [String: Target] | ||
|
||
struct Target: Codable { | ||
struct Config: Codable { | ||
struct Settings: Codable { | ||
let base: [String] | ||
var platforms: [String: Optional<[String]>] | ||
} | ||
|
||
let build: Settings? | ||
let buildFiles: Settings? | ||
} | ||
|
||
let label: String | ||
let configs: [String: Config] | ||
} | ||
} |
Oops, something went wrong.