Restat build.ninja after gen
As of version 1.8, ninja caches mtimes in the .ninja_log file and will
not restat a file if it has an entry in the .ninja_log. This becomes
problematic for generator files such as build.ninja. In a scenario where
the .ninja_log has an entry for build.ninja (ie, after ninja has had to
trigger a re-gen) and a manual run of of `gn gen` has updated the
build.ninja file, a subsequent invocation of ninja will trigger yet
another re-gen of build.ninja.
This can be reproduced like this:
# Initial build
gn gen out && ninja -C out
# Trigger ninja re-gen so there's a build.ninja log entry
touch BUILD.gn && ninja -C out
# Manual re-gen
gn gen out
# The following command will re-gen again before building
ninja -C out
To work around this, the recommended approach from ninja is to use the
ninja restat tool to get ninja to update the mtime in the .ninja_log.
This CL does that by attempting to invoke `ninja -t restat build.ninja`
immediately after the build.ninja is generated by `gn gen`. Because this
tool was only introduced in 1.10, the usage is gated on having a ninja
binary of at least that version. The ninja binary can be provided via
the --ninja-executable switch.
Bug: 136
Change-Id: If40391aa13e6ef71c4e8ab26aff57d66a8137b8e
Reviewed-on: https://gn-review.googlesource.com/c/gn/+/10400
Commit-Queue: RJ Ascani <[email protected]>
Reviewed-by: Brett Wilson <[email protected]>
diff --git a/docs/reference.md b/docs/reference.md
index 06ab5a0..8eb1510 100644
--- a/docs/reference.md
+++ b/docs/reference.md
@@ -718,6 +718,16 @@
See "gn help switches" for the common command-line switches.
```
+#### **General options**
+
+```
+ --ninja-executable=<string>
+ Can be used to specify the ninja executable to use. This executable will
+ be used as an IDE option to indicate which ninja to use for building. This
+ executable will also be used as part of the gen process for triggering a
+ restat on generated ninja files.
+```
+
#### **IDE options**
```
@@ -7760,6 +7770,7 @@
* --dotfile: Override the name of the ".gn" file.
* --fail-on-unused-args: Treat unused build args as fatal errors.
* --markdown: Write help output in the Markdown format.
+ * --ninja-executable: Set the Ninja executable.
* --nocolor: Force non-colored output.
* -q: Quiet mode. Don't print output on success.
* --root: Explicitly specify source root.