-
-
Notifications
You must be signed in to change notification settings - Fork 243
feat: regenerate build.ninja when dub.json or dub.selections.json change #3134
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
Merged
+114
−2
Merged
Changes from 14 commits
Commits
Show all changes
15 commits
Select commit
Hold shift + click to select a range
f8a288e
feat: regenerate build.ninja when dub.json or dub.selections.json change
hariprakazz c67429e
test: add behavioral regen test - verify ninja attempts build.ninja r…
hariprakazz 2833bbd
test: replace textual grep checks with behavioral regen tests, cover …
hariprakazz 5c77da3
fix flaky regen test on fast runners, add sleep before touch
hariprakazz 0537c5a
debug: add mtime diagnostics to regen test
hariprakazz 6e90a3c
add explain flag to debug ci regen issue
hariprakazz 425ff8a
rewrite regen test in D, fix dub path resolution and dub.sdl tracking
hariprakazz 0cb4689
add debug output to diagnose windows failure
hariprakazz fbaed14
escape colons in ninja regen paths to fix windows drive-letter parsing
hariprakazz 025523c
re-add debug output
hariprakazz df0e7c2
escape colons in source file paths for windows compile edges
hariprakazz 57f6e48
remove debug output now that windows path fix is confirmed working
hariprakazz 06ce670
use common module die/log instead of manual return codes, per review …
hariprakazz 7cc5647
use common module die/log instead of manual return codes, per review …
hariprakazz 74a3b6e
ninja: escape lflags for Windows paths, add content-based regen test
hariprakazz File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or 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 hidden or 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,2 @@ | ||
| name "ninja-generator-sdl" | ||
| targetType "executable" |
This file contains hidden or 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 @@ | ||
| void main() {} |
This file contains hidden or 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,64 @@ | ||
| /+ dub.sdl: | ||
| name "ninja-generator-regen" | ||
| dependency "common" path="./common" | ||
| +/ | ||
|
|
||
| module ninja_generator_regen; | ||
|
|
||
| import std.process : environment, execute, Config; | ||
| import std.path : buildPath, dirName; | ||
| import std.file : setTimes, readText, remove; | ||
| import std.datetime : Clock; | ||
| import std.algorithm : canFind; | ||
| import core.thread : Thread; | ||
| import core.time : seconds; | ||
|
|
||
| import common; | ||
|
|
||
| bool regenerated(string projDir, string touchedFile) | ||
| { | ||
| Thread.sleep(1.seconds); | ||
| setTimes(buildPath(projDir, touchedFile), Clock.currTime, Clock.currTime); | ||
| const result = execute(["ninja"], null, Config.none, size_t.max, projDir); | ||
| return result.status == 0 && result.output.canFind("Regenerating build.ninja"); | ||
| } | ||
|
|
||
| int main() | ||
| { | ||
| const dub = environment.get("DUB", buildPath(__FILE_FULL_PATH__.dirName.dirName, "bin", "dub")); | ||
| const dc = environment.get("DC", "dmd"); | ||
| const curr_dir = environment.get("CURR_DIR", buildPath(__FILE_FULL_PATH__.dirName)); | ||
| const projDir = buildPath(curr_dir, "ninja-generator"); | ||
|
|
||
| if (execute([dub, "generate", "ninja", "--compiler", dc], null, Config.none, size_t.max, projDir).status) | ||
| die("dub generate ninja failed"); | ||
|
|
||
| execute(["ninja", "-t", "clean"], null, Config.none, size_t.max, projDir); | ||
| if (execute(["ninja"], null, Config.none, size_t.max, projDir).status) | ||
| die("initial ninja build failed"); | ||
|
|
||
| if (!regenerated(projDir, "dub.json")) | ||
| die("no regen after touching dub.json"); | ||
|
|
||
| const sdlProjDir = buildPath(curr_dir, "ninja-generator-sdl"); | ||
|
|
||
| if (execute([dub, "generate", "ninja", "--compiler", dc], null, Config.none, size_t.max, sdlProjDir).status) | ||
| die("dub generate ninja failed for dub.sdl project"); | ||
|
|
||
| const sdlBuildNinja = buildPath(sdlProjDir, "build.ninja"); | ||
| if (!readText(sdlBuildNinja).canFind("regen") || !readText(sdlBuildNinja).canFind("dub.sdl")) | ||
| die("build.ninja regen edge missing dub.sdl dependency"); | ||
|
|
||
| execute(["ninja", "-t", "clean"], null, Config.none, size_t.max, sdlProjDir); | ||
| if (execute(["ninja"], null, Config.none, size_t.max, sdlProjDir).status) | ||
| die("initial ninja build failed for dub.sdl project"); | ||
|
|
||
| if (!regenerated(sdlProjDir, "dub.sdl")) | ||
| die("no regen after touching dub.sdl"); | ||
|
|
||
| execute(["ninja", "-t", "clean"], null, Config.none, size_t.max, sdlProjDir); | ||
| remove(sdlBuildNinja); | ||
|
|
||
| log("PASS"); | ||
| return 0; | ||
| } | ||
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.