-
Notifications
You must be signed in to change notification settings - Fork 49
Implement generation status #12
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
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -36,7 +36,7 @@ enum Generator { | |
/// @note this version is written into the `XCHAMMER_DEPS_HASH` build setting | ||
/// the version can be extracted with a simple search: i.e. | ||
/// grep -m 1 XCHAMMER_DEPS_HASH $PROJ | sed 's,.*version:\(.*\):.*,\1,g' | ||
public static let BinaryVersion = "0.1.2" | ||
public static let BinaryVersion = "0.1.3" | ||
|
||
/// Used to store the `depsHash` into the project | ||
static let DepsHashSettingName = "XCHAMMER_DEPS_HASH" | ||
|
@@ -91,18 +91,28 @@ enum Generator { | |
// Use whatever command and XCHammer this project was built with | ||
let generateCommand = CommandLine.arguments.filter { $0 != "--force" } | ||
|
||
let genStatusPath: String | ||
if let xcworkspacePath = genOptions.xcworkspacePath { | ||
genStatusPath = XCHammerAsset.genStatus.getPath(underProj: | ||
xcworkspacePath) | ||
} else { | ||
genStatusPath = XCHammerAsset.genStatus.getPath(underProj: | ||
genOptions.outputProjectPath) | ||
} | ||
|
||
// Exit with a non 0 status to ensure Xcode reloads the project ( by | ||
// forcing another build in the future ) | ||
// Determine state by comparing timestamps of the script. | ||
let updateScript = """ | ||
# This file is governed by XCHammer | ||
set -e | ||
if [[ $ACTION == "clean" ]]; then | ||
exit 0 | ||
fi | ||
|
||
PREV_STAT=`stat -f %c "$0"` | ||
PREV_STAT=`stat -f %c "\(genStatusPath)"` | ||
\(generateCommand.joined(separator: " ")) | ||
STAT=`stat -f %c "$0"` | ||
STAT=`stat -f %c "\(genStatusPath)"` | ||
if [[ "$PREV_STAT" != "$STAT" ]]; then | ||
echo "error: Xcode project was out-of-date so we updated it for you! Please build again." | ||
exit 1 | ||
|
@@ -305,6 +315,13 @@ enum Generator { | |
fatalError("Can't write BUILD file") | ||
} | ||
|
||
let genStatusPath = XCHammerAsset.genStatus.getPath(underProj: | ||
tempProjectPath) | ||
guard FileManager.default.createFile(atPath: genStatusPath, | ||
contents: "".data(using: .utf8), attributes: nil) else { | ||
fatalError("Can't write genStatus") | ||
} | ||
|
||
// Add the entitilement rules to the queried rules | ||
let targetsToBuild = genfileLabels + entitlementRules | ||
.map { BuildLabel("/" + relativeProjDir + "/XCHammerAssets:" + $0.name) } | ||
|
@@ -642,6 +659,19 @@ enum Generator { | |
depsHash: depsHash) | ||
}) | ||
|
||
// Write the genStatus into the workspace | ||
if let xcworkspacePath = xcworkspacePath { | ||
try? FileManager.default.createDirectory(atPath: | ||
(xcworkspacePath + Path("XCHammerAssets")).string, | ||
withIntermediateDirectories: true, | ||
attributes: [:]) | ||
let genStatusPath = XCHammerAsset.genStatus.getPath(underProj: | ||
xcworkspacePath) | ||
guard FileManager.default.createFile(atPath: genStatusPath, | ||
contents: "".data(using: .utf8), attributes: nil) else { | ||
fatalError("Can't write genStatus") | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Same here |
||
} | ||
} | ||
return results.first ?? .success() | ||
} | ||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,11 +1,12 @@ | ||
# This file is governed by XCHammer | ||
set -e | ||
if [[ $ACTION == "clean" ]]; then | ||
exit 0 | ||
fi | ||
|
||
PREV_STAT=`stat -f %c "$0"` | ||
PREV_STAT=`stat -f %c "/Users/jerry/Projects/xchammer-github/sample/UrlGet/UrlGet.xcodeproj/XCHammerAssets/genStatus"` | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. are you expecting absolute paths here? remove There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Yep we're using absolute paths, and unfortunately, they are all hardcoded to the last persons computer. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. We should have a better way.. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. |
||
/Users/jerry/Projects/xchammer-github/.build/debug/XCHammer generate /Users/jerry/Projects/xchammer-github/sample/UrlGet/XCHammer.yaml --workspace_root /Users/jerry/Projects/xchammer-github/sample/UrlGet | ||
STAT=`stat -f %c "$0"` | ||
STAT=`stat -f %c "/Users/jerry/Projects/xchammer-github/sample/UrlGet/UrlGet.xcodeproj/XCHammerAssets/genStatus"` | ||
if [[ "$PREV_STAT" != "$STAT" ]]; then | ||
echo "error: Xcode project was out-of-date so we updated it for you! Please build again." | ||
exit 1 | ||
|
Large diffs are not rendered by default.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
What does this mean for people that run
xchammer
? We should have something helpful hereThere was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
None of the of the fatals here are meaningful to users, as they're invalid program states ( fatal errors ). Perhaps we should cull them into a
fatal XCHammer
that is more clear.