* [PATCH] meson: regenerate config-list.h when Documentation changes
@ 2026-02-07 21:59 D. Ben Knoble
2026-02-07 22:38 ` Ben Knoble
` (2 more replies)
0 siblings, 3 replies; 46+ messages in thread
From: D. Ben Knoble @ 2026-02-07 21:59 UTC (permalink / raw)
To: git; +Cc: D. Ben Knoble, Junio C Hamano, Patrick Steinhardt, Evan Martin
The Meson-based build doesn't know when to rebuild config-list.h, so the
header is sometimes stale.
For example, an old build directory might have config-list.h from before
4173df5187 (submodule: introduce extensions.submodulePathConfig,
2026-01-12), which added submodule.<name>.gitdir to the list. Without
it, t9902-completion.sh fails. Regenerating the config-list.h artifact
from sources fixes the artifact and the test.
Teach the meson build to depend on the Documentation files that
generate-configlist.sh reads by having it use the output of
generate-configlist-deps.sh as a list of dependency files, since Meson
does not have (or want) builtin support for globbing like Make.
Signed-off-by: D. Ben Knoble <ben.knoble+github@gmail.com>
---
Notes (benknoble/commits):
I considered having generate-configlist.sh write its own dependency
list, which Meson also supports… idk though. Input welcome :)
generate-configlist-deps.sh | 5 +++++
meson.build | 1 +
2 files changed, 6 insertions(+)
create mode 100755 generate-configlist-deps.sh
diff --git a/generate-configlist-deps.sh b/generate-configlist-deps.sh
new file mode 100755
index 0000000000..a873e976b6
--- /dev/null
+++ b/generate-configlist-deps.sh
@@ -0,0 +1,5 @@
+#! /bin/sh
+
+printf '%s\n' \
+ "$MESON_SOURCE_ROOT"/Documentation/*config.adoc \
+ "$MESON_SOURCE_ROOT"/Documentation/config/*.adoc
diff --git a/meson.build b/meson.build
index 3a1d12caa4..4df7caa206 100644
--- a/meson.build
+++ b/meson.build
@@ -720,6 +720,7 @@ endif
builtin_sources += custom_target(
output: 'config-list.h',
+ depend_files: run_command(meson.current_source_dir() + '/generate-configlist-deps').stdout().strip().split('\n'),
command: [
shell,
meson.current_source_dir() + '/generate-configlist.sh',
--
2.52.0.rc0.971.g305ecc6b61.dirty
^ permalink raw reply related [flat|nested] 46+ messages in thread* Re: [PATCH] meson: regenerate config-list.h when Documentation changes 2026-02-07 21:59 [PATCH] meson: regenerate config-list.h when Documentation changes D. Ben Knoble @ 2026-02-07 22:38 ` Ben Knoble 2026-02-09 15:19 ` [PATCH v2] " D. Ben Knoble 2026-02-09 15:25 ` [PATCH] meson: " Patrick Steinhardt 2 siblings, 0 replies; 46+ messages in thread From: Ben Knoble @ 2026-02-07 22:38 UTC (permalink / raw) To: D. Ben Knoble; +Cc: git, Junio C Hamano, Patrick Steinhardt, Evan Martin > Le 7 févr. 2026 à 16:59, D. Ben Knoble <ben.knoble+github@gmail.com> a écrit : > > diff --git a/generate-configlist-deps.sh b/generate-configlist-deps.sh > new file mode 100755 > index 0000000000..a873e976b6 > --- /dev/null > +++ b/generate-configlist-deps.sh > @@ -0,0 +1,5 @@ > +#! /bin/sh > + > +printf '%s\n' \ > + "$MESON_SOURCE_ROOT"/Documentation/*config.adoc \ > + "$MESON_SOURCE_ROOT"/Documentation/config/*.adoc > diff --git a/meson.build b/meson.build > index 3a1d12caa4..4df7caa206 100644 > --- a/meson.build > +++ b/meson.build > @@ -720,6 +720,7 @@ endif > > builtin_sources += custom_target( > output: 'config-list.h', > + depend_files: run_command(meson.current_source_dir() + '/generate-configlist-deps').stdout().strip().split('\n'), > Ah, woops. I renamed the file locally before committing but forgot to update the meson spec. This line should have the obvious change to use the correct filename. Will send a v2 when I get more feedback. ^ permalink raw reply [flat|nested] 46+ messages in thread
* [PATCH v2] meson: regenerate config-list.h when Documentation changes 2026-02-07 21:59 [PATCH] meson: regenerate config-list.h when Documentation changes D. Ben Knoble 2026-02-07 22:38 ` Ben Knoble @ 2026-02-09 15:19 ` D. Ben Knoble 2026-02-11 23:51 ` [PATCH v3] " D. Ben Knoble 2026-02-09 15:25 ` [PATCH] meson: " Patrick Steinhardt 2 siblings, 1 reply; 46+ messages in thread From: D. Ben Knoble @ 2026-02-09 15:19 UTC (permalink / raw) To: git; +Cc: D. Ben Knoble, Junio C Hamano, Patrick Steinhardt, Evan Martin The Meson-based build doesn't know when to rebuild config-list.h, so the header is sometimes stale. For example, an old build directory might have config-list.h from before 4173df5187 (submodule: introduce extensions.submodulePathConfig, 2026-01-12), which added submodule.<name>.gitdir to the list. Without it, t9902-completion.sh fails. Regenerating the config-list.h artifact from sources fixes the artifact and the test. Teach the meson build to depend on the Documentation files that generate-configlist.sh reads by having it use the output of generate-configlist-deps.sh as a list of dependency files, since Meson does not have (or want) builtin support for globbing like Make. Signed-off-by: D. Ben Knoble <ben.knoble+github@gmail.com> --- Notes (benknoble/commits): I considered having generate-configlist.sh write its own dependency list, which Meson also supports… idk though. Input welcome :) This was also built on top of commits [1] on next, but should not depend on them despite what base-commit and prerequisite-patch-id say. Indeed, it applies cleanly to master @ 3e0db84c88 (Start 2.54 cycle, 2026-02-05). [1]: https://lore.kernel.org/git/20260207215924.28863-1-ben.knoble+github@gmail.com/ generate-configlist-deps.sh | 5 +++++ meson.build | 1 + 2 files changed, 6 insertions(+) create mode 100755 generate-configlist-deps.sh diff --git a/generate-configlist-deps.sh b/generate-configlist-deps.sh new file mode 100755 index 0000000000..a873e976b6 --- /dev/null +++ b/generate-configlist-deps.sh @@ -0,0 +1,5 @@ +#! /bin/sh + +printf '%s\n' \ + "$MESON_SOURCE_ROOT"/Documentation/*config.adoc \ + "$MESON_SOURCE_ROOT"/Documentation/config/*.adoc diff --git a/meson.build b/meson.build index 3a1d12caa4..eb6a149c9f 100644 --- a/meson.build +++ b/meson.build @@ -720,6 +720,7 @@ endif builtin_sources += custom_target( output: 'config-list.h', + depend_files: run_command(meson.current_source_dir() + '/generate-configlist-deps.sh', check: true).stdout().strip().split('\n'), command: [ shell, meson.current_source_dir() + '/generate-configlist.sh', Diff-intervalle contre v1 : 1: b03d70c9f3 ! 1: c9ae171eed meson: regenerate config-list.h when Documentation changes @@ meson.build: endif builtin_sources += custom_target( output: 'config-list.h', -+ depend_files: run_command(meson.current_source_dir() + '/generate-configlist-deps').stdout().strip().split('\n'), ++ depend_files: run_command(meson.current_source_dir() + '/generate-configlist-deps.sh', check: true).stdout().strip().split('\n'), command: [ shell, meson.current_source_dir() + '/generate-configlist.sh', base-commit: 64333814d3ac6e46b6b9c308a6398a66743a4022 prerequisite-patch-id: 364ba1899740b93be5957262d3583348d030e8fa -- 2.52.0.rc0.1018.g3ad6585c12.dirty ^ permalink raw reply related [flat|nested] 46+ messages in thread
* [PATCH v3] meson: regenerate config-list.h when Documentation changes 2026-02-09 15:19 ` [PATCH v2] " D. Ben Knoble @ 2026-02-11 23:51 ` D. Ben Knoble 2026-02-12 8:06 ` Patrick Steinhardt ` (3 more replies) 0 siblings, 4 replies; 46+ messages in thread From: D. Ben Knoble @ 2026-02-11 23:51 UTC (permalink / raw) To: git Cc: D. Ben Knoble, Phillip Wood, Patrick Steinhardt, Junio C Hamano, Evan Martin The Meson-based build doesn't know when to rebuild config-list.h, so the header is sometimes stale. For example, an old build directory might have config-list.h from before 4173df5187 (submodule: introduce extensions.submodulePathConfig, 2026-01-12), which added submodule.<name>.gitdir to the list. Without it, t9902-completion.sh fails. Regenerating the config-list.h artifact from sources fixes the artifact and the test. Teach the meson build to depend on the Documentation files that generate-configlist.sh reads by having it an additional output as a list of dependency files, since Meson does not have (or want) builtin support for globbing like Make. Helped-by: Patrick Steinhardt <ps@pks.im> Signed-off-by: D. Ben Knoble <ben.knoble+github@gmail.com> --- Notes (benknoble/commits): Changes from v2 (<c9ae171eed6bd5b0fa6671b10a5ad0da024f36d0.1770649805.git.ben.knoble+github@gmail.com>): • Pick up (and tweak) Patrick's depfile proposal • Include the script itself as a dependency • Escape output paths (spaces, octothorpes, and backslashes) for Ninja I'm not 100% sure I've actually done the escaping correctly, though, since Ninja's source says that a space preceded by 2N backslashes represents 2N backslashes at the end of a filename, and λ printf '%s\n' 'foo\' | sed 's/[# \\]/\\&/g' | xxd 00000000: 666f 6f5c 5c0a foo\\. So would they interpret that as the filename 'foo\\' instead of 'foo\' ? (Or, no because the 2N slashes aren't followed by a SP, but a NL?) generate-configlist.sh | 10 +++++++++- meson.build | 4 +++- 2 files changed, 12 insertions(+), 2 deletions(-) diff --git a/generate-configlist.sh b/generate-configlist.sh index 75c39ade20..091efd4564 100755 --- a/generate-configlist.sh +++ b/generate-configlist.sh @@ -2,10 +2,11 @@ SOURCE_DIR="$1" OUTPUT="$2" +DEPFILE="$3" if test -z "$SOURCE_DIR" || ! test -d "$SOURCE_DIR" || test -z "$OUTPUT" then - echo >&2 "USAGE: $0 <SOURCE_DIR> <OUTPUT>" + echo >&2 "USAGE: $0 <SOURCE_DIR> <OUTPUT> [<DEPFILE>]" exit 1 fi @@ -36,3 +37,10 @@ print_config_list () { echo print_config_list } >"$OUTPUT" + +if test -n "$DEPFILE" +then + printf "$OUTPUT: %s\n" "$0" "$SOURCE_DIR"/Documentation/*config.adoc \ + "$SOURCE_DIR"/Documentation/config/*.adoc | + sed 's/[# \\]/\\&/g' >"$DEPFILE" +fi diff --git a/meson.build b/meson.build index 3a1d12caa4..fb5d7367f5 100644 --- a/meson.build +++ b/meson.build @@ -720,11 +720,13 @@ endif builtin_sources += custom_target( output: 'config-list.h', + depfile: 'config-list.h.d', command: [ shell, - meson.current_source_dir() + '/generate-configlist.sh', + meson.current_source_dir() / 'generate-configlist.sh', meson.current_source_dir(), '@OUTPUT@', + '@DEPFILE@', ], env: script_environment, ) base-commit: 19a08e0c02faf1c5b4efd1add85598cf8390ff7e prerequisite-patch-id: 364ba1899740b93be5957262d3583348d030e8fa -- 2.52.0.rc0.1058.g68d811a4ee.dirty ^ permalink raw reply related [flat|nested] 46+ messages in thread
* Re: [PATCH v3] meson: regenerate config-list.h when Documentation changes 2026-02-11 23:51 ` [PATCH v3] " D. Ben Knoble @ 2026-02-12 8:06 ` Patrick Steinhardt 2026-02-12 10:29 ` Phillip Wood ` (2 subsequent siblings) 3 siblings, 0 replies; 46+ messages in thread From: Patrick Steinhardt @ 2026-02-12 8:06 UTC (permalink / raw) To: D. Ben Knoble; +Cc: git, Phillip Wood, Junio C Hamano, Evan Martin On Wed, Feb 11, 2026 at 06:51:02PM -0500, D. Ben Knoble wrote: > Notes (benknoble/commits): > Changes from v2 (<c9ae171eed6bd5b0fa6671b10a5ad0da024f36d0.1770649805.git.ben.knoble+github@gmail.com>): > > • Pick up (and tweak) Patrick's depfile proposal > • Include the script itself as a dependency > • Escape output paths (spaces, octothorpes, and backslashes) for Ninja > > I'm not 100% sure I've actually done the escaping correctly, though, > since Ninja's source says that a space preceded by 2N backslashes > represents 2N backslashes at the end of a filename, and I guess you refer to [1], more specifically this quote: Rather than implement all of above, we follow what GCC/Clang produces: Backslashes escape a space or hash sign. When a space is preceded by 2N+1 backslashes, it is represents N backslashes followed by space. When a space is preceded by 2N backslashes, it represents 2N backslashes at the end of a filename. A hash sign is escaped by a single backslash. All other backslashes remain unchanged. > λ printf '%s\n' 'foo\' | sed 's/[# \\]/\\&/g' | xxd > 00000000: 666f 6f5c 5c0a foo\\. > > So would they interpret that as the filename 'foo\\' instead of 'foo\' ? > (Or, no because the 2N slashes aren't followed by a SP, but a NL?) I think it would be interpreted as "foo\\". I would say that we really don't need to go too much into detail here. I very much hope that no sane person would have literal "\ " in their paths. One might wonder about Windows, where backslashes are common. But filenames cannot start with a space there, so this is fine. So I'd say we should only care about quoting ' ' and '#', nothing else. We can still iterate going forward if we see that we're too naive. > generate-configlist.sh | 10 +++++++++- > meson.build | 4 +++- > 2 files changed, 12 insertions(+), 2 deletions(-) > > diff --git a/generate-configlist.sh b/generate-configlist.sh > index 75c39ade20..091efd4564 100755 > --- a/generate-configlist.sh > +++ b/generate-configlist.sh > @@ -36,3 +37,10 @@ print_config_list () { > echo > print_config_list > } >"$OUTPUT" > + > +if test -n "$DEPFILE" > +then > + printf "$OUTPUT: %s\n" "$0" "$SOURCE_DIR"/Documentation/*config.adoc \ I think it's a tiny bit hacky that we output the script itself as a dependency here, and that it would be cleaner to do this via `depend_files` in the target itself. > + "$SOURCE_DIR"/Documentation/config/*.adoc | > + sed 's/[# \\]/\\&/g' >"$DEPFILE" > +fi From the above rules I would think that we should simply ignore backslashes here. As the last rule says, "All other backslashes remain unchanged.". > diff --git a/meson.build b/meson.build > index 3a1d12caa4..fb5d7367f5 100644 > --- a/meson.build > +++ b/meson.build > @@ -720,11 +720,13 @@ endif > > builtin_sources += custom_target( > output: 'config-list.h', > + depfile: 'config-list.h.d', > command: [ > shell, > - meson.current_source_dir() + '/generate-configlist.sh', > + meson.current_source_dir() / 'generate-configlist.sh', > meson.current_source_dir(), > '@OUTPUT@', > + '@DEPFILE@', I didn't know about `@DEPFILE@`, nice. Thanks! Patrick [1]: https://github.com/ninja-build/ninja/blob/cc60300ab94dae9bb28fece3c9b7c397235b17de/src/depfile_parser.in.cc#L27 ^ permalink raw reply [flat|nested] 46+ messages in thread
* Re: [PATCH v3] meson: regenerate config-list.h when Documentation changes 2026-02-11 23:51 ` [PATCH v3] " D. Ben Knoble 2026-02-12 8:06 ` Patrick Steinhardt @ 2026-02-12 10:29 ` Phillip Wood 2026-02-12 14:14 ` Phillip Wood 2026-02-12 15:56 ` Ben Knoble 2026-02-16 22:28 ` [PATCH v4] " D. Ben Knoble 3 siblings, 1 reply; 46+ messages in thread From: Phillip Wood @ 2026-02-12 10:29 UTC (permalink / raw) To: D. Ben Knoble, git Cc: Phillip Wood, Patrick Steinhardt, Junio C Hamano, Evan Martin Hi Ben On 11/02/2026 23:51, D. Ben Knoble wrote: > The Meson-based build doesn't know when to rebuild config-list.h, so the > header is sometimes stale. > > For example, an old build directory might have config-list.h from before > 4173df5187 (submodule: introduce extensions.submodulePathConfig, > 2026-01-12), which added submodule.<name>.gitdir to the list. Without > it, t9902-completion.sh fails. Regenerating the config-list.h artifact > from sources fixes the artifact and the test. > > Teach the meson build to depend on the Documentation files that > generate-configlist.sh reads by having it an additional output as a list > of dependency files, since Meson does not have (or want) builtin support > for globbing like Make. It would be useful to mention that we assume that if a user adds a new file under Documentation/config then they will also edit one of the existing files to include that new file and that will trigger a rebuild. > Helped-by: Patrick Steinhardt <ps@pks.im> > Signed-off-by: D. Ben Knoble <ben.knoble+github@gmail.com> > --- > > Notes (benknoble/commits): > Changes from v2 (<c9ae171eed6bd5b0fa6671b10a5ad0da024f36d0.1770649805.git.ben.knoble+github@gmail.com>): > > • Pick up (and tweak) Patrick's depfile proposal > • Include the script itself as a dependency > • Escape output paths (spaces, octothorpes, and backslashes) for Ninja > > I'm not 100% sure I've actually done the escaping correctly, though, > since Ninja's source says that a space preceded by 2N backslashes > represents 2N backslashes at the end of a filename, and > > λ printf '%s\n' 'foo\' | sed 's/[# \\]/\\&/g' | xxd > 00000000: 666f 6f5c 5c0a foo\\. > > So would they interpret that as the filename 'foo\\' instead of 'foo\' ? > (Or, no because the 2N slashes aren't followed by a SP, but a NL?) Having re-read the ninja source I agree with Patrick that we should not be escaping backslashes > +if test -n "$DEPFILE" > +then > + printf "$OUTPUT: %s\n" "$0" "$SOURCE_DIR"/Documentation/*config.adoc \ > + "$SOURCE_DIR"/Documentation/config/*.adoc | > + sed 's/[# \\]/\\&/g' >"$DEPFILE" This will escape the space after "$OUTPUT:" which is not what we want. printf '%s\n' ... | sed "s/[# ]/\\&/g; s|^|$OUTPUT|" >"$DEPFILE" should work so long as $OUTPUT does not contain any '|' characters. Thanks Phillip > +fi > diff --git a/meson.build b/meson.build > index 3a1d12caa4..fb5d7367f5 100644 > --- a/meson.build > +++ b/meson.build > @@ -720,11 +720,13 @@ endif > > builtin_sources += custom_target( > output: 'config-list.h', > + depfile: 'config-list.h.d', > command: [ > shell, > - meson.current_source_dir() + '/generate-configlist.sh', > + meson.current_source_dir() / 'generate-configlist.sh', > meson.current_source_dir(), > '@OUTPUT@', > + '@DEPFILE@', > ], > env: script_environment, > ) > > base-commit: 19a08e0c02faf1c5b4efd1add85598cf8390ff7e > prerequisite-patch-id: 364ba1899740b93be5957262d3583348d030e8fa ^ permalink raw reply [flat|nested] 46+ messages in thread
* Re: [PATCH v3] meson: regenerate config-list.h when Documentation changes 2026-02-12 10:29 ` Phillip Wood @ 2026-02-12 14:14 ` Phillip Wood 0 siblings, 0 replies; 46+ messages in thread From: Phillip Wood @ 2026-02-12 14:14 UTC (permalink / raw) To: D. Ben Knoble, git Cc: Phillip Wood, Patrick Steinhardt, Junio C Hamano, Evan Martin On 12/02/2026 10:29, Phillip Wood wrote: > > printf '%s\n' ... | sed "s/[# ]/\\&/g; s|^|$OUTPUT|" >"$DEPFILE" Sorry that's missing ": " after $OUTPUT Thanks Phillip ^ permalink raw reply [flat|nested] 46+ messages in thread
* Re: [PATCH v3] meson: regenerate config-list.h when Documentation changes 2026-02-11 23:51 ` [PATCH v3] " D. Ben Knoble 2026-02-12 8:06 ` Patrick Steinhardt 2026-02-12 10:29 ` Phillip Wood @ 2026-02-12 15:56 ` Ben Knoble 2026-02-16 22:28 ` [PATCH v4] " D. Ben Knoble 3 siblings, 0 replies; 46+ messages in thread From: Ben Knoble @ 2026-02-12 15:56 UTC (permalink / raw) To: D. Ben Knoble Cc: git, Phillip Wood, Patrick Steinhardt, Junio C Hamano, Evan Martin Apologies, this has a rather obvious bug: > > Le 11 févr. 2026 à 18:51, D. Ben Knoble <ben.knoble+github@gmail.com> a écrit : > > The Meson-based build doesn't know when to rebuild config-list.h, so the > header is sometimes stale. > > For example, an old build directory might have config-list.h from before > 4173df5187 (submodule: introduce extensions.submodulePathConfig, > 2026-01-12), which added submodule.<name>.gitdir to the list. Without > it, t9902-completion.sh fails. Regenerating the config-list.h artifact > from sources fixes the artifact and the test. > > Teach the meson build to depend on the Documentation files that > generate-configlist.sh reads by having it an additional output as a list > of dependency files, since Meson does not have (or want) builtin support > for globbing like Make. > > Helped-by: Patrick Steinhardt <ps@pks.im> > Signed-off-by: D. Ben Knoble <ben.knoble+github@gmail.com> > --- > > Notes (benknoble/commits): > Changes from v2 (<c9ae171eed6bd5b0fa6671b10a5ad0da024f36d0.1770649805.git.ben.knoble+github@gmail.com>): > > • Pick up (and tweak) Patrick's depfile proposal > • Include the script itself as a dependency > • Escape output paths (spaces, octothorpes, and backslashes) for Ninja > > I'm not 100% sure I've actually done the escaping correctly, though, > since Ninja's source says that a space preceded by 2N backslashes > represents 2N backslashes at the end of a filename, and > > λ printf '%s\n' 'foo\' | sed 's/[# \\]/\\&/g' | xxd > 00000000: 666f 6f5c 5c0a foo\\. > > So would they interpret that as the filename 'foo\\' instead of 'foo\' ? > (Or, no because the 2N slashes aren't followed by a SP, but a NL?) > > generate-configlist.sh | 10 +++++++++- > meson.build | 4 +++- > 2 files changed, 12 insertions(+), 2 deletions(-) > > diff --git a/generate-configlist.sh b/generate-configlist.sh > index 75c39ade20..091efd4564 100755 > --- a/generate-configlist.sh > +++ b/generate-configlist.sh > @@ -2,10 +2,11 @@ > > SOURCE_DIR="$1" > OUTPUT="$2" > +DEPFILE="$3" > > if test -z "$SOURCE_DIR" || ! test -d "$SOURCE_DIR" || test -z "$OUTPUT" > then > - echo >&2 "USAGE: $0 <SOURCE_DIR> <OUTPUT>" > + echo >&2 "USAGE: $0 <SOURCE_DIR> <OUTPUT> [<DEPFILE>]" > exit 1 > fi > > @@ -36,3 +37,10 @@ print_config_list () { > echo > print_config_list > } >"$OUTPUT" > + > +if test -n "$DEPFILE" > +then > + printf "$OUTPUT: %s\n" "$0" "$SOURCE_DIR"/Documentation/*config.adoc \ > + "$SOURCE_DIR"/Documentation/config/*.adoc | > + sed 's/[# \\]/\\&/g' >"$DEPFILE" This also escapes the space after the OUTPUT: prefix. Will try to find a different way. ^ permalink raw reply [flat|nested] 46+ messages in thread
* [PATCH v4] meson: regenerate config-list.h when Documentation changes 2026-02-11 23:51 ` [PATCH v3] " D. Ben Knoble ` (2 preceding siblings ...) 2026-02-12 15:56 ` Ben Knoble @ 2026-02-16 22:28 ` D. Ben Knoble 2026-02-17 0:33 ` Ben Knoble ` (3 more replies) 3 siblings, 4 replies; 46+ messages in thread From: D. Ben Knoble @ 2026-02-16 22:28 UTC (permalink / raw) To: git Cc: D. Ben Knoble, Phillip Wood, Patrick Steinhardt, Evan Martin, Junio C Hamano The Meson-based build doesn't know when to rebuild config-list.h, so the header is sometimes stale. For example, an old build directory might have config-list.h from before 4173df5187 (submodule: introduce extensions.submodulePathConfig, 2026-01-12), which added submodule.<name>.gitdir to the list. Without it, t9902-completion.sh fails. Regenerating the config-list.h artifact from sources fixes the artifact and the test. Teach the meson build to depend on the Documentation files that generate-configlist.sh reads by having it an additional output as a list of dependency files, since Meson does not have (or want) builtin support for globbing like Make. We assume that if a user adds a new file under Documentation/config then they will also edit one of the existing files to include that new file, and that will trigger a rebuild. Also mark the generator script as a dependency. Combining the following commands helps debug dependencies: ninja -C <builddir> -t deps config-list.h ninja -C <builddir> -t browse config-list.h The former lists all the dependencies discovered from our output ".d" file (the config documentation) and the latter shows the dependency on the script itself, among other useful edges in the dependency graph. Helped-by: Patrick Steinhardt <ps@pks.im> Helped-by: Phillip Wood <phillip.wood@dunelm.org.uk> Signed-off-by: D. Ben Knoble <ben.knoble+github@gmail.com> --- Notes (benknoble/commits): Changes from v3 (<0a344f1f3ee4a5d95c6f46df030b9936db4354a1.1770853297.git.ben.knoble+github@gmail.com>): • Include the script itself as a dependency via depfile • Fix output path escaping (spaces, octothorpes; drop backslashes) for Ninja (I've used a loop because I couldn't find a portable construct that could escape only the remainder of the lines in the way I wanted). • Mention our assumptions about Documentation updates triggering rebuilds • Also include some debugging information in the commit message generate-configlist.sh | 12 +++++++++++- meson.build | 5 ++++- 2 files changed, 15 insertions(+), 2 deletions(-) diff --git a/generate-configlist.sh b/generate-configlist.sh index 75c39ade209..63a2e8b6938 100755 --- a/generate-configlist.sh +++ b/generate-configlist.sh @@ -2,10 +2,11 @@ SOURCE_DIR="$1" OUTPUT="$2" +DEPFILE="$3" if test -z "$SOURCE_DIR" || ! test -d "$SOURCE_DIR" || test -z "$OUTPUT" then - echo >&2 "USAGE: $0 <SOURCE_DIR> <OUTPUT>" + echo >&2 "USAGE: $0 <SOURCE_DIR> <OUTPUT> [<DEPFILE>]" exit 1 fi @@ -36,3 +37,12 @@ print_config_list () echo print_config_list } >"$OUTPUT" + +if test -n "$DEPFILE" +then + for doc in "$SOURCE_DIR"/Documentation/*config.adoc \ + "$SOURCE_DIR"/Documentation/config/*.adoc + do + printf "$OUTPUT: %s\n" "$(printf '%s\n' "$doc" | sed 's/[# ]/\\&/g')" + done >"$DEPFILE" +fi diff --git a/meson.build b/meson.build index 3a1d12caa4b..e4b8f1e33d2 100644 --- a/meson.build +++ b/meson.build @@ -720,11 +720,14 @@ endif builtin_sources += custom_target( output: 'config-list.h', + depfile: 'config-list.h.d', + depend_files: [ 'generate-configlist.sh' ], command: [ shell, - meson.current_source_dir() + '/generate-configlist.sh', + meson.current_source_dir() / 'generate-configlist.sh', meson.current_source_dir(), '@OUTPUT@', + '@DEPFILE@', ], env: script_environment, ) Diff-intervalle contre v3 : 1: 0a344f1f3ee ! 1: 9cdcc9de04f meson: regenerate config-list.h when Documentation changes @@ Commit message Teach the meson build to depend on the Documentation files that generate-configlist.sh reads by having it an additional output as a list of dependency files, since Meson does not have (or want) builtin support - for globbing like Make. + for globbing like Make. We assume that if a user adds a new file under + Documentation/config then they will also edit one of the existing files + to include that new file, and that will trigger a rebuild. + + Also mark the generator script as a dependency. + + Combining the following commands helps debug dependencies: + + ninja -C <builddir> -t deps config-list.h + ninja -C <builddir> -t browse config-list.h + + The former lists all the dependencies discovered from our output ".d" + file (the config documentation) and the latter shows the dependency on + the script itself, among other useful edges in the dependency graph. Helped-by: Patrick Steinhardt <ps@pks.im> + Helped-by: Phillip Wood <phillip.wood@dunelm.org.uk> ## Notes (benknoble/commits) ## - Changes from v2 (<c9ae171eed6bd5b0fa6671b10a5ad0da024f36d0.1770649805.git.ben.knoble+github@gmail.com>): + Changes from v3 (<0a344f1f3ee4a5d95c6f46df030b9936db4354a1.1770853297.git.ben.knoble+github@gmail.com>): - • Pick up (and tweak) Patrick's depfile proposal - • Include the script itself as a dependency - • Escape output paths (spaces, octothorpes, and backslashes) for Ninja - - I'm not 100% sure I've actually done the escaping correctly, though, - since Ninja's source says that a space preceded by 2N backslashes - represents 2N backslashes at the end of a filename, and - - λ printf '%s\n' 'foo\' | sed 's/[# \\]/\\&/g' | xxd - 00000000: 666f 6f5c 5c0a foo\\. - - So would they interpret that as the filename 'foo\\' instead of 'foo\' ? - (Or, no because the 2N slashes aren't followed by a SP, but a NL?) + • Include the script itself as a dependency via depfile + • Fix output path escaping (spaces, octothorpes; drop backslashes) for + Ninja (I've used a loop because I couldn't find a portable construct + that could escape only the remainder of the lines in the way I + wanted). + • Mention our assumptions about Documentation updates triggering + rebuilds + • Also include some debugging information in the commit message ## generate-configlist.sh ## @@ @@ generate-configlist.sh: print_config_list () + +if test -n "$DEPFILE" +then -+ printf "$OUTPUT: %s\n" "$0" "$SOURCE_DIR"/Documentation/*config.adoc \ -+ "$SOURCE_DIR"/Documentation/config/*.adoc | -+ sed 's/[# \\]/\\&/g' >"$DEPFILE" ++ for doc in "$SOURCE_DIR"/Documentation/*config.adoc \ ++ "$SOURCE_DIR"/Documentation/config/*.adoc ++ do ++ printf "$OUTPUT: %s\n" "$(printf '%s\n' "$doc" | sed 's/[# ]/\\&/g')" ++ done >"$DEPFILE" +fi ## meson.build ## @@ meson.build: endif builtin_sources += custom_target( output: 'config-list.h', + depfile: 'config-list.h.d', ++ depend_files: [ 'generate-configlist.sh' ], command: [ shell, - meson.current_source_dir() + '/generate-configlist.sh', base-commit: 19a08e0c02faf1c5b4efd1add85598cf8390ff7e prerequisite-patch-id: 364ba1899740b93be5957262d3583348d030e8fa -- 2.48.1 ^ permalink raw reply related [flat|nested] 46+ messages in thread
* Re: [PATCH v4] meson: regenerate config-list.h when Documentation changes 2026-02-16 22:28 ` [PATCH v4] " D. Ben Knoble @ 2026-02-17 0:33 ` Ben Knoble 2026-02-17 7:03 ` Patrick Steinhardt 2026-02-17 7:02 ` Patrick Steinhardt ` (2 subsequent siblings) 3 siblings, 1 reply; 46+ messages in thread From: Ben Knoble @ 2026-02-17 0:33 UTC (permalink / raw) To: D. Ben Knoble Cc: git, Phillip Wood, Patrick Steinhardt, Evan Martin, Junio C Hamano > Le 16 févr. 2026 à 17:29, D. Ben Knoble <ben.knoble+github@gmail.com> a écrit : > > The Meson-based build doesn't know when to rebuild config-list.h, so the > header is sometimes stale. > > For example, an old build directory might have config-list.h from before > 4173df5187 (submodule: introduce extensions.submodulePathConfig, > 2026-01-12), which added submodule.<name>.gitdir to the list. Without > it, t9902-completion.sh fails. Regenerating the config-list.h artifact > from sources fixes the artifact and the test. > > Teach the meson build to depend on the Documentation files that > generate-configlist.sh reads by having it an additional output as a list > of dependency files, since Meson does not have (or want) builtin support > for globbing like Make. We assume that if a user adds a new file under > Documentation/config then they will also edit one of the existing files > to include that new file, and that will trigger a rebuild. > > Also mark the generator script as a dependency. > > Combining the following commands helps debug dependencies: > > ninja -C <builddir> -t deps config-list.h > ninja -C <builddir> -t browse config-list.h > > The former lists all the dependencies discovered from our output ".d" > file (the config documentation) and the latter shows the dependency on > the script itself, among other useful edges in the dependency graph. > > Helped-by: Patrick Steinhardt <ps@pks.im> > Helped-by: Phillip Wood <phillip.wood@dunelm.org.uk> > Signed-off-by: D. Ben Knoble <ben.knoble+github@gmail.com> > --- > > Notes (benknoble/commits): > Changes from v3 (<0a344f1f3ee4a5d95c6f46df030b9936db4354a1.1770853297.git.ben.knoble+github@gmail.com>): > > • Include the script itself as a dependency via depfile > • Fix output path escaping (spaces, octothorpes; drop backslashes) for > Ninja (I've used a loop because I couldn't find a portable construct > that could escape only the remainder of the lines in the way I > wanted). > • Mention our assumptions about Documentation updates triggering > rebuilds > • Also include some debugging information in the commit message > > generate-configlist.sh | 12 +++++++++++- > meson.build | 5 ++++- > 2 files changed, 15 insertions(+), 2 deletions(-) > > diff --git a/generate-configlist.sh b/generate-configlist.sh > index 75c39ade209..63a2e8b6938 100755 > --- a/generate-configlist.sh > +++ b/generate-configlist.sh > @@ -2,10 +2,11 @@ > > SOURCE_DIR="$1" > OUTPUT="$2" > +DEPFILE="$3" > > if test -z "$SOURCE_DIR" || ! test -d "$SOURCE_DIR" || test -z "$OUTPUT" > then > - echo >&2 "USAGE: $0 <SOURCE_DIR> <OUTPUT>" > + echo >&2 "USAGE: $0 <SOURCE_DIR> <OUTPUT> [<DEPFILE>]" > exit 1 > fi > > @@ -36,3 +37,12 @@ print_config_list () > echo > print_config_list > } >"$OUTPUT" > + > +if test -n "$DEPFILE" > +then > + for doc in "$SOURCE_DIR"/Documentation/*config.adoc \ > + "$SOURCE_DIR"/Documentation/config/*.adoc > + do > + printf "$OUTPUT: %s\n" "$(printf '%s\n' "$doc" | sed 's/[# ]/\\&/g')" > + done >"$DEPFILE" > +fi > diff --git a/meson.build b/meson.build > index 3a1d12caa4b..e4b8f1e33d2 100644 > --- a/meson.build > +++ b/meson.build > @@ -720,11 +720,14 @@ endif > > builtin_sources += custom_target( > output: 'config-list.h', > + depfile: 'config-list.h.d', > + depend_files: [ 'generate-configlist.sh' ], > command: [ > shell, > - meson.current_source_dir() + '/generate-configlist.sh', > + meson.current_source_dir() / 'generate-configlist.sh', > meson.current_source_dir(), > '@OUTPUT@', > + '@DEPFILE@', > ], > env: script_environment, > ) > > Diff-intervalle contre v3 : > 1: 0a344f1f3ee ! 1: 9cdcc9de04f meson: regenerate config-list.h when Documentation changes > @@ Commit message > Teach the meson build to depend on the Documentation files that > generate-configlist.sh reads by having it an additional output as a list > of dependency files, since Meson does not have (or want) builtin support > - for globbing like Make. > + for globbing like Make. We assume that if a user adds a new file under > + Documentation/config then they will also edit one of the existing files > + to include that new file, and that will trigger a rebuild. > + > + Also mark the generator script as a dependency. > + > + Combining the following commands helps debug dependencies: > + > + ninja -C <builddir> -t deps config-list.h > + ninja -C <builddir> -t browse config-list.h > + > + The former lists all the dependencies discovered from our output ".d" > + file (the config documentation) and the latter shows the dependency on > + the script itself, among other useful edges in the dependency graph. > > Helped-by: Patrick Steinhardt <ps@pks.im> > + Helped-by: Phillip Wood <phillip.wood@dunelm.org.uk> > > > ## Notes (benknoble/commits) ## > - Changes from v2 (<c9ae171eed6bd5b0fa6671b10a5ad0da024f36d0.1770649805.git.ben.knoble+github@gmail.com>): > + Changes from v3 (<0a344f1f3ee4a5d95c6f46df030b9936db4354a1.1770853297.git.ben.knoble+github@gmail.com>): > > - • Pick up (and tweak) Patrick's depfile proposal > - • Include the script itself as a dependency > - • Escape output paths (spaces, octothorpes, and backslashes) for Ninja > - > - I'm not 100% sure I've actually done the escaping correctly, though, > - since Ninja's source says that a space preceded by 2N backslashes > - represents 2N backslashes at the end of a filename, and > - > - λ printf '%s\n' 'foo\' | sed 's/[# \\]/\\&/g' | xxd > - 00000000: 666f 6f5c 5c0a foo\\. > - > - So would they interpret that as the filename 'foo\\' instead of 'foo\' ? > - (Or, no because the 2N slashes aren't followed by a SP, but a NL?) > + • Include the script itself as a dependency via depfile > + • Fix output path escaping (spaces, octothorpes; drop backslashes) for > + Ninja (I've used a loop because I couldn't find a portable construct > + that could escape only the remainder of the lines in the way I > + wanted). > + • Mention our assumptions about Documentation updates triggering > + rebuilds > + • Also include some debugging information in the commit message > > ## generate-configlist.sh ## > @@ > @@ generate-configlist.sh: print_config_list () > + > +if test -n "$DEPFILE" > +then > -+ printf "$OUTPUT: %s\n" "$0" "$SOURCE_DIR"/Documentation/*config.adoc \ > -+ "$SOURCE_DIR"/Documentation/config/*.adoc | > -+ sed 's/[# \\]/\\&/g' >"$DEPFILE" > ++ for doc in "$SOURCE_DIR"/Documentation/*config.adoc \ > ++ "$SOURCE_DIR"/Documentation/config/*.adoc > ++ do > ++ printf "$OUTPUT: %s\n" "$(printf '%s\n' "$doc" | sed 's/[# ]/\\&/g')" > ++ done >"$DEPFILE" > +fi > > ## meson.build ## > @@ meson.build: endif > builtin_sources += custom_target( > output: 'config-list.h', > + depfile: 'config-list.h.d', > ++ depend_files: [ 'generate-configlist.sh' ], > command: [ > shell, > - meson.current_source_dir() + '/generate-configlist.sh', > > base-commit: 19a08e0c02faf1c5b4efd1add85598cf8390ff7e > prerequisite-patch-id: 364ba1899740b93be5957262d3583348d030e8fa > -- > 2.48.1 Hmm. I’m pretty sure this worked locally but I’m seeing some CI failures on GitHub. Will investigate. ^ permalink raw reply [flat|nested] 46+ messages in thread
* Re: [PATCH v4] meson: regenerate config-list.h when Documentation changes 2026-02-17 0:33 ` Ben Knoble @ 2026-02-17 7:03 ` Patrick Steinhardt 2026-02-17 13:28 ` D. Ben Knoble 0 siblings, 1 reply; 46+ messages in thread From: Patrick Steinhardt @ 2026-02-17 7:03 UTC (permalink / raw) To: Ben Knoble; +Cc: D. Ben Knoble, git, Phillip Wood, Evan Martin, Junio C Hamano On Mon, Feb 16, 2026 at 07:33:19PM -0500, Ben Knoble wrote: > Hmm. I’m pretty sure this worked locally but I’m seeing some CI > failures on GitHub. Will investigate. Where did you see the failures? The changes look good to me, and things work as expected on my machine, so I'm wondering what the root cause is. A test run at [1] in GitLab's CI is also successful (ignore the MSVC+Meson failures, a fix for these is being reviewed on the mailing list already). Patrick [1]: https://gitlab.com/gitlab-org/git/-/merge_requests/505 ^ permalink raw reply [flat|nested] 46+ messages in thread
* Re: [PATCH v4] meson: regenerate config-list.h when Documentation changes 2026-02-17 7:03 ` Patrick Steinhardt @ 2026-02-17 13:28 ` D. Ben Knoble 0 siblings, 0 replies; 46+ messages in thread From: D. Ben Knoble @ 2026-02-17 13:28 UTC (permalink / raw) To: Patrick Steinhardt; +Cc: git, Phillip Wood, Evan Martin, Junio C Hamano On Tue, Feb 17, 2026 at 2:03 AM Patrick Steinhardt <ps@pks.im> wrote: > > On Mon, Feb 16, 2026 at 07:33:19PM -0500, Ben Knoble wrote: > > Hmm. I’m pretty sure this worked locally but I’m seeing some CI > > failures on GitHub. Will investigate. > > Where did you see the failures? The changes look good to me, and things > work as expected on my machine, so I'm wondering what the root cause is. > A test run at [1] in GitLab's CI is also successful (ignore the > MSVC+Meson failures, a fix for these is being reviewed on the mailing > list already). > > Patrick > > [1]: https://gitlab.com/gitlab-org/git/-/merge_requests/505 I must have misread my mobile notifications; I _thought_ [1] was failing, but it must have been a different branch I accidentally pushed to GitHub :) CI for this branch succeeded. [1]: https://github.com/benknoble/git/actions/runs/22081407078 -- D. Ben Knoble ^ permalink raw reply [flat|nested] 46+ messages in thread
* Re: [PATCH v4] meson: regenerate config-list.h when Documentation changes 2026-02-16 22:28 ` [PATCH v4] " D. Ben Knoble 2026-02-17 0:33 ` Ben Knoble @ 2026-02-17 7:02 ` Patrick Steinhardt 2026-02-17 13:28 ` D. Ben Knoble 2026-02-17 9:20 ` Phillip Wood 2026-02-18 14:37 ` [PATCH v5] build: " D. Ben Knoble 3 siblings, 1 reply; 46+ messages in thread From: Patrick Steinhardt @ 2026-02-17 7:02 UTC (permalink / raw) To: D. Ben Knoble; +Cc: git, Phillip Wood, Evan Martin, Junio C Hamano On Mon, Feb 16, 2026 at 05:28:57PM -0500, D. Ben Knoble wrote: > The Meson-based build doesn't know when to rebuild config-list.h, so the > header is sometimes stale. > > For example, an old build directory might have config-list.h from before > 4173df5187 (submodule: introduce extensions.submodulePathConfig, > 2026-01-12), which added submodule.<name>.gitdir to the list. Without > it, t9902-completion.sh fails. Regenerating the config-list.h artifact > from sources fixes the artifact and the test. > > Teach the meson build to depend on the Documentation files that > generate-configlist.sh reads by having it an additional output as a list > of dependency files, since Meson does not have (or want) builtin support > for globbing like Make. We assume that if a user adds a new file under > Documentation/config then they will also edit one of the existing files > to include that new file, and that will trigger a rebuild. > > Also mark the generator script as a dependency. > > Combining the following commands helps debug dependencies: > > ninja -C <builddir> -t deps config-list.h > ninja -C <builddir> -t browse config-list.h > > The former lists all the dependencies discovered from our output ".d" > file (the config documentation) and the latter shows the dependency on > the script itself, among other useful edges in the dependency graph. Good hint, thanks for putting it here. > diff --git a/generate-configlist.sh b/generate-configlist.sh > index 75c39ade209..63a2e8b6938 100755 > --- a/generate-configlist.sh > +++ b/generate-configlist.sh > @@ -36,3 +37,12 @@ print_config_list () > echo > print_config_list > } >"$OUTPUT" > + > +if test -n "$DEPFILE" > +then > + for doc in "$SOURCE_DIR"/Documentation/*config.adoc \ > + "$SOURCE_DIR"/Documentation/config/*.adoc > + do > + printf "$OUTPUT: %s\n" "$(printf '%s\n' "$doc" | sed 's/[# ]/\\&/g')" Tiny nit: can't we simplify this to "$(echo "$doc" | sed ...)"? > diff --git a/meson.build b/meson.build > index 3a1d12caa4b..e4b8f1e33d2 100644 > --- a/meson.build > +++ b/meson.build > @@ -720,11 +720,14 @@ endif > > builtin_sources += custom_target( > output: 'config-list.h', > + depfile: 'config-list.h.d', > + depend_files: [ 'generate-configlist.sh' ], > command: [ > shell, > - meson.current_source_dir() + '/generate-configlist.sh', > + meson.current_source_dir() / 'generate-configlist.sh', > meson.current_source_dir(), > '@OUTPUT@', > + '@DEPFILE@', > ], > env: script_environment, > ) And this looks as expected now, too. I also verified locally that this correctly rebuilds things when either the script or any of the files change. I wonder whether we also want to have a second patch on top to adjust our Makefile? E.g. something like this: diff --git a/Makefile b/Makefile index 47ed9fa7fd..ed82775ec2 100644 --- a/Makefile +++ b/Makefile @@ -2688,8 +2688,10 @@ $(BUILT_INS): git$X config-list.h: generate-configlist.sh -config-list.h: Documentation/*config.adoc Documentation/config/*.adoc - $(QUIET_GEN)$(SHELL_PATH) ./generate-configlist.sh . $@ +config-list.h: generate-configlist.sh + $(QUIET_GEN)$(SHELL_PATH) ./generate-configlist.sh . $@ .depend/config-list.h.d + +-include .depend/config-list.h.d command-list.h: generate-cmdlist.sh command-list.txt Please feel free to skip this part though. Thanks! Patrick ^ permalink raw reply related [flat|nested] 46+ messages in thread
* Re: [PATCH v4] meson: regenerate config-list.h when Documentation changes 2026-02-17 7:02 ` Patrick Steinhardt @ 2026-02-17 13:28 ` D. Ben Knoble 2026-02-17 20:24 ` Junio C Hamano 0 siblings, 1 reply; 46+ messages in thread From: D. Ben Knoble @ 2026-02-17 13:28 UTC (permalink / raw) To: Patrick Steinhardt; +Cc: git, Phillip Wood, Evan Martin, Junio C Hamano On Tue, Feb 17, 2026 at 2:02 AM Patrick Steinhardt <ps@pks.im> wrote: > > On Mon, Feb 16, 2026 at 05:28:57PM -0500, D. Ben Knoble wrote: > > The Meson-based build doesn't know when to rebuild config-list.h, so the > > header is sometimes stale. > > > > For example, an old build directory might have config-list.h from before > > 4173df5187 (submodule: introduce extensions.submodulePathConfig, > > 2026-01-12), which added submodule.<name>.gitdir to the list. Without > > it, t9902-completion.sh fails. Regenerating the config-list.h artifact > > from sources fixes the artifact and the test. > > > > Teach the meson build to depend on the Documentation files that > > generate-configlist.sh reads by having it an additional output as a list > > of dependency files, since Meson does not have (or want) builtin support > > for globbing like Make. We assume that if a user adds a new file under > > Documentation/config then they will also edit one of the existing files > > to include that new file, and that will trigger a rebuild. > > > > Also mark the generator script as a dependency. > > > > Combining the following commands helps debug dependencies: > > > > ninja -C <builddir> -t deps config-list.h > > ninja -C <builddir> -t browse config-list.h > > > > The former lists all the dependencies discovered from our output ".d" > > file (the config documentation) and the latter shows the dependency on > > the script itself, among other useful edges in the dependency graph. > > Good hint, thanks for putting it here. > > > diff --git a/generate-configlist.sh b/generate-configlist.sh > > index 75c39ade209..63a2e8b6938 100755 > > --- a/generate-configlist.sh > > +++ b/generate-configlist.sh > > @@ -36,3 +37,12 @@ print_config_list () > > echo > > print_config_list > > } >"$OUTPUT" > > + > > +if test -n "$DEPFILE" > > +then > > + for doc in "$SOURCE_DIR"/Documentation/*config.adoc \ > > + "$SOURCE_DIR"/Documentation/config/*.adoc > > + do > > + printf "$OUTPUT: %s\n" "$(printf '%s\n' "$doc" | sed 's/[# ]/\\&/g')" > > Tiny nit: can't we simplify this to "$(echo "$doc" | sed ...)"? Given how unportable echo is [1], I'd prefer to keep printf. [1]: https://github.com/benknoble/echocho, for one. If the doc started with "-e" for example the results might be unreliable. > > diff --git a/meson.build b/meson.build > > index 3a1d12caa4b..e4b8f1e33d2 100644 > > --- a/meson.build > > +++ b/meson.build > > @@ -720,11 +720,14 @@ endif > > > > builtin_sources += custom_target( > > output: 'config-list.h', > > + depfile: 'config-list.h.d', > > + depend_files: [ 'generate-configlist.sh' ], > > command: [ > > shell, > > - meson.current_source_dir() + '/generate-configlist.sh', > > + meson.current_source_dir() / 'generate-configlist.sh', > > meson.current_source_dir(), > > '@OUTPUT@', > > + '@DEPFILE@', > > ], > > env: script_environment, > > ) > > And this looks as expected now, too. I also verified locally that this > correctly rebuilds things when either the script or any of the files > change. > > I wonder whether we also want to have a second patch on top to adjust > our Makefile? E.g. something like this: > > diff --git a/Makefile b/Makefile > index 47ed9fa7fd..ed82775ec2 100644 > --- a/Makefile > +++ b/Makefile > @@ -2688,8 +2688,10 @@ $(BUILT_INS): git$X > > config-list.h: generate-configlist.sh > > -config-list.h: Documentation/*config.adoc Documentation/config/*.adoc > - $(QUIET_GEN)$(SHELL_PATH) ./generate-configlist.sh . $@ > +config-list.h: generate-configlist.sh > + $(QUIET_GEN)$(SHELL_PATH) ./generate-configlist.sh . $@ .depend/config-list.h.d > + > +-include .depend/config-list.h.d > > command-list.h: generate-cmdlist.sh command-list.txt > > > Please feel free to skip this part though. > > Thanks! > > Patrick That seems reasonable. I'll add to the next version. ^ permalink raw reply [flat|nested] 46+ messages in thread
* Re: [PATCH v4] meson: regenerate config-list.h when Documentation changes 2026-02-17 13:28 ` D. Ben Knoble @ 2026-02-17 20:24 ` Junio C Hamano 0 siblings, 0 replies; 46+ messages in thread From: Junio C Hamano @ 2026-02-17 20:24 UTC (permalink / raw) To: D. Ben Knoble; +Cc: Patrick Steinhardt, git, Phillip Wood, Evan Martin "D. Ben Knoble" <ben.knoble+github@gmail.com> writes: >> > + for doc in "$SOURCE_DIR"/Documentation/*config.adoc \ >> > + "$SOURCE_DIR"/Documentation/config/*.adoc >> > + do >> > + printf "$OUTPUT: %s\n" "$(printf '%s\n' "$doc" | sed 's/[# ]/\\&/g')" >> >> Tiny nit: can't we simplify this to "$(echo "$doc" | sed ...)"? > > Given how unportable echo is [1], I'd prefer to keep printf. > > [1]: https://github.com/benknoble/echocho, for one. If the doc started > with "-e" for example the results might be unreliable. To cause trouble, wouldn't it be necessary for "$doc" to be exactly "-e", not "started with"? And when does $SOURCE_DIR begin with "-e" anyway? It sounds more or less academic irrelevancy. Whatn I am more curious about is the "#"s and spaces being the only bytes that needs quoting. As SOURCE_DIR pretty much under end-user's control (otherwise you wouldn't be worried about it starting with -e), wouldn't we have other problematic bytes we need to worry about? ^ permalink raw reply [flat|nested] 46+ messages in thread
* Re: [PATCH v4] meson: regenerate config-list.h when Documentation changes 2026-02-16 22:28 ` [PATCH v4] " D. Ben Knoble 2026-02-17 0:33 ` Ben Knoble 2026-02-17 7:02 ` Patrick Steinhardt @ 2026-02-17 9:20 ` Phillip Wood 2026-02-17 13:38 ` D. Ben Knoble 2026-02-18 14:37 ` [PATCH v5] build: " D. Ben Knoble 3 siblings, 1 reply; 46+ messages in thread From: Phillip Wood @ 2026-02-17 9:20 UTC (permalink / raw) To: D. Ben Knoble, git Cc: Phillip Wood, Patrick Steinhardt, Evan Martin, Junio C Hamano On 16/02/2026 22:28, D. Ben Knoble wrote: > The Meson-based build doesn't know when to rebuild config-list.h, so the > header is sometimes stale. > > For example, an old build directory might have config-list.h from before > 4173df5187 (submodule: introduce extensions.submodulePathConfig, > 2026-01-12), which added submodule.<name>.gitdir to the list. Without > it, t9902-completion.sh fails. Regenerating the config-list.h artifact > from sources fixes the artifact and the test. > > Teach the meson build to depend on the Documentation files that > generate-configlist.sh reads by having it an additional output as a list > of dependency files, since Meson does not have (or want) builtin support > for globbing like Make. We assume that if a user adds a new file under > Documentation/config then they will also edit one of the existing files > to include that new file, and that will trigger a rebuild. > > Also mark the generator script as a dependency. > > Combining the following commands helps debug dependencies: > > ninja -C <builddir> -t deps config-list.h > ninja -C <builddir> -t browse config-list.h > > The former lists all the dependencies discovered from our output ".d" > file (the config documentation) and the latter shows the dependency on > the script itself, among other useful edges in the dependency graph. > > Helped-by: Patrick Steinhardt <ps@pks.im> > Helped-by: Phillip Wood <phillip.wood@dunelm.org.uk> > Signed-off-by: D. Ben Knoble <ben.knoble+github@gmail.com> Thanks for the nicely written commit message. > +if test -n "$DEPFILE" > +then > + for doc in "$SOURCE_DIR"/Documentation/*config.adoc \ > + "$SOURCE_DIR"/Documentation/config/*.adoc > + do > + printf "$OUTPUT: %s\n" "$(printf '%s\n' "$doc" | sed 's/[# ]/\\&/g')"\\ This forks two processes for every file which is a bit inefficient and will be especially slow on windows. If we quote $OUTPUT first we should be able to use a single sed process for all the files QUOTED_OUTPUT="$(printf '%s\n' "$OUTPUT"| sed 's|[/\]|\\&|g')" printf '%s\n' "$SOURCE_DIR"/Documentation/*config.adoc \ "$SOURCE_DIR"/Documentation/config/*.adoc | sed -e 's/[# ]/\\&/g' -e "s/^/$QUOTED_OUTPUT: /" >"$DEPFILE" Thanks Phillip ^ permalink raw reply [flat|nested] 46+ messages in thread
* Re: [PATCH v4] meson: regenerate config-list.h when Documentation changes 2026-02-17 9:20 ` Phillip Wood @ 2026-02-17 13:38 ` D. Ben Knoble 2026-02-17 15:11 ` Phillip Wood 0 siblings, 1 reply; 46+ messages in thread From: D. Ben Knoble @ 2026-02-17 13:38 UTC (permalink / raw) To: phillip.wood; +Cc: git, Patrick Steinhardt, Evan Martin, Junio C Hamano On Tue, Feb 17, 2026 at 4:20 AM Phillip Wood <phillip.wood123@gmail.com> wrote: > On 16/02/2026 22:28, D. Ben Knoble wrote: > > +if test -n "$DEPFILE" > > +then > > + for doc in "$SOURCE_DIR"/Documentation/*config.adoc \ > > + "$SOURCE_DIR"/Documentation/config/*.adoc > > + do > > + printf "$OUTPUT: %s\n" "$(printf '%s\n' "$doc" | sed 's/[# ]/\\&/g')"\\ > > This forks two processes for every file which is a bit inefficient and > will be especially slow on windows. Yeah. I couldn't find a way I trusted to behave in the presence of strange characters, though… > If we quote $OUTPUT first we should > be able to use a single sed process for all the files > > QUOTED_OUTPUT="$(printf '%s\n' "$OUTPUT"| sed 's|[/\]|\\&|g')" > printf '%s\n' "$SOURCE_DIR"/Documentation/*config.adoc \ > "$SOURCE_DIR"/Documentation/config/*.adoc | > sed -e 's/[# ]/\\&/g' -e "s/^/$QUOTED_OUTPUT: /" >"$DEPFILE" …and this version matches a concept I considered. Let me think aloud. To quote output, we backslash-escape any "/" and "\"; we are going to use it in the replacement side of sed's substitute command with "/" delimiters. My manual says "&" and "\[0-9]" are also special in the replacement string. We have no backreferences for the latter, but my sed on macOS complains about bad backreferences in cases like echo abc | sed 's/^/foo\1/' OTOH, escaping backslashes already covers such backreferences. So I think we'd need something closer to sed 's,[&/\],\\&,g' ? If you agree with that reasoning, I'll include this in the next version. (I'll also try this out a bit first.) PS in patterns with so many "vertical" characters, I find the commas a bit easier to read than pipes :) ^ permalink raw reply [flat|nested] 46+ messages in thread
* Re: [PATCH v4] meson: regenerate config-list.h when Documentation changes 2026-02-17 13:38 ` D. Ben Knoble @ 2026-02-17 15:11 ` Phillip Wood 0 siblings, 0 replies; 46+ messages in thread From: Phillip Wood @ 2026-02-17 15:11 UTC (permalink / raw) To: D. Ben Knoble, phillip.wood Cc: git, Patrick Steinhardt, Evan Martin, Junio C Hamano On 17/02/2026 13:38, D. Ben Knoble wrote: > On Tue, Feb 17, 2026 at 4:20 AM Phillip Wood <phillip.wood123@gmail.com> wrote: >> On 16/02/2026 22:28, D. Ben Knoble wrote: >>> +if test -n "$DEPFILE" >>> +then >>> + for doc in "$SOURCE_DIR"/Documentation/*config.adoc \ >>> + "$SOURCE_DIR"/Documentation/config/*.adoc >>> + do >>> + printf "$OUTPUT: %s\n" "$(printf '%s\n' "$doc" | sed 's/[# ]/\\&/g')"\\ >> >> This forks two processes for every file which is a bit inefficient and >> will be especially slow on windows. > > Yeah. I couldn't find a way I trusted to behave in the presence of > strange characters, though… > >> If we quote $OUTPUT first we should >> be able to use a single sed process for all the files >> >> QUOTED_OUTPUT="$(printf '%s\n' "$OUTPUT"| sed 's|[/\]|\\&|g')" >> printf '%s\n' "$SOURCE_DIR"/Documentation/*config.adoc \ >> "$SOURCE_DIR"/Documentation/config/*.adoc | >> sed -e 's/[# ]/\\&/g' -e "s/^/$QUOTED_OUTPUT: /" >"$DEPFILE" > > …and this version matches a concept I considered. Let me think aloud. > > To quote output, we backslash-escape any "/" and "\"; we are going to > use it in the replacement side of sed's substitute command with "/" > delimiters. > > My manual says "&" and "\[0-9]" are also special in the replacement > string. Oh, I should have remembered '&' needed escaping as well We have no backreferences for the latter, but my sed on macOS > complains about bad backreferences in cases like > > echo abc | sed 's/^/foo\1/' > > OTOH, escaping backslashes already covers such backreferences. So I > think we'd need something closer to > > sed 's,[&/\],\\&,g' > > ? If you agree with that reasoning, I'll include this in the next > version. (I'll also try this out a bit first.) That looks good to me > PS in patterns with so many "vertical" characters, I find the commas a > bit easier to read than pipes :) Yes, that does make it clearer Thanks Phillip ^ permalink raw reply [flat|nested] 46+ messages in thread
* [PATCH v5] build: regenerate config-list.h when Documentation changes 2026-02-16 22:28 ` [PATCH v4] " D. Ben Knoble ` (2 preceding siblings ...) 2026-02-17 9:20 ` Phillip Wood @ 2026-02-18 14:37 ` D. Ben Knoble 2026-02-19 10:19 ` Phillip Wood ` (3 more replies) 3 siblings, 4 replies; 46+ messages in thread From: D. Ben Knoble @ 2026-02-18 14:37 UTC (permalink / raw) To: git Cc: D. Ben Knoble, Phillip Wood, Patrick Steinhardt, Junio C Hamano, brian m. carlson, Evan Martin The Meson-based build doesn't know when to rebuild config-list.h, so the header is sometimes stale. For example, an old build directory might have config-list.h from before 4173df5187 (submodule: introduce extensions.submodulePathConfig, 2026-01-12), which added submodule.<name>.gitdir to the list. Without it, t9902-completion.sh fails. Regenerating the config-list.h artifact from sources fixes the artifact and the test. Teach the meson build to depend on the Documentation files that generate-configlist.sh reads by having it an additional output as a list of dependency files, since Meson does not have (or want) builtin support for globbing like Make. We assume that if a user adds a new file under Documentation/config then they will also edit one of the existing files to include that new file, and that will trigger a rebuild. Also mark the generator script as a dependency. While we're at it, teach the Makefile to use the same "the script knows it's dependencies" logic. For Meson, combining the following commands helps debug dependencies: ninja -C <builddir> -t deps config-list.h ninja -C <builddir> -t browse config-list.h The former lists all the dependencies discovered from our output ".d" file (the config documentation) and the latter shows the dependency on the script itself, among other useful edges in the dependency graph. Helped-by: Patrick Steinhardt <ps@pks.im> Helped-by: Phillip Wood <phillip.wood@dunelm.org.uk> Signed-off-by: D. Ben Knoble <ben.knoble+github@gmail.com> --- Notes (benknoble/commits): Changes from v4 (<9cdcc9de04f0f8fff657f0474b31c063466ed808.1771280837.git.ben.knoble+github@gmail.com>): • Include Patrick's suggested Makefile changes. Note there's no quiet equivalent for mdkir that isn't for the current target's containing directory… • Make depfile output efficient again, thanks to Phillip. I've kept printf instead of echo (from Patrick/Junio) because I think it is easier to reason about ("it works" vs. "did I use this in a way that might cause problems"). Junio asked about other problematic bytes: the other one I could think of (since all the inputs should be paths, anyway) is newlines. I gave meson's depfile.py a glance [1], and it looks like they don't handle newlines in paths. Other whitespace doesn't appear to be an issue (see "elif c in {' ', '\n'}"); I think _most_ characters are just added to the filename. [1]: https://github.com/mesonbuild/meson/blob/master/mesonbuild/depfile.py Makefile | 5 +++-- generate-configlist.sh | 11 ++++++++++- meson.build | 5 ++++- 3 files changed, 17 insertions(+), 4 deletions(-) diff --git a/Makefile b/Makefile index 7f37ad8f58..6f926ffb1f 100644 --- a/Makefile +++ b/Makefile @@ -2688,9 +2688,10 @@ $(BUILT_INS): git$X cp $< $@ config-list.h: generate-configlist.sh + @mkdir -p .depend + $(QUIET_GEN)$(SHELL_PATH) ./generate-configlist.sh . $@ .depend/config-list.h.d -config-list.h: Documentation/*config.adoc Documentation/config/*.adoc - $(QUIET_GEN)$(SHELL_PATH) ./generate-configlist.sh . $@ +-include .depend/config-list.h.d command-list.h: generate-cmdlist.sh command-list.txt diff --git a/generate-configlist.sh b/generate-configlist.sh index 75c39ade20..39ac8845ab 100755 --- a/generate-configlist.sh +++ b/generate-configlist.sh @@ -2,10 +2,11 @@ SOURCE_DIR="$1" OUTPUT="$2" +DEPFILE="$3" if test -z "$SOURCE_DIR" || ! test -d "$SOURCE_DIR" || test -z "$OUTPUT" then - echo >&2 "USAGE: $0 <SOURCE_DIR> <OUTPUT>" + echo >&2 "USAGE: $0 <SOURCE_DIR> <OUTPUT> [<DEPFILE>]" exit 1 fi @@ -36,3 +37,11 @@ print_config_list () { echo print_config_list } >"$OUTPUT" + +if test -n "$DEPFILE" +then + QUOTED_OUTPUT="$(printf '%s\n' "$OUTPUT" | sed 's,[&/\],\\&,g')" + printf '%s\n' "$SOURCE_DIR"/Documentation/*config.adoc \ + "$SOURCE_DIR"/Documentation/config/*.adoc | + sed -e 's/[# ]/\\&/g' -e "s/^/$QUOTED_OUTPUT: /" >"$DEPFILE" +fi diff --git a/meson.build b/meson.build index 762e2d0fc0..74b459b004 100644 --- a/meson.build +++ b/meson.build @@ -720,11 +720,14 @@ endif builtin_sources += custom_target( output: 'config-list.h', + depfile: 'config-list.h.d', + depend_files: [ 'generate-configlist.sh' ], command: [ shell, - meson.current_source_dir() + '/generate-configlist.sh', + meson.current_source_dir() / 'generate-configlist.sh', meson.current_source_dir(), '@OUTPUT@', + '@DEPFILE@', ], env: script_environment, ) Diff-intervalle contre v4 : 1: e2f4e1f9ba < -: ---------- completion: add stash import, export 2: 9cdcc9de04 ! 1: 611a94cd98 meson: regenerate config-list.h when Documentation changes @@ Metadata Author: D. Ben Knoble <ben.knoble+github@gmail.com> ## Commit message ## - meson: regenerate config-list.h when Documentation changes + build: regenerate config-list.h when Documentation changes The Meson-based build doesn't know when to rebuild config-list.h, so the header is sometimes stale. @@ Commit message of dependency files, since Meson does not have (or want) builtin support for globbing like Make. We assume that if a user adds a new file under Documentation/config then they will also edit one of the existing files - to include that new file, and that will trigger a rebuild. + to include that new file, and that will trigger a rebuild. Also mark the + generator script as a dependency. - Also mark the generator script as a dependency. + While we're at it, teach the Makefile to use the same "the script knows + it's dependencies" logic. - Combining the following commands helps debug dependencies: + For Meson, combining the following commands helps debug dependencies: ninja -C <builddir> -t deps config-list.h ninja -C <builddir> -t browse config-list.h @@ Commit message ## Notes (benknoble/commits) ## - Changes from v3 (<0a344f1f3ee4a5d95c6f46df030b9936db4354a1.1770853297.git.ben.knoble+github@gmail.com>): + Changes from v4 (<9cdcc9de04f0f8fff657f0474b31c063466ed808.1771280837.git.ben.knoble+github@gmail.com>): - • Include the script itself as a dependency via depfile - • Fix output path escaping (spaces, octothorpes; drop backslashes) for - Ninja (I've used a loop because I couldn't find a portable construct - that could escape only the remainder of the lines in the way I - wanted). - • Mention our assumptions about Documentation updates triggering - rebuilds - • Also include some debugging information in the commit message + • Include Patrick's suggested Makefile changes. Note there's no quiet + equivalent for mdkir that isn't for the current target's containing + directory… + • Make depfile output efficient again, thanks to Phillip. + + I've kept printf instead of echo (from Patrick/Junio) because I think it + is easier to reason about ("it works" vs. "did I use this in a way that + might cause problems"). + + Junio asked about other problematic bytes: the other one I could think + of (since all the inputs should be paths, anyway) is newlines. I gave + meson's depfile.py a glance [1], and it looks like they don't handle + newlines in paths. Other whitespace doesn't appear to be an issue (see + "elif c in {' ', '\n'}"); I think _most_ characters are just added to + the filename. + + [1]: https://github.com/mesonbuild/meson/blob/master/mesonbuild/depfile.py + + ## Makefile ## +@@ Makefile: $(BUILT_INS): git$X + cp $< $@ + + config-list.h: generate-configlist.sh ++ @mkdir -p .depend ++ $(QUIET_GEN)$(SHELL_PATH) ./generate-configlist.sh . $@ .depend/config-list.h.d + +-config-list.h: Documentation/*config.adoc Documentation/config/*.adoc +- $(QUIET_GEN)$(SHELL_PATH) ./generate-configlist.sh . $@ ++-include .depend/config-list.h.d + + command-list.h: generate-cmdlist.sh command-list.txt + ## generate-configlist.sh ## @@ @@ generate-configlist.sh: print_config_list () { + +if test -n "$DEPFILE" +then -+ for doc in "$SOURCE_DIR"/Documentation/*config.adoc \ -+ "$SOURCE_DIR"/Documentation/config/*.adoc -+ do -+ printf "$OUTPUT: %s\n" "$(printf '%s\n' "$doc" | sed 's/[# ]/\\&/g')" -+ done >"$DEPFILE" ++ QUOTED_OUTPUT="$(printf '%s\n' "$OUTPUT" | sed 's,[&/\],\\&,g')" ++ printf '%s\n' "$SOURCE_DIR"/Documentation/*config.adoc \ ++ "$SOURCE_DIR"/Documentation/config/*.adoc | ++ sed -e 's/[# ]/\\&/g' -e "s/^/$QUOTED_OUTPUT: /" >"$DEPFILE" +fi ## meson.build ## base-commit: f7e9f6c205466443107228e036b20acb7baa8c50 -- 2.53.0 ^ permalink raw reply related [flat|nested] 46+ messages in thread
* Re: [PATCH v5] build: regenerate config-list.h when Documentation changes 2026-02-18 14:37 ` [PATCH v5] build: " D. Ben Knoble @ 2026-02-19 10:19 ` Phillip Wood 2026-02-19 13:40 ` D. Ben Knoble 2026-02-19 13:56 ` Patrick Steinhardt ` (2 subsequent siblings) 3 siblings, 1 reply; 46+ messages in thread From: Phillip Wood @ 2026-02-19 10:19 UTC (permalink / raw) To: D. Ben Knoble, git Cc: Phillip Wood, Patrick Steinhardt, Junio C Hamano, brian m. carlson, Evan Martin Hi Ben I tested the meson changes by setting up source and build directories with daft names to test the quoting. $ git worktree add --detach '/dev/shm/s#r#c dir' $ cd '/dev/shm/s#r#c dir' $ meson setup '/dev/shm/b#u&i ld' If I build git and then remove Documentation/config/add.adoc config-list.h is regenerated, it is not regenerated if I do not change any of the config documentation files so it looks to be working correctly. I've not tested the Makefile changes. Thanks for working on it Phillip On 18/02/2026 14:37, D. Ben Knoble wrote: > The Meson-based build doesn't know when to rebuild config-list.h, so the > header is sometimes stale. > > For example, an old build directory might have config-list.h from before > 4173df5187 (submodule: introduce extensions.submodulePathConfig, > 2026-01-12), which added submodule.<name>.gitdir to the list. Without > it, t9902-completion.sh fails. Regenerating the config-list.h artifact > from sources fixes the artifact and the test. > > Teach the meson build to depend on the Documentation files that > generate-configlist.sh reads by having it an additional output as a list > of dependency files, since Meson does not have (or want) builtin support > for globbing like Make. We assume that if a user adds a new file under > Documentation/config then they will also edit one of the existing files > to include that new file, and that will trigger a rebuild. Also mark the > generator script as a dependency. > > While we're at it, teach the Makefile to use the same "the script knows > it's dependencies" logic. > > For Meson, combining the following commands helps debug dependencies: > > ninja -C <builddir> -t deps config-list.h > ninja -C <builddir> -t browse config-list.h > > The former lists all the dependencies discovered from our output ".d" > file (the config documentation) and the latter shows the dependency on > the script itself, among other useful edges in the dependency graph. > > Helped-by: Patrick Steinhardt <ps@pks.im> > Helped-by: Phillip Wood <phillip.wood@dunelm.org.uk> > Signed-off-by: D. Ben Knoble <ben.knoble+github@gmail.com> > --- > > Notes (benknoble/commits): > Changes from v4 (<9cdcc9de04f0f8fff657f0474b31c063466ed808.1771280837.git.ben.knoble+github@gmail.com>): > > • Include Patrick's suggested Makefile changes. Note there's no quiet > equivalent for mdkir that isn't for the current target's containing > directory… > • Make depfile output efficient again, thanks to Phillip. > > I've kept printf instead of echo (from Patrick/Junio) because I think it > is easier to reason about ("it works" vs. "did I use this in a way that > might cause problems"). > > Junio asked about other problematic bytes: the other one I could think > of (since all the inputs should be paths, anyway) is newlines. I gave > meson's depfile.py a glance [1], and it looks like they don't handle > newlines in paths. Other whitespace doesn't appear to be an issue (see > "elif c in {' ', '\n'}"); I think _most_ characters are just added to > the filename. > > [1]: https://github.com/mesonbuild/meson/blob/master/mesonbuild/depfile.py > > Makefile | 5 +++-- > generate-configlist.sh | 11 ++++++++++- > meson.build | 5 ++++- > 3 files changed, 17 insertions(+), 4 deletions(-) > > diff --git a/Makefile b/Makefile > index 7f37ad8f58..6f926ffb1f 100644 > --- a/Makefile > +++ b/Makefile > @@ -2688,9 +2688,10 @@ $(BUILT_INS): git$X > cp $< $@ > > config-list.h: generate-configlist.sh > + @mkdir -p .depend > + $(QUIET_GEN)$(SHELL_PATH) ./generate-configlist.sh . $@ .depend/config-list.h.d > > -config-list.h: Documentation/*config.adoc Documentation/config/*.adoc > - $(QUIET_GEN)$(SHELL_PATH) ./generate-configlist.sh . $@ > +-include .depend/config-list.h.d > > command-list.h: generate-cmdlist.sh command-list.txt > > diff --git a/generate-configlist.sh b/generate-configlist.sh > index 75c39ade20..39ac8845ab 100755 > --- a/generate-configlist.sh > +++ b/generate-configlist.sh > @@ -2,10 +2,11 @@ > > SOURCE_DIR="$1" > OUTPUT="$2" > +DEPFILE="$3" > > if test -z "$SOURCE_DIR" || ! test -d "$SOURCE_DIR" || test -z "$OUTPUT" > then > - echo >&2 "USAGE: $0 <SOURCE_DIR> <OUTPUT>" > + echo >&2 "USAGE: $0 <SOURCE_DIR> <OUTPUT> [<DEPFILE>]" > exit 1 > fi > > @@ -36,3 +37,11 @@ print_config_list () { > echo > print_config_list > } >"$OUTPUT" > + > +if test -n "$DEPFILE" > +then > + QUOTED_OUTPUT="$(printf '%s\n' "$OUTPUT" | sed 's,[&/\],\\&,g')" > + printf '%s\n' "$SOURCE_DIR"/Documentation/*config.adoc \ > + "$SOURCE_DIR"/Documentation/config/*.adoc | > + sed -e 's/[# ]/\\&/g' -e "s/^/$QUOTED_OUTPUT: /" >"$DEPFILE" > +fi > diff --git a/meson.build b/meson.build > index 762e2d0fc0..74b459b004 100644 > --- a/meson.build > +++ b/meson.build > @@ -720,11 +720,14 @@ endif > > builtin_sources += custom_target( > output: 'config-list.h', > + depfile: 'config-list.h.d', > + depend_files: [ 'generate-configlist.sh' ], > command: [ > shell, > - meson.current_source_dir() + '/generate-configlist.sh', > + meson.current_source_dir() / 'generate-configlist.sh', > meson.current_source_dir(), > '@OUTPUT@', > + '@DEPFILE@', > ], > env: script_environment, > ) > > Diff-intervalle contre v4 : > 1: e2f4e1f9ba < -: ---------- completion: add stash import, export > 2: 9cdcc9de04 ! 1: 611a94cd98 meson: regenerate config-list.h when Documentation changes > @@ Metadata > Author: D. Ben Knoble <ben.knoble+github@gmail.com> > > ## Commit message ## > - meson: regenerate config-list.h when Documentation changes > + build: regenerate config-list.h when Documentation changes > > The Meson-based build doesn't know when to rebuild config-list.h, so the > header is sometimes stale. > @@ Commit message > of dependency files, since Meson does not have (or want) builtin support > for globbing like Make. We assume that if a user adds a new file under > Documentation/config then they will also edit one of the existing files > - to include that new file, and that will trigger a rebuild. > + to include that new file, and that will trigger a rebuild. Also mark the > + generator script as a dependency. > > - Also mark the generator script as a dependency. > + While we're at it, teach the Makefile to use the same "the script knows > + it's dependencies" logic. > > - Combining the following commands helps debug dependencies: > + For Meson, combining the following commands helps debug dependencies: > > ninja -C <builddir> -t deps config-list.h > ninja -C <builddir> -t browse config-list.h > @@ Commit message > > > ## Notes (benknoble/commits) ## > - Changes from v3 (<0a344f1f3ee4a5d95c6f46df030b9936db4354a1.1770853297.git.ben.knoble+github@gmail.com>): > + Changes from v4 (<9cdcc9de04f0f8fff657f0474b31c063466ed808.1771280837.git.ben.knoble+github@gmail.com>): > > - • Include the script itself as a dependency via depfile > - • Fix output path escaping (spaces, octothorpes; drop backslashes) for > - Ninja (I've used a loop because I couldn't find a portable construct > - that could escape only the remainder of the lines in the way I > - wanted). > - • Mention our assumptions about Documentation updates triggering > - rebuilds > - • Also include some debugging information in the commit message > + • Include Patrick's suggested Makefile changes. Note there's no quiet > + equivalent for mdkir that isn't for the current target's containing > + directory… > + • Make depfile output efficient again, thanks to Phillip. > + > + I've kept printf instead of echo (from Patrick/Junio) because I think it > + is easier to reason about ("it works" vs. "did I use this in a way that > + might cause problems"). > + > + Junio asked about other problematic bytes: the other one I could think > + of (since all the inputs should be paths, anyway) is newlines. I gave > + meson's depfile.py a glance [1], and it looks like they don't handle > + newlines in paths. Other whitespace doesn't appear to be an issue (see > + "elif c in {' ', '\n'}"); I think _most_ characters are just added to > + the filename. > + > + [1]: https://github.com/mesonbuild/meson/blob/master/mesonbuild/depfile.py > + > + ## Makefile ## > +@@ Makefile: $(BUILT_INS): git$X > + cp $< $@ > + > + config-list.h: generate-configlist.sh > ++ @mkdir -p .depend > ++ $(QUIET_GEN)$(SHELL_PATH) ./generate-configlist.sh . $@ .depend/config-list.h.d > + > +-config-list.h: Documentation/*config.adoc Documentation/config/*.adoc > +- $(QUIET_GEN)$(SHELL_PATH) ./generate-configlist.sh . $@ > ++-include .depend/config-list.h.d > + > + command-list.h: generate-cmdlist.sh command-list.txt > + > > ## generate-configlist.sh ## > @@ > @@ generate-configlist.sh: print_config_list () { > + > +if test -n "$DEPFILE" > +then > -+ for doc in "$SOURCE_DIR"/Documentation/*config.adoc \ > -+ "$SOURCE_DIR"/Documentation/config/*.adoc > -+ do > -+ printf "$OUTPUT: %s\n" "$(printf '%s\n' "$doc" | sed 's/[# ]/\\&/g')" > -+ done >"$DEPFILE" > ++ QUOTED_OUTPUT="$(printf '%s\n' "$OUTPUT" | sed 's,[&/\],\\&,g')" > ++ printf '%s\n' "$SOURCE_DIR"/Documentation/*config.adoc \ > ++ "$SOURCE_DIR"/Documentation/config/*.adoc | > ++ sed -e 's/[# ]/\\&/g' -e "s/^/$QUOTED_OUTPUT: /" >"$DEPFILE" > +fi > > ## meson.build ## > > base-commit: f7e9f6c205466443107228e036b20acb7baa8c50 ^ permalink raw reply [flat|nested] 46+ messages in thread
* Re: [PATCH v5] build: regenerate config-list.h when Documentation changes 2026-02-19 10:19 ` Phillip Wood @ 2026-02-19 13:40 ` D. Ben Knoble 0 siblings, 0 replies; 46+ messages in thread From: D. Ben Knoble @ 2026-02-19 13:40 UTC (permalink / raw) To: phillip.wood Cc: git, Patrick Steinhardt, Junio C Hamano, brian m. carlson, Evan Martin On Thu, Feb 19, 2026 at 5:19 AM Phillip Wood <phillip.wood123@gmail.com> wrote: > > Hi Ben > > I tested the meson changes by setting up source and build directories > with daft names to test the quoting. > > $ git worktree add --detach '/dev/shm/s#r#c dir' > $ cd '/dev/shm/s#r#c dir' > $ meson setup '/dev/shm/b#u&i ld' > > If I build git and then remove Documentation/config/add.adoc > config-list.h is regenerated, it is not regenerated if I do not change > any of the config documentation files so it looks to be working > correctly. I've not tested the Makefile changes. > > Thanks for working on it > > Phillip Great, thanks! ^ permalink raw reply [flat|nested] 46+ messages in thread
* Re: [PATCH v5] build: regenerate config-list.h when Documentation changes 2026-02-18 14:37 ` [PATCH v5] build: " D. Ben Knoble 2026-02-19 10:19 ` Phillip Wood @ 2026-02-19 13:56 ` Patrick Steinhardt 2026-02-21 13:58 ` D. Ben Knoble 2026-02-19 15:10 ` Marc Branchaud 2026-02-21 14:07 ` [PATCH v6] " D. Ben Knoble 3 siblings, 1 reply; 46+ messages in thread From: Patrick Steinhardt @ 2026-02-19 13:56 UTC (permalink / raw) To: D. Ben Knoble Cc: git, Phillip Wood, Junio C Hamano, brian m. carlson, Evan Martin On Wed, Feb 18, 2026 at 09:37:59AM -0500, D. Ben Knoble wrote: > diff --git a/generate-configlist.sh b/generate-configlist.sh > index 75c39ade20..39ac8845ab 100755 > --- a/generate-configlist.sh > +++ b/generate-configlist.sh > @@ -36,3 +37,11 @@ print_config_list () { > echo > print_config_list > } >"$OUTPUT" > + > +if test -n "$DEPFILE" We could arguably drop conditional now that both the Makefile and Meson pass that argument, but I don't mind it much. > +then > + QUOTED_OUTPUT="$(printf '%s\n' "$OUTPUT" | sed 's,[&/\],\\&,g')" > + printf '%s\n' "$SOURCE_DIR"/Documentation/*config.adoc \ > + "$SOURCE_DIR"/Documentation/config/*.adoc | > + sed -e 's/[# ]/\\&/g' -e "s/^/$QUOTED_OUTPUT: /" >"$DEPFILE" > +fi Okay, so we first quote the target output file once, and then we quote the sources with a single call to sed(1), too. To not perform quoting of the target output file twice we don't include it in the printf call, but instead prepend it to each line. Looks reasonable to me, and we spawn at most two sed(1) processes. Nice. > diff --git a/meson.build b/meson.build > index 762e2d0fc0..74b459b004 100644 > --- a/meson.build > +++ b/meson.build > @@ -720,11 +720,14 @@ endif > > builtin_sources += custom_target( > output: 'config-list.h', > + depfile: 'config-list.h.d', > + depend_files: [ 'generate-configlist.sh' ], > command: [ > shell, > - meson.current_source_dir() + '/generate-configlist.sh', > + meson.current_source_dir() / 'generate-configlist.sh', > meson.current_source_dir(), > '@OUTPUT@', > + '@DEPFILE@', > ], > env: script_environment, > ) > > Diff-intervalle contre v4 : > 1: e2f4e1f9ba < -: ---------- completion: add stash import, export The range-diff is a bit broken, but that doesn't really matter much. Overall this patch looks good to me, thanks! Patrick ^ permalink raw reply [flat|nested] 46+ messages in thread
* Re: [PATCH v5] build: regenerate config-list.h when Documentation changes 2026-02-19 13:56 ` Patrick Steinhardt @ 2026-02-21 13:58 ` D. Ben Knoble 0 siblings, 0 replies; 46+ messages in thread From: D. Ben Knoble @ 2026-02-21 13:58 UTC (permalink / raw) To: Patrick Steinhardt Cc: git, Phillip Wood, Junio C Hamano, brian m. carlson, Evan Martin On Thu, Feb 19, 2026 at 8:57 AM Patrick Steinhardt <ps@pks.im> wrote: > > On Wed, Feb 18, 2026 at 09:37:59AM -0500, D. Ben Knoble wrote: > > diff --git a/generate-configlist.sh b/generate-configlist.sh > > index 75c39ade20..39ac8845ab 100755 > > --- a/generate-configlist.sh > > +++ b/generate-configlist.sh > > @@ -36,3 +37,11 @@ print_config_list () { > > echo > > print_config_list > > } >"$OUTPUT" > > + > > +if test -n "$DEPFILE" > > We could arguably drop conditional now that both the Makefile and Meson > pass that argument, but I don't mind it much. I'm going to reroll a commit message, so I could drop this. OTOH, I think we've got a working configuration, and maybe someone runs this script occasionally to generate the list without wanting the deps. Idk. > > +then > > + QUOTED_OUTPUT="$(printf '%s\n' "$OUTPUT" | sed 's,[&/\],\\&,g')" > > + printf '%s\n' "$SOURCE_DIR"/Documentation/*config.adoc \ > > + "$SOURCE_DIR"/Documentation/config/*.adoc | > > + sed -e 's/[# ]/\\&/g' -e "s/^/$QUOTED_OUTPUT: /" >"$DEPFILE" > > +fi > > Okay, so we first quote the target output file once, and then we quote > the sources with a single call to sed(1), too. To not perform quoting > of the target output file twice we don't include it in the printf call, > but instead prepend it to each line. > > Looks reasonable to me, and we spawn at most two sed(1) processes. Nice. > > > diff --git a/meson.build b/meson.build > > index 762e2d0fc0..74b459b004 100644 > > --- a/meson.build > > +++ b/meson.build > > @@ -720,11 +720,14 @@ endif > > > > builtin_sources += custom_target( > > output: 'config-list.h', > > + depfile: 'config-list.h.d', > > + depend_files: [ 'generate-configlist.sh' ], > > command: [ > > shell, > > - meson.current_source_dir() + '/generate-configlist.sh', > > + meson.current_source_dir() / 'generate-configlist.sh', > > meson.current_source_dir(), > > '@OUTPUT@', > > + '@DEPFILE@', > > ], > > env: script_environment, > > ) > > > > Diff-intervalle contre v4 : > > 1: e2f4e1f9ba < -: ---------- completion: add stash import, export > > The range-diff is a bit broken, but that doesn't really matter much. Gr. I must have tweaked something at the last second and missed this. Bummer. > Overall this patch looks good to me, thanks! > > Patrick Thanks for the help and reviews! ^ permalink raw reply [flat|nested] 46+ messages in thread
* Re: [PATCH v5] build: regenerate config-list.h when Documentation changes 2026-02-18 14:37 ` [PATCH v5] build: " D. Ben Knoble 2026-02-19 10:19 ` Phillip Wood 2026-02-19 13:56 ` Patrick Steinhardt @ 2026-02-19 15:10 ` Marc Branchaud 2026-02-21 13:58 ` D. Ben Knoble 2026-02-21 14:07 ` [PATCH v6] " D. Ben Knoble 3 siblings, 1 reply; 46+ messages in thread From: Marc Branchaud @ 2026-02-19 15:10 UTC (permalink / raw) To: D. Ben Knoble, git Cc: Phillip Wood, Patrick Steinhardt, Junio C Hamano, brian m. carlson, Evan Martin On 2026-02-18 07:37, D. Ben Knoble wrote: > The Meson-based build doesn't know when to rebuild config-list.h, so the > header is sometimes stale. > > For example, an old build directory might have config-list.h from before > 4173df5187 (submodule: introduce extensions.submodulePathConfig, > 2026-01-12), which added submodule.<name>.gitdir to the list. Without > it, t9902-completion.sh fails. Regenerating the config-list.h artifact > from sources fixes the artifact and the test. > > Teach the meson build to depend on the Documentation files that > generate-configlist.sh reads by having it an additional output as a list> of dependency files, since Meson does not have (or want) builtin support > for globbing like Make. That sentence doesn't parse. Maybe this? Since Meson does not have (or want) builtin support for globbing like Make, teach generate-configlist.sh to generate a dependency list of the Documentation files it reads, and have the Meson build incorporate that. M. > We assume that if a user adds a new file under > Documentation/config then they will also edit one of the existing files > to include that new file, and that will trigger a rebuild. Also mark the > generator script as a dependency. > > While we're at it, teach the Makefile to use the same "the script knows > it's dependencies" logic. > > For Meson, combining the following commands helps debug dependencies: > > ninja -C <builddir> -t deps config-list.h > ninja -C <builddir> -t browse config-list.h > > The former lists all the dependencies discovered from our output ".d" > file (the config documentation) and the latter shows the dependency on > the script itself, among other useful edges in the dependency graph. > > Helped-by: Patrick Steinhardt <ps@pks.im> > Helped-by: Phillip Wood <phillip.wood@dunelm.org.uk> > Signed-off-by: D. Ben Knoble <ben.knoble+github@gmail.com> > --- > > Notes (benknoble/commits): > Changes from v4 (<9cdcc9de04f0f8fff657f0474b31c063466ed808.1771280837.git.ben.knoble+github@gmail.com>): > > • Include Patrick's suggested Makefile changes. Note there's no quiet > equivalent for mdkir that isn't for the current target's containing > directory… > • Make depfile output efficient again, thanks to Phillip. > > I've kept printf instead of echo (from Patrick/Junio) because I think it > is easier to reason about ("it works" vs. "did I use this in a way that > might cause problems"). > > Junio asked about other problematic bytes: the other one I could think > of (since all the inputs should be paths, anyway) is newlines. I gave > meson's depfile.py a glance [1], and it looks like they don't handle > newlines in paths. Other whitespace doesn't appear to be an issue (see > "elif c in {' ', '\n'}"); I think _most_ characters are just added to > the filename. > > [1]: https://github.com/mesonbuild/meson/blob/master/mesonbuild/depfile.py > > Makefile | 5 +++-- > generate-configlist.sh | 11 ++++++++++- > meson.build | 5 ++++- > 3 files changed, 17 insertions(+), 4 deletions(-) > > diff --git a/Makefile b/Makefile > index 7f37ad8f58..6f926ffb1f 100644 > --- a/Makefile > +++ b/Makefile > @@ -2688,9 +2688,10 @@ $(BUILT_INS): git$X > cp $< $@ > > config-list.h: generate-configlist.sh > + @mkdir -p .depend > + $(QUIET_GEN)$(SHELL_PATH) ./generate-configlist.sh . $@ .depend/config-list.h.d > > -config-list.h: Documentation/*config.adoc Documentation/config/*.adoc > - $(QUIET_GEN)$(SHELL_PATH) ./generate-configlist.sh . $@ > +-include .depend/config-list.h.d > > command-list.h: generate-cmdlist.sh command-list.txt > > diff --git a/generate-configlist.sh b/generate-configlist.sh > index 75c39ade20..39ac8845ab 100755 > --- a/generate-configlist.sh > +++ b/generate-configlist.sh > @@ -2,10 +2,11 @@ > > SOURCE_DIR="$1" > OUTPUT="$2" > +DEPFILE="$3" > > if test -z "$SOURCE_DIR" || ! test -d "$SOURCE_DIR" || test -z "$OUTPUT" > then > - echo >&2 "USAGE: $0 <SOURCE_DIR> <OUTPUT>" > + echo >&2 "USAGE: $0 <SOURCE_DIR> <OUTPUT> [<DEPFILE>]" > exit 1 > fi > > @@ -36,3 +37,11 @@ print_config_list () { > echo > print_config_list > } >"$OUTPUT" > + > +if test -n "$DEPFILE" > +then > + QUOTED_OUTPUT="$(printf '%s\n' "$OUTPUT" | sed 's,[&/\],\\&,g')" > + printf '%s\n' "$SOURCE_DIR"/Documentation/*config.adoc \ > + "$SOURCE_DIR"/Documentation/config/*.adoc | > + sed -e 's/[# ]/\\&/g' -e "s/^/$QUOTED_OUTPUT: /" >"$DEPFILE" > +fi > diff --git a/meson.build b/meson.build > index 762e2d0fc0..74b459b004 100644 > --- a/meson.build > +++ b/meson.build > @@ -720,11 +720,14 @@ endif > > builtin_sources += custom_target( > output: 'config-list.h', > + depfile: 'config-list.h.d', > + depend_files: [ 'generate-configlist.sh' ], > command: [ > shell, > - meson.current_source_dir() + '/generate-configlist.sh', > + meson.current_source_dir() / 'generate-configlist.sh', > meson.current_source_dir(), > '@OUTPUT@', > + '@DEPFILE@', > ], > env: script_environment, > ) > > Diff-intervalle contre v4 : > 1: e2f4e1f9ba < -: ---------- completion: add stash import, export > 2: 9cdcc9de04 ! 1: 611a94cd98 meson: regenerate config-list.h when Documentation changes > @@ Metadata > Author: D. Ben Knoble <ben.knoble+github@gmail.com> > > ## Commit message ## > - meson: regenerate config-list.h when Documentation changes > + build: regenerate config-list.h when Documentation changes > > The Meson-based build doesn't know when to rebuild config-list.h, so the > header is sometimes stale. > @@ Commit message > of dependency files, since Meson does not have (or want) builtin support > for globbing like Make. We assume that if a user adds a new file under > Documentation/config then they will also edit one of the existing files > - to include that new file, and that will trigger a rebuild. > + to include that new file, and that will trigger a rebuild. Also mark the > + generator script as a dependency. > > - Also mark the generator script as a dependency. > + While we're at it, teach the Makefile to use the same "the script knows > + it's dependencies" logic. > > - Combining the following commands helps debug dependencies: > + For Meson, combining the following commands helps debug dependencies: > > ninja -C <builddir> -t deps config-list.h > ninja -C <builddir> -t browse config-list.h > @@ Commit message > > > ## Notes (benknoble/commits) ## > - Changes from v3 (<0a344f1f3ee4a5d95c6f46df030b9936db4354a1.1770853297.git.ben.knoble+github@gmail.com>): > + Changes from v4 (<9cdcc9de04f0f8fff657f0474b31c063466ed808.1771280837.git.ben.knoble+github@gmail.com>): > > - • Include the script itself as a dependency via depfile > - • Fix output path escaping (spaces, octothorpes; drop backslashes) for > - Ninja (I've used a loop because I couldn't find a portable construct > - that could escape only the remainder of the lines in the way I > - wanted). > - • Mention our assumptions about Documentation updates triggering > - rebuilds > - • Also include some debugging information in the commit message > + • Include Patrick's suggested Makefile changes. Note there's no quiet > + equivalent for mdkir that isn't for the current target's containing > + directory… > + • Make depfile output efficient again, thanks to Phillip. > + > + I've kept printf instead of echo (from Patrick/Junio) because I think it > + is easier to reason about ("it works" vs. "did I use this in a way that > + might cause problems"). > + > + Junio asked about other problematic bytes: the other one I could think > + of (since all the inputs should be paths, anyway) is newlines. I gave > + meson's depfile.py a glance [1], and it looks like they don't handle > + newlines in paths. Other whitespace doesn't appear to be an issue (see > + "elif c in {' ', '\n'}"); I think _most_ characters are just added to > + the filename. > + > + [1]: https://github.com/mesonbuild/meson/blob/master/mesonbuild/depfile.py > + > + ## Makefile ## > +@@ Makefile: $(BUILT_INS): git$X > + cp $< $@ > + > + config-list.h: generate-configlist.sh > ++ @mkdir -p .depend > ++ $(QUIET_GEN)$(SHELL_PATH) ./generate-configlist.sh . $@ .depend/config-list.h.d > + > +-config-list.h: Documentation/*config.adoc Documentation/config/*.adoc > +- $(QUIET_GEN)$(SHELL_PATH) ./generate-configlist.sh . $@ > ++-include .depend/config-list.h.d > + > + command-list.h: generate-cmdlist.sh command-list.txt > + > > ## generate-configlist.sh ## > @@ > @@ generate-configlist.sh: print_config_list () { > + > +if test -n "$DEPFILE" > +then > -+ for doc in "$SOURCE_DIR"/Documentation/*config.adoc \ > -+ "$SOURCE_DIR"/Documentation/config/*.adoc > -+ do > -+ printf "$OUTPUT: %s\n" "$(printf '%s\n' "$doc" | sed 's/[# ]/\\&/g')" > -+ done >"$DEPFILE" > ++ QUOTED_OUTPUT="$(printf '%s\n' "$OUTPUT" | sed 's,[&/\],\\&,g')" > ++ printf '%s\n' "$SOURCE_DIR"/Documentation/*config.adoc \ > ++ "$SOURCE_DIR"/Documentation/config/*.adoc | > ++ sed -e 's/[# ]/\\&/g' -e "s/^/$QUOTED_OUTPUT: /" >"$DEPFILE" > +fi > > ## meson.build ## > > base-commit: f7e9f6c205466443107228e036b20acb7baa8c50 ^ permalink raw reply [flat|nested] 46+ messages in thread
* Re: [PATCH v5] build: regenerate config-list.h when Documentation changes 2026-02-19 15:10 ` Marc Branchaud @ 2026-02-21 13:58 ` D. Ben Knoble 0 siblings, 0 replies; 46+ messages in thread From: D. Ben Knoble @ 2026-02-21 13:58 UTC (permalink / raw) To: Marc Branchaud Cc: git, Phillip Wood, Patrick Steinhardt, Junio C Hamano, brian m. carlson, Evan Martin On Thu, Feb 19, 2026 at 10:10 AM Marc Branchaud <marcnarc@xiplink.com> wrote: > > > On 2026-02-18 07:37, D. Ben Knoble wrote: > > The Meson-based build doesn't know when to rebuild config-list.h, so the > > header is sometimes stale. > > > > For example, an old build directory might have config-list.h from before > > 4173df5187 (submodule: introduce extensions.submodulePathConfig, > > 2026-01-12), which added submodule.<name>.gitdir to the list. Without > > it, t9902-completion.sh fails. Regenerating the config-list.h artifact > > from sources fixes the artifact and the test. > > > > Teach the meson build to depend on the Documentation files that > > generate-configlist.sh reads by having it an additional output as a list > > of dependency files, since Meson does not have (or want) builtin support > > for globbing like Make. > > That sentence doesn't parse. Maybe this? > > Since Meson does not have (or want) builtin support for globbing like > Make, teach generate-configlist.sh to generate a dependency list of the > Documentation files it reads, and have the Meson build incorporate that. > > M. Thanks. That sentence is looking stranger than when I first wrote it. Will fix. ^ permalink raw reply [flat|nested] 46+ messages in thread
* [PATCH v6] build: regenerate config-list.h when Documentation changes 2026-02-18 14:37 ` [PATCH v5] build: " D. Ben Knoble ` (2 preceding siblings ...) 2026-02-19 15:10 ` Marc Branchaud @ 2026-02-21 14:07 ` D. Ben Knoble 2026-02-23 6:37 ` Patrick Steinhardt ` (2 more replies) 3 siblings, 3 replies; 46+ messages in thread From: D. Ben Knoble @ 2026-02-21 14:07 UTC (permalink / raw) To: git Cc: D. Ben Knoble, Phillip Wood, Patrick Steinhardt, Marc Branchaud, Evan Martin, brian m. carlson, Junio C Hamano The Meson-based build doesn't know when to rebuild config-list.h, so the header is sometimes stale. For example, an old build directory might have config-list.h from before 4173df5187 (submodule: introduce extensions.submodulePathConfig, 2026-01-12), which added submodule.<name>.gitdir to the list. Without it, t9902-completion.sh fails. Regenerating the config-list.h artifact from sources fixes the artifact and the test. Since Meson does not have (or want) builtin support for globbing like Make, teach generate-configlist.sh to also generate a list of Documentation files its output depends on, and incorporate that into the Meson build. We assume that if a user adds a new file under Documentation/config then they will also edit one of the existing files to include that new file, and that will trigger a rebuild. Also mark the generator script as a dependency. While we're at it, teach the Makefile to use the same "the script knows it's dependencies" logic. For Meson, combining the following commands helps debug dependencies: ninja -C <builddir> -t deps config-list.h ninja -C <builddir> -t browse config-list.h The former lists all the dependencies discovered from our output ".d" file (the config documentation) and the latter shows the dependency on the script itself, among other useful edges in the dependency graph. Helped-by: Patrick Steinhardt <ps@pks.im> Helped-by: Phillip Wood <phillip.wood@dunelm.org.uk> Signed-off-by: D. Ben Knoble <ben.knoble+github@gmail.com> --- Notes (benknoble/commits): Changes from v5 (<611a94cd988e3795bc63dba2f1b270aa0d058bd2.1771425395.git.ben.knoble+github@gmail.com>): • Reword a confusing sentence in the commit message Makefile | 5 +++-- generate-configlist.sh | 11 ++++++++++- meson.build | 5 ++++- 3 files changed, 17 insertions(+), 4 deletions(-) diff --git a/Makefile b/Makefile index 7f37ad8f58..6f926ffb1f 100644 --- a/Makefile +++ b/Makefile @@ -2688,9 +2688,10 @@ $(BUILT_INS): git$X cp $< $@ config-list.h: generate-configlist.sh + @mkdir -p .depend + $(QUIET_GEN)$(SHELL_PATH) ./generate-configlist.sh . $@ .depend/config-list.h.d -config-list.h: Documentation/*config.adoc Documentation/config/*.adoc - $(QUIET_GEN)$(SHELL_PATH) ./generate-configlist.sh . $@ +-include .depend/config-list.h.d command-list.h: generate-cmdlist.sh command-list.txt diff --git a/generate-configlist.sh b/generate-configlist.sh index 75c39ade20..39ac8845ab 100755 --- a/generate-configlist.sh +++ b/generate-configlist.sh @@ -2,10 +2,11 @@ SOURCE_DIR="$1" OUTPUT="$2" +DEPFILE="$3" if test -z "$SOURCE_DIR" || ! test -d "$SOURCE_DIR" || test -z "$OUTPUT" then - echo >&2 "USAGE: $0 <SOURCE_DIR> <OUTPUT>" + echo >&2 "USAGE: $0 <SOURCE_DIR> <OUTPUT> [<DEPFILE>]" exit 1 fi @@ -36,3 +37,11 @@ print_config_list () { echo print_config_list } >"$OUTPUT" + +if test -n "$DEPFILE" +then + QUOTED_OUTPUT="$(printf '%s\n' "$OUTPUT" | sed 's,[&/\],\\&,g')" + printf '%s\n' "$SOURCE_DIR"/Documentation/*config.adoc \ + "$SOURCE_DIR"/Documentation/config/*.adoc | + sed -e 's/[# ]/\\&/g' -e "s/^/$QUOTED_OUTPUT: /" >"$DEPFILE" +fi diff --git a/meson.build b/meson.build index 762e2d0fc0..74b459b004 100644 --- a/meson.build +++ b/meson.build @@ -720,11 +720,14 @@ endif builtin_sources += custom_target( output: 'config-list.h', + depfile: 'config-list.h.d', + depend_files: [ 'generate-configlist.sh' ], command: [ shell, - meson.current_source_dir() + '/generate-configlist.sh', + meson.current_source_dir() / 'generate-configlist.sh', meson.current_source_dir(), '@OUTPUT@', + '@DEPFILE@', ], env: script_environment, ) Diff-intervalle contre v5 : 1: 611a94cd98 ! 1: 5dcd4e9308 build: regenerate config-list.h when Documentation changes @@ Commit message it, t9902-completion.sh fails. Regenerating the config-list.h artifact from sources fixes the artifact and the test. - Teach the meson build to depend on the Documentation files that - generate-configlist.sh reads by having it an additional output as a list - of dependency files, since Meson does not have (or want) builtin support - for globbing like Make. We assume that if a user adds a new file under + Since Meson does not have (or want) builtin support for globbing like + Make, teach generate-configlist.sh to also generate a list of + Documentation files its output depends on, and incorporate that into the + Meson build. + + We assume that if a user adds a new file under Documentation/config then they will also edit one of the existing files to include that new file, and that will trigger a rebuild. Also mark the generator script as a dependency. @@ Commit message ## Notes (benknoble/commits) ## - Changes from v4 (<9cdcc9de04f0f8fff657f0474b31c063466ed808.1771280837.git.ben.knoble+github@gmail.com>): + Changes from v5 (<611a94cd988e3795bc63dba2f1b270aa0d058bd2.1771425395.git.ben.knoble+github@gmail.com>): - • Include Patrick's suggested Makefile changes. Note there's no quiet - equivalent for mdkir that isn't for the current target's containing - directory… - • Make depfile output efficient again, thanks to Phillip. - - I've kept printf instead of echo (from Patrick/Junio) because I think it - is easier to reason about ("it works" vs. "did I use this in a way that - might cause problems"). - - Junio asked about other problematic bytes: the other one I could think - of (since all the inputs should be paths, anyway) is newlines. I gave - meson's depfile.py a glance [1], and it looks like they don't handle - newlines in paths. Other whitespace doesn't appear to be an issue (see - "elif c in {' ', '\n'}"); I think _most_ characters are just added to - the filename. - - [1]: https://github.com/mesonbuild/meson/blob/master/mesonbuild/depfile.py + • Reword a confusing sentence in the commit message ## Makefile ## @@ Makefile: $(BUILT_INS): git$X base-commit: 4a7958ca1415077ce9b1d0a38223ede55da779d9 -- 2.53.0 ^ permalink raw reply related [flat|nested] 46+ messages in thread
* Re: [PATCH v6] build: regenerate config-list.h when Documentation changes 2026-02-21 14:07 ` [PATCH v6] " D. Ben Knoble @ 2026-02-23 6:37 ` Patrick Steinhardt 2026-02-23 6:55 ` SZEDER Gábor 2026-02-24 14:39 ` [PATCH v7] " D. Ben Knoble 2 siblings, 0 replies; 46+ messages in thread From: Patrick Steinhardt @ 2026-02-23 6:37 UTC (permalink / raw) To: D. Ben Knoble Cc: git, Phillip Wood, Marc Branchaud, Evan Martin, brian m. carlson, Junio C Hamano On Sat, Feb 21, 2026 at 09:07:17AM -0500, D. Ben Knoble wrote: > Notes (benknoble/commits): > Changes from v5 (<611a94cd988e3795bc63dba2f1b270aa0d058bd2.1771425395.git.ben.knoble+github@gmail.com>): > > • Reword a confusing sentence in the commit message Thanks, this version looks ready to me. Patrick ^ permalink raw reply [flat|nested] 46+ messages in thread
* Re: [PATCH v6] build: regenerate config-list.h when Documentation changes 2026-02-21 14:07 ` [PATCH v6] " D. Ben Knoble 2026-02-23 6:37 ` Patrick Steinhardt @ 2026-02-23 6:55 ` SZEDER Gábor 2026-02-23 21:41 ` Ben Knoble 2026-02-24 14:39 ` [PATCH v7] " D. Ben Knoble 2 siblings, 1 reply; 46+ messages in thread From: SZEDER Gábor @ 2026-02-23 6:55 UTC (permalink / raw) To: D. Ben Knoble Cc: git, Phillip Wood, Patrick Steinhardt, Marc Branchaud, Evan Martin, brian m. carlson, Junio C Hamano On Sat, Feb 21, 2026 at 09:07:17AM -0500, D. Ben Knoble wrote: > The Meson-based build doesn't know when to rebuild config-list.h, so the > header is sometimes stale. > > For example, an old build directory might have config-list.h from before > 4173df5187 (submodule: introduce extensions.submodulePathConfig, > 2026-01-12), which added submodule.<name>.gitdir to the list. Without > it, t9902-completion.sh fails. Regenerating the config-list.h artifact > from sources fixes the artifact and the test. > > Since Meson does not have (or want) builtin support for globbing like > Make, teach generate-configlist.sh to also generate a list of > Documentation files its output depends on, and incorporate that into the > Meson build. > > We assume that if a user adds a new file under > Documentation/config then they will also edit one of the existing files > to include that new file, and that will trigger a rebuild. Also mark the > generator script as a dependency. > > While we're at it, teach the Makefile to use the same "the script knows > it's dependencies" logic. > > For Meson, combining the following commands helps debug dependencies: > > ninja -C <builddir> -t deps config-list.h > ninja -C <builddir> -t browse config-list.h > > The former lists all the dependencies discovered from our output ".d" > file (the config documentation) and the latter shows the dependency on > the script itself, among other useful edges in the dependency graph. > > Helped-by: Patrick Steinhardt <ps@pks.im> > Helped-by: Phillip Wood <phillip.wood@dunelm.org.uk> > Signed-off-by: D. Ben Knoble <ben.knoble+github@gmail.com> > --- > > Notes (benknoble/commits): > Changes from v5 (<611a94cd988e3795bc63dba2f1b270aa0d058bd2.1771425395.git.ben.knoble+github@gmail.com>): > > • Reword a confusing sentence in the commit message > > Makefile | 5 +++-- > generate-configlist.sh | 11 ++++++++++- > meson.build | 5 ++++- > 3 files changed, 17 insertions(+), 4 deletions(-) > > diff --git a/Makefile b/Makefile > index 7f37ad8f58..6f926ffb1f 100644 > --- a/Makefile > +++ b/Makefile > @@ -2688,9 +2688,10 @@ $(BUILT_INS): git$X > cp $< $@ > > config-list.h: generate-configlist.sh > + @mkdir -p .depend > + $(QUIET_GEN)$(SHELL_PATH) ./generate-configlist.sh . $@ .depend/config-list.h.d > > -config-list.h: Documentation/*config.adoc Documentation/config/*.adoc > - $(QUIET_GEN)$(SHELL_PATH) ./generate-configlist.sh . $@ > +-include .depend/config-list.h.d This breaks the build when something disappears from Documentation/config/: $ git checkout origin/seen HEAD is now at 57edfa3ce8 Merge branch 'ty/setup-error-tightening' into seen $ ls -l Documentation/config/hook.adoc -rw-rw-r-- 1 szeder szeder 3828 Feb 23 07:50 Documentation/config/hook.adoc $ git grep hook.adoc Documentation/git-hook.adoc:include::config/hook.adoc[] Documentation/howto/meson.build: 'rebuild-from-update-hook.adoc', Documentation/meson.build: 'git-hook.adoc' : 1, $ make V=1 config-list.h /bin/sh ./generate-configlist.sh . config-list.h .depend/config-list.h.d $ git checkout 0aabf70f60 Previous HEAD position was 57edfa3ce8 Merge branch 'ty/setup-error-tightening' into seen HEAD is now at 0aabf70f60 build: regenerate config-list.h when Documentation changes $ ls -l Documentation/config/hook.adoc ls: cannot access 'Documentation/config/hook.adoc': No such file or directory $ git grep hook.adoc Documentation/howto/meson.build: 'rebuild-from-update-hook.adoc', Documentation/meson.build: 'git-hook.adoc' : 1, $ make V=1 config-list.h GIT_VERSION=2.53.0.119.g0aabf70f60 make: *** No rule to make target 'Documentation/config/hook.adoc', needed by 'config-list.h'. Stop. $ grep hook.adoc .depend/config-list.h.d config-list.h: ./Documentation/config/hook.adoc > command-list.h: generate-cmdlist.sh command-list.txt > > diff --git a/generate-configlist.sh b/generate-configlist.sh > index 75c39ade20..39ac8845ab 100755 > --- a/generate-configlist.sh > +++ b/generate-configlist.sh > @@ -2,10 +2,11 @@ > > SOURCE_DIR="$1" > OUTPUT="$2" > +DEPFILE="$3" > > if test -z "$SOURCE_DIR" || ! test -d "$SOURCE_DIR" || test -z "$OUTPUT" > then > - echo >&2 "USAGE: $0 <SOURCE_DIR> <OUTPUT>" > + echo >&2 "USAGE: $0 <SOURCE_DIR> <OUTPUT> [<DEPFILE>]" > exit 1 > fi > > @@ -36,3 +37,11 @@ print_config_list () { > echo > print_config_list > } >"$OUTPUT" > + > +if test -n "$DEPFILE" > +then > + QUOTED_OUTPUT="$(printf '%s\n' "$OUTPUT" | sed 's,[&/\],\\&,g')" > + printf '%s\n' "$SOURCE_DIR"/Documentation/*config.adoc \ > + "$SOURCE_DIR"/Documentation/config/*.adoc | > + sed -e 's/[# ]/\\&/g' -e "s/^/$QUOTED_OUTPUT: /" >"$DEPFILE" > +fi > diff --git a/meson.build b/meson.build > index 762e2d0fc0..74b459b004 100644 > --- a/meson.build > +++ b/meson.build > @@ -720,11 +720,14 @@ endif > > builtin_sources += custom_target( > output: 'config-list.h', > + depfile: 'config-list.h.d', > + depend_files: [ 'generate-configlist.sh' ], > command: [ > shell, > - meson.current_source_dir() + '/generate-configlist.sh', > + meson.current_source_dir() / 'generate-configlist.sh', > meson.current_source_dir(), > '@OUTPUT@', > + '@DEPFILE@', > ], > env: script_environment, > ) > > Diff-intervalle contre v5 : > 1: 611a94cd98 ! 1: 5dcd4e9308 build: regenerate config-list.h when Documentation changes > @@ Commit message > it, t9902-completion.sh fails. Regenerating the config-list.h artifact > from sources fixes the artifact and the test. > > - Teach the meson build to depend on the Documentation files that > - generate-configlist.sh reads by having it an additional output as a list > - of dependency files, since Meson does not have (or want) builtin support > - for globbing like Make. We assume that if a user adds a new file under > + Since Meson does not have (or want) builtin support for globbing like > + Make, teach generate-configlist.sh to also generate a list of > + Documentation files its output depends on, and incorporate that into the > + Meson build. > + > + We assume that if a user adds a new file under > Documentation/config then they will also edit one of the existing files > to include that new file, and that will trigger a rebuild. Also mark the > generator script as a dependency. > @@ Commit message > > > ## Notes (benknoble/commits) ## > - Changes from v4 (<9cdcc9de04f0f8fff657f0474b31c063466ed808.1771280837.git.ben.knoble+github@gmail.com>): > + Changes from v5 (<611a94cd988e3795bc63dba2f1b270aa0d058bd2.1771425395.git.ben.knoble+github@gmail.com>): > > - • Include Patrick's suggested Makefile changes. Note there's no quiet > - equivalent for mdkir that isn't for the current target's containing > - directory… > - • Make depfile output efficient again, thanks to Phillip. > - > - I've kept printf instead of echo (from Patrick/Junio) because I think it > - is easier to reason about ("it works" vs. "did I use this in a way that > - might cause problems"). > - > - Junio asked about other problematic bytes: the other one I could think > - of (since all the inputs should be paths, anyway) is newlines. I gave > - meson's depfile.py a glance [1], and it looks like they don't handle > - newlines in paths. Other whitespace doesn't appear to be an issue (see > - "elif c in {' ', '\n'}"); I think _most_ characters are just added to > - the filename. > - > - [1]: https://github.com/mesonbuild/meson/blob/master/mesonbuild/depfile.py > + • Reword a confusing sentence in the commit message > > ## Makefile ## > @@ Makefile: $(BUILT_INS): git$X > > base-commit: 4a7958ca1415077ce9b1d0a38223ede55da779d9 > -- > 2.53.0 > ^ permalink raw reply [flat|nested] 46+ messages in thread
* Re: [PATCH v6] build: regenerate config-list.h when Documentation changes 2026-02-23 6:55 ` SZEDER Gábor @ 2026-02-23 21:41 ` Ben Knoble 2026-02-24 9:58 ` Patrick Steinhardt 0 siblings, 1 reply; 46+ messages in thread From: Ben Knoble @ 2026-02-23 21:41 UTC (permalink / raw) To: SZEDER Gábor Cc: D. Ben Knoble, git, Phillip Wood, Patrick Steinhardt, Marc Branchaud, Evan Martin, brian m. carlson, Junio C Hamano > Le 23 févr. 2026 à 01:55, SZEDER Gábor <szeder.dev@gmail.com> a écrit : > > On Sat, Feb 21, 2026 at 09:07:17AM -0500, D. Ben Knoble wrote: >> The Meson-based build doesn't know when to rebuild config-list.h, so the >> header is sometimes stale. >> >> For example, an old build directory might have config-list.h from before >> 4173df5187 (submodule: introduce extensions.submodulePathConfig, >> 2026-01-12), which added submodule.<name>.gitdir to the list. Without >> it, t9902-completion.sh fails. Regenerating the config-list.h artifact >> from sources fixes the artifact and the test. >> >> Since Meson does not have (or want) builtin support for globbing like >> Make, teach generate-configlist.sh to also generate a list of >> Documentation files its output depends on, and incorporate that into the >> Meson build. >> >> We assume that if a user adds a new file under >> Documentation/config then they will also edit one of the existing files >> to include that new file, and that will trigger a rebuild. Also mark the >> generator script as a dependency. >> >> While we're at it, teach the Makefile to use the same "the script knows >> it's dependencies" logic. >> >> For Meson, combining the following commands helps debug dependencies: >> >> ninja -C <builddir> -t deps config-list.h >> ninja -C <builddir> -t browse config-list.h >> >> The former lists all the dependencies discovered from our output ".d" >> file (the config documentation) and the latter shows the dependency on >> the script itself, among other useful edges in the dependency graph. >> >> Helped-by: Patrick Steinhardt <ps@pks.im> >> Helped-by: Phillip Wood <phillip.wood@dunelm.org.uk> >> Signed-off-by: D. Ben Knoble <ben.knoble+github@gmail.com> >> --- >> >> Notes (benknoble/commits): >> Changes from v5 (<611a94cd988e3795bc63dba2f1b270aa0d058bd2.1771425395.git.ben.knoble+github@gmail.com>): >> >> • Reword a confusing sentence in the commit message >> >> Makefile | 5 +++-- >> generate-configlist.sh | 11 ++++++++++- >> meson.build | 5 ++++- >> 3 files changed, 17 insertions(+), 4 deletions(-) >> >> diff --git a/Makefile b/Makefile >> index 7f37ad8f58..6f926ffb1f 100644 >> --- a/Makefile >> +++ b/Makefile >> @@ -2688,9 +2688,10 @@ $(BUILT_INS): git$X >> cp $< $@ >> >> config-list.h: generate-configlist.sh >> + @mkdir -p .depend >> + $(QUIET_GEN)$(SHELL_PATH) ./generate-configlist.sh . $@ .depend/config-list.h.d >> >> -config-list.h: Documentation/*config.adoc Documentation/config/*.adoc >> - $(QUIET_GEN)$(SHELL_PATH) ./generate-configlist.sh . $@ >> +-include .depend/config-list.h.d > > This breaks the build when something disappears from > Documentation/config/: > > $ git checkout origin/seen > HEAD is now at 57edfa3ce8 Merge branch 'ty/setup-error-tightening' into seen > $ ls -l Documentation/config/hook.adoc > -rw-rw-r-- 1 szeder szeder 3828 Feb 23 07:50 Documentation/config/hook.adoc > $ git grep hook.adoc > Documentation/git-hook.adoc:include::config/hook.adoc[] > Documentation/howto/meson.build: 'rebuild-from-update-hook.adoc', > Documentation/meson.build: 'git-hook.adoc' : 1, > $ make V=1 config-list.h > /bin/sh ./generate-configlist.sh . config-list.h .depend/config-list.h.d > $ git checkout 0aabf70f60 > Previous HEAD position was 57edfa3ce8 Merge branch 'ty/setup-error-tightening' into seen > HEAD is now at 0aabf70f60 build: regenerate config-list.h when Documentation changes > $ ls -l Documentation/config/hook.adoc > ls: cannot access 'Documentation/config/hook.adoc': No such file or directory > $ git grep hook.adoc > Documentation/howto/meson.build: 'rebuild-from-update-hook.adoc', > Documentation/meson.build: 'git-hook.adoc' : 1, > $ make V=1 config-list.h > GIT_VERSION=2.53.0.119.g0aabf70f60 > make: *** No rule to make target 'Documentation/config/hook.adoc', needed by 'config-list.h'. Stop. > $ grep hook.adoc .depend/config-list.h.d > config-list.h: ./Documentation/config/hook.adoc Indeed. This might arise while bisecting, which was my original motivation. Thoughts on a path forward? At least this issue (to me) is clearer than a spurious test failure :) ^ permalink raw reply [flat|nested] 46+ messages in thread
* Re: [PATCH v6] build: regenerate config-list.h when Documentation changes 2026-02-23 21:41 ` Ben Knoble @ 2026-02-24 9:58 ` Patrick Steinhardt 2026-02-24 11:00 ` Phillip Wood 0 siblings, 1 reply; 46+ messages in thread From: Patrick Steinhardt @ 2026-02-24 9:58 UTC (permalink / raw) To: Ben Knoble Cc: SZEDER Gábor, D. Ben Knoble, git, Phillip Wood, Marc Branchaud, Evan Martin, brian m. carlson, Junio C Hamano On Mon, Feb 23, 2026 at 04:41:48PM -0500, Ben Knoble wrote: > > Le 23 févr. 2026 à 01:55, SZEDER Gábor <szeder.dev@gmail.com> a écrit : > > On Sat, Feb 21, 2026 at 09:07:17AM -0500, D. Ben Knoble wrote: > >> diff --git a/Makefile b/Makefile > >> index 7f37ad8f58..6f926ffb1f 100644 > >> --- a/Makefile > >> +++ b/Makefile > >> @@ -2688,9 +2688,10 @@ $(BUILT_INS): git$X > >> cp $< $@ > >> > >> config-list.h: generate-configlist.sh > >> + @mkdir -p .depend > >> + $(QUIET_GEN)$(SHELL_PATH) ./generate-configlist.sh . $@ .depend/config-list.h.d > >> > >> -config-list.h: Documentation/*config.adoc Documentation/config/*.adoc > >> - $(QUIET_GEN)$(SHELL_PATH) ./generate-configlist.sh . $@ > >> +-include .depend/config-list.h.d > > > > This breaks the build when something disappears from > > Documentation/config/: > > > > $ git checkout origin/seen > > HEAD is now at 57edfa3ce8 Merge branch 'ty/setup-error-tightening' into seen > > $ ls -l Documentation/config/hook.adoc > > -rw-rw-r-- 1 szeder szeder 3828 Feb 23 07:50 Documentation/config/hook.adoc > > $ git grep hook.adoc > > Documentation/git-hook.adoc:include::config/hook.adoc[] > > Documentation/howto/meson.build: 'rebuild-from-update-hook.adoc', > > Documentation/meson.build: 'git-hook.adoc' : 1, > > $ make V=1 config-list.h > > /bin/sh ./generate-configlist.sh . config-list.h .depend/config-list.h.d > > $ git checkout 0aabf70f60 > > Previous HEAD position was 57edfa3ce8 Merge branch 'ty/setup-error-tightening' into seen > > HEAD is now at 0aabf70f60 build: regenerate config-list.h when Documentation changes > > $ ls -l Documentation/config/hook.adoc > > ls: cannot access 'Documentation/config/hook.adoc': No such file or directory > > $ git grep hook.adoc > > Documentation/howto/meson.build: 'rebuild-from-update-hook.adoc', > > Documentation/meson.build: 'git-hook.adoc' : 1, > > $ make V=1 config-list.h > > GIT_VERSION=2.53.0.119.g0aabf70f60 > > make: *** No rule to make target 'Documentation/config/hook.adoc', needed by 'config-list.h'. Stop. > > $ grep hook.adoc .depend/config-list.h.d > > config-list.h: ./Documentation/config/hook.adoc > > Indeed. This might arise while bisecting, which was my original > motivation. Thoughts on a path forward? At least this issue (to me) is > clearer than a spurious test failure :) For Meson this case works alright. So maybe we just drop the changes to the Makefile and call it a day? An alternative would be to have the following patch on top: diff --git a/generate-configlist.sh b/generate-configlist.sh index 39ac8845ab..e28054f9e0 100755 --- a/generate-configlist.sh +++ b/generate-configlist.sh @@ -41,7 +41,12 @@ EOF if test -n "$DEPFILE" then QUOTED_OUTPUT="$(printf '%s\n' "$OUTPUT" | sed 's,[&/\],\\&,g')" - printf '%s\n' "$SOURCE_DIR"/Documentation/*config.adoc \ - "$SOURCE_DIR"/Documentation/config/*.adoc | - sed -e 's/[# ]/\\&/g' -e "s/^/$QUOTED_OUTPUT: /" >"$DEPFILE" + { + printf '%s\n' "$SOURCE_DIR"/Documentation/*config.adoc \ + "$SOURCE_DIR"/Documentation/config/*.adoc | + sed -e 's/[# ]/\\&/g' -e "s/^/$QUOTED_OUTPUT: /" + printf '%s:\n' "$SOURCE_DIR"/Documentation/*config.adoc \ + "$SOURCE_DIR"/Documentation/config/*.adoc | + sed -e 's/[# ]/\\&/g' + } >"$DEPFILE" fi What it does is to also create an empty target for all of the dependencies. Which is in fact what GCC/Clang also do when you pass -MP: $ cat main.c #include "foo.h" int main() { puts("foobar"); return 0; } $ clang -MMD -MP main.c $ cat main.d main.o: main.c foo.h foo.h: Patrick ^ permalink raw reply related [flat|nested] 46+ messages in thread
* Re: [PATCH v6] build: regenerate config-list.h when Documentation changes 2026-02-24 9:58 ` Patrick Steinhardt @ 2026-02-24 11:00 ` Phillip Wood 2026-02-24 14:12 ` D. Ben Knoble 0 siblings, 1 reply; 46+ messages in thread From: Phillip Wood @ 2026-02-24 11:00 UTC (permalink / raw) To: Patrick Steinhardt, Ben Knoble Cc: SZEDER Gábor, D. Ben Knoble, git, Phillip Wood, Marc Branchaud, Evan Martin, brian m. carlson, Junio C Hamano On 24/02/2026 09:58, Patrick Steinhardt wrote: > On Mon, Feb 23, 2026 at 04:41:48PM -0500, Ben Knoble wrote: >>> Le 23 févr. 2026 à 01:55, SZEDER Gábor <szeder.dev@gmail.com> a écrit : >>> On Sat, Feb 21, 2026 at 09:07:17AM -0500, D. Ben Knoble wrote: >>>> diff --git a/Makefile b/Makefile >>>> index 7f37ad8f58..6f926ffb1f 100644 >>>> --- a/Makefile >>>> +++ b/Makefile >>>> @@ -2688,9 +2688,10 @@ $(BUILT_INS): git$X >>>> cp $< $@ >>>> >>>> config-list.h: generate-configlist.sh >>>> + @mkdir -p .depend >>>> + $(QUIET_GEN)$(SHELL_PATH) ./generate-configlist.sh . $@ .depend/config-list.h.d >>>> >>>> -config-list.h: Documentation/*config.adoc Documentation/config/*.adoc >>>> - $(QUIET_GEN)$(SHELL_PATH) ./generate-configlist.sh . $@ >>>> +-include .depend/config-list.h.d >>> >>> This breaks the build when something disappears from >>> Documentation/config/: >>> >>> $ git checkout origin/seen >>> HEAD is now at 57edfa3ce8 Merge branch 'ty/setup-error-tightening' into seen >>> $ ls -l Documentation/config/hook.adoc >>> -rw-rw-r-- 1 szeder szeder 3828 Feb 23 07:50 Documentation/config/hook.adoc >>> $ git grep hook.adoc >>> Documentation/git-hook.adoc:include::config/hook.adoc[] >>> Documentation/howto/meson.build: 'rebuild-from-update-hook.adoc', >>> Documentation/meson.build: 'git-hook.adoc' : 1, >>> $ make V=1 config-list.h >>> /bin/sh ./generate-configlist.sh . config-list.h .depend/config-list.h.d >>> $ git checkout 0aabf70f60 >>> Previous HEAD position was 57edfa3ce8 Merge branch 'ty/setup-error-tightening' into seen >>> HEAD is now at 0aabf70f60 build: regenerate config-list.h when Documentation changes >>> $ ls -l Documentation/config/hook.adoc >>> ls: cannot access 'Documentation/config/hook.adoc': No such file or directory >>> $ git grep hook.adoc >>> Documentation/howto/meson.build: 'rebuild-from-update-hook.adoc', >>> Documentation/meson.build: 'git-hook.adoc' : 1, >>> $ make V=1 config-list.h >>> GIT_VERSION=2.53.0.119.g0aabf70f60 >>> make: *** No rule to make target 'Documentation/config/hook.adoc', needed by 'config-list.h'. Stop. >>> $ grep hook.adoc .depend/config-list.h.d >>> config-list.h: ./Documentation/config/hook.adoc >> >> Indeed. This might arise while bisecting, which was my original >> motivation. Thoughts on a path forward? At least this issue (to me) is >> clearer than a spurious test failure :) > > For Meson this case works alright. So maybe we just drop the changes to > the Makefile and call it a day? > > An alternative would be to have the following patch on top: > > diff --git a/generate-configlist.sh b/generate-configlist.sh > index 39ac8845ab..e28054f9e0 100755 > --- a/generate-configlist.sh > +++ b/generate-configlist.sh > @@ -41,7 +41,12 @@ EOF > if test -n "$DEPFILE" > then > QUOTED_OUTPUT="$(printf '%s\n' "$OUTPUT" | sed 's,[&/\],\\&,g')" > - printf '%s\n' "$SOURCE_DIR"/Documentation/*config.adoc \ > - "$SOURCE_DIR"/Documentation/config/*.adoc | > - sed -e 's/[# ]/\\&/g' -e "s/^/$QUOTED_OUTPUT: /" >"$DEPFILE" > + { > + printf '%s\n' "$SOURCE_DIR"/Documentation/*config.adoc \ > + "$SOURCE_DIR"/Documentation/config/*.adoc | > + sed -e 's/[# ]/\\&/g' -e "s/^/$QUOTED_OUTPUT: /" > + printf '%s:\n' "$SOURCE_DIR"/Documentation/*config.adoc \ > + "$SOURCE_DIR"/Documentation/config/*.adoc | > + sed -e 's/[# ]/\\&/g' > + } >"$DEPFILE" > fi > > What it does is to also create an empty target for all of the > dependencies. Which is in fact what GCC/Clang also do when you pass -MP: Oh, I was wondering how they got around the problem we're seeing here. While it seems ninja is happy it ignore missing dependencies in depfiles, are we sure the build systems meson uses on other platforms are as well? If not it might be worth adding this, rather than just dropping the Makefile changes. Thanks Phillip > > $ cat main.c > #include "foo.h" > int main() > { > puts("foobar"); > return 0; > } > > $ clang -MMD -MP main.c > $ cat main.d > main.o: main.c foo.h > foo.h: > > Patrick ^ permalink raw reply [flat|nested] 46+ messages in thread
* Re: [PATCH v6] build: regenerate config-list.h when Documentation changes 2026-02-24 11:00 ` Phillip Wood @ 2026-02-24 14:12 ` D. Ben Knoble 0 siblings, 0 replies; 46+ messages in thread From: D. Ben Knoble @ 2026-02-24 14:12 UTC (permalink / raw) To: phillip.wood Cc: Patrick Steinhardt, SZEDER Gábor, git, Marc Branchaud, Evan Martin, brian m. carlson, Junio C Hamano On Tue, Feb 24, 2026 at 6:00 AM Phillip Wood <phillip.wood123@gmail.com> wrote: > > > > On 24/02/2026 09:58, Patrick Steinhardt wrote: > > On Mon, Feb 23, 2026 at 04:41:48PM -0500, Ben Knoble wrote: > >>> Le 23 févr. 2026 à 01:55, SZEDER Gábor <szeder.dev@gmail.com> a écrit : > >>> On Sat, Feb 21, 2026 at 09:07:17AM -0500, D. Ben Knoble wrote: > >>>> diff --git a/Makefile b/Makefile > >>>> index 7f37ad8f58..6f926ffb1f 100644 > >>>> --- a/Makefile > >>>> +++ b/Makefile > >>>> @@ -2688,9 +2688,10 @@ $(BUILT_INS): git$X > >>>> cp $< $@ > >>>> > >>>> config-list.h: generate-configlist.sh > >>>> + @mkdir -p .depend > >>>> + $(QUIET_GEN)$(SHELL_PATH) ./generate-configlist.sh . $@ .depend/config-list.h.d > >>>> > >>>> -config-list.h: Documentation/*config.adoc Documentation/config/*.adoc > >>>> - $(QUIET_GEN)$(SHELL_PATH) ./generate-configlist.sh . $@ > >>>> +-include .depend/config-list.h.d > >>> > >>> This breaks the build when something disappears from > >>> Documentation/config/: > >>> > >>> $ git checkout origin/seen > >>> HEAD is now at 57edfa3ce8 Merge branch 'ty/setup-error-tightening' into seen > >>> $ ls -l Documentation/config/hook.adoc > >>> -rw-rw-r-- 1 szeder szeder 3828 Feb 23 07:50 Documentation/config/hook.adoc > >>> $ git grep hook.adoc > >>> Documentation/git-hook.adoc:include::config/hook.adoc[] > >>> Documentation/howto/meson.build: 'rebuild-from-update-hook.adoc', > >>> Documentation/meson.build: 'git-hook.adoc' : 1, > >>> $ make V=1 config-list.h > >>> /bin/sh ./generate-configlist.sh . config-list.h .depend/config-list.h.d > >>> $ git checkout 0aabf70f60 > >>> Previous HEAD position was 57edfa3ce8 Merge branch 'ty/setup-error-tightening' into seen > >>> HEAD is now at 0aabf70f60 build: regenerate config-list.h when Documentation changes > >>> $ ls -l Documentation/config/hook.adoc > >>> ls: cannot access 'Documentation/config/hook.adoc': No such file or directory > >>> $ git grep hook.adoc > >>> Documentation/howto/meson.build: 'rebuild-from-update-hook.adoc', > >>> Documentation/meson.build: 'git-hook.adoc' : 1, > >>> $ make V=1 config-list.h > >>> GIT_VERSION=2.53.0.119.g0aabf70f60 > >>> make: *** No rule to make target 'Documentation/config/hook.adoc', needed by 'config-list.h'. Stop. > >>> $ grep hook.adoc .depend/config-list.h.d > >>> config-list.h: ./Documentation/config/hook.adoc > >> > >> Indeed. This might arise while bisecting, which was my original > >> motivation. Thoughts on a path forward? At least this issue (to me) is > >> clearer than a spurious test failure :) > > > > For Meson this case works alright. So maybe we just drop the changes to > > the Makefile and call it a day? > > > > An alternative would be to have the following patch on top: > > > > diff --git a/generate-configlist.sh b/generate-configlist.sh > > index 39ac8845ab..e28054f9e0 100755 > > --- a/generate-configlist.sh > > +++ b/generate-configlist.sh > > @@ -41,7 +41,12 @@ EOF > > if test -n "$DEPFILE" > > then > > QUOTED_OUTPUT="$(printf '%s\n' "$OUTPUT" | sed 's,[&/\],\\&,g')" > > - printf '%s\n' "$SOURCE_DIR"/Documentation/*config.adoc \ > > - "$SOURCE_DIR"/Documentation/config/*.adoc | > > - sed -e 's/[# ]/\\&/g' -e "s/^/$QUOTED_OUTPUT: /" >"$DEPFILE" > > + { > > + printf '%s\n' "$SOURCE_DIR"/Documentation/*config.adoc \ > > + "$SOURCE_DIR"/Documentation/config/*.adoc | > > + sed -e 's/[# ]/\\&/g' -e "s/^/$QUOTED_OUTPUT: /" > > + printf '%s:\n' "$SOURCE_DIR"/Documentation/*config.adoc \ > > + "$SOURCE_DIR"/Documentation/config/*.adoc | > > + sed -e 's/[# ]/\\&/g' > > + } >"$DEPFILE" > > fi > > > > What it does is to also create an empty target for all of the > > dependencies. Which is in fact what GCC/Clang also do when you pass -MP: > > Oh, I was wondering how they got around the problem we're seeing here. > While it seems ninja is happy it ignore missing dependencies in > depfiles, are we sure the build systems meson uses on other platforms > are as well? If not it might be worth adding this, rather than just > dropping the Makefile changes. > > Thanks > > Phillip > > > > > $ cat main.c > > #include "foo.h" > > int main() > > { > > puts("foobar"); > > return 0; > > } > > > > $ clang -MMD -MP main.c > > $ cat main.d > > main.o: main.c foo.h > > foo.h: > > > > Patrick Yep, I agree with Phillip: I have a feeling Meson intends folks to produce output like GCC/Clang do, so let's honor that (even if it's not well-documented IMO). Will add. -- D. Ben Knoble ^ permalink raw reply [flat|nested] 46+ messages in thread
* [PATCH v7] build: regenerate config-list.h when Documentation changes 2026-02-21 14:07 ` [PATCH v6] " D. Ben Knoble 2026-02-23 6:37 ` Patrick Steinhardt 2026-02-23 6:55 ` SZEDER Gábor @ 2026-02-24 14:39 ` D. Ben Knoble 2026-02-25 18:45 ` Junio C Hamano 2 siblings, 1 reply; 46+ messages in thread From: D. Ben Knoble @ 2026-02-24 14:39 UTC (permalink / raw) To: git Cc: D. Ben Knoble, Phillip Wood, Patrick Steinhardt, Marc Branchaud, SZEDER Gábor, Evan Martin, brian m. carlson, Junio C Hamano The Meson-based build doesn't know when to rebuild config-list.h, so the header is sometimes stale. For example, an old build directory might have config-list.h from before 4173df5187 (submodule: introduce extensions.submodulePathConfig, 2026-01-12), which added submodule.<name>.gitdir to the list. Without it, t9902-completion.sh fails. Regenerating the config-list.h artifact from sources fixes the artifact and the test. Since Meson does not have (or want) builtin support for globbing like Make, teach generate-configlist.sh to also generate a list of Documentation files its output depends on, and incorporate that into the Meson build. We honor the undocumented GCC/Clang contract of outputting empty targets for all the dependencies (like they do with -MP). That is, generate lines like build/config-list.h: $SOURCE_DIR/Documentation/config.adoc $SOURCE_DIR/Documentation/config.adoc: We assume that if a user adds a new file under Documentation/config then they will also edit one of the existing files to include that new file, and that will trigger a rebuild. Also mark the generator script as a dependency. While we're at it, teach the Makefile to use the same "the script knows it's dependencies" logic. For Meson, combining the following commands helps debug dependencies: ninja -C <builddir> -t deps config-list.h ninja -C <builddir> -t browse config-list.h The former lists all the dependencies discovered from our output ".d" file (the config documentation) and the latter shows the dependency on the script itself, among other useful edges in the dependency graph. Helped-by: Patrick Steinhardt <ps@pks.im> Helped-by: Phillip Wood <phillip.wood@dunelm.org.uk> Signed-off-by: D. Ben Knoble <ben.knoble+github@gmail.com> --- Notes (benknoble/commits): Changes from v6 (<5dcd4e9308100a25603c50fecb36447c0ee4df62.1771682788.git.ben.knoble+github@gmail.com>): • Fix Make-based builds when a dependency is removed by generating the expected empty targets. (Thanks to a report from Szeder Gábor.) Makefile | 5 +++-- generate-configlist.sh | 16 +++++++++++++++- meson.build | 5 ++++- 3 files changed, 22 insertions(+), 4 deletions(-) diff --git a/Makefile b/Makefile index 7f37ad8f58..6f926ffb1f 100644 --- a/Makefile +++ b/Makefile @@ -2688,9 +2688,10 @@ $(BUILT_INS): git$X cp $< $@ config-list.h: generate-configlist.sh + @mkdir -p .depend + $(QUIET_GEN)$(SHELL_PATH) ./generate-configlist.sh . $@ .depend/config-list.h.d -config-list.h: Documentation/*config.adoc Documentation/config/*.adoc - $(QUIET_GEN)$(SHELL_PATH) ./generate-configlist.sh . $@ +-include .depend/config-list.h.d command-list.h: generate-cmdlist.sh command-list.txt diff --git a/generate-configlist.sh b/generate-configlist.sh index 75c39ade20..e28054f9e0 100755 --- a/generate-configlist.sh +++ b/generate-configlist.sh @@ -2,10 +2,11 @@ SOURCE_DIR="$1" OUTPUT="$2" +DEPFILE="$3" if test -z "$SOURCE_DIR" || ! test -d "$SOURCE_DIR" || test -z "$OUTPUT" then - echo >&2 "USAGE: $0 <SOURCE_DIR> <OUTPUT>" + echo >&2 "USAGE: $0 <SOURCE_DIR> <OUTPUT> [<DEPFILE>]" exit 1 fi @@ -36,3 +37,16 @@ print_config_list () { echo print_config_list } >"$OUTPUT" + +if test -n "$DEPFILE" +then + QUOTED_OUTPUT="$(printf '%s\n' "$OUTPUT" | sed 's,[&/\],\\&,g')" + { + printf '%s\n' "$SOURCE_DIR"/Documentation/*config.adoc \ + "$SOURCE_DIR"/Documentation/config/*.adoc | + sed -e 's/[# ]/\\&/g' -e "s/^/$QUOTED_OUTPUT: /" + printf '%s:\n' "$SOURCE_DIR"/Documentation/*config.adoc \ + "$SOURCE_DIR"/Documentation/config/*.adoc | + sed -e 's/[# ]/\\&/g' + } >"$DEPFILE" +fi diff --git a/meson.build b/meson.build index 6f155beafa..4b536e0124 100644 --- a/meson.build +++ b/meson.build @@ -722,11 +722,14 @@ endif builtin_sources += custom_target( output: 'config-list.h', + depfile: 'config-list.h.d', + depend_files: [ 'generate-configlist.sh' ], command: [ shell, - meson.current_source_dir() + '/generate-configlist.sh', + meson.current_source_dir() / 'generate-configlist.sh', meson.current_source_dir(), '@OUTPUT@', + '@DEPFILE@', ], env: script_environment, ) Diff-intervalle contre v6 : 1: 7ffbde5f8a ! 1: 4ef96c6bbf build: regenerate config-list.h when Documentation changes @@ Commit message Since Meson does not have (or want) builtin support for globbing like Make, teach generate-configlist.sh to also generate a list of Documentation files its output depends on, and incorporate that into the - Meson build. + Meson build. We honor the undocumented GCC/Clang contract of outputting + empty targets for all the dependencies (like they do with -MP). That is, + generate lines like + + build/config-list.h: $SOURCE_DIR/Documentation/config.adoc + $SOURCE_DIR/Documentation/config.adoc: We assume that if a user adds a new file under Documentation/config then they will also edit one of the existing files @@ Commit message ## Notes (benknoble/commits) ## - Changes from v5 (<611a94cd988e3795bc63dba2f1b270aa0d058bd2.1771425395.git.ben.knoble+github@gmail.com>): + Changes from v6 (<5dcd4e9308100a25603c50fecb36447c0ee4df62.1771682788.git.ben.knoble+github@gmail.com>): - • Reword a confusing sentence in the commit message + • Fix Make-based builds when a dependency is removed by generating the + expected empty targets. (Thanks to a report from Szeder Gábor.) ## Makefile ## @@ Makefile: $(BUILT_INS): git$X @@ generate-configlist.sh: print_config_list () { +if test -n "$DEPFILE" +then + QUOTED_OUTPUT="$(printf '%s\n' "$OUTPUT" | sed 's,[&/\],\\&,g')" -+ printf '%s\n' "$SOURCE_DIR"/Documentation/*config.adoc \ -+ "$SOURCE_DIR"/Documentation/config/*.adoc | -+ sed -e 's/[# ]/\\&/g' -e "s/^/$QUOTED_OUTPUT: /" >"$DEPFILE" ++ { ++ printf '%s\n' "$SOURCE_DIR"/Documentation/*config.adoc \ ++ "$SOURCE_DIR"/Documentation/config/*.adoc | ++ sed -e 's/[# ]/\\&/g' -e "s/^/$QUOTED_OUTPUT: /" ++ printf '%s:\n' "$SOURCE_DIR"/Documentation/*config.adoc \ ++ "$SOURCE_DIR"/Documentation/config/*.adoc | ++ sed -e 's/[# ]/\\&/g' ++ } >"$DEPFILE" +fi ## meson.build ## base-commit: 309c995771be952610fdcff99f7fea96934ce045 -- 2.53.0.537.g7ffbde5f8a.dirty ^ permalink raw reply related [flat|nested] 46+ messages in thread
* Re: [PATCH v7] build: regenerate config-list.h when Documentation changes 2026-02-24 14:39 ` [PATCH v7] " D. Ben Knoble @ 2026-02-25 18:45 ` Junio C Hamano 2026-02-26 3:20 ` Ben Knoble 0 siblings, 1 reply; 46+ messages in thread From: Junio C Hamano @ 2026-02-25 18:45 UTC (permalink / raw) To: D. Ben Knoble Cc: git, Phillip Wood, Patrick Steinhardt, Marc Branchaud, SZEDER Gábor, Evan Martin, brian m. carlson "D. Ben Knoble" <ben.knoble+github@gmail.com> writes: > The Meson-based build doesn't know when to rebuild config-list.h, so the > header is sometimes stale. > ... > Helped-by: Patrick Steinhardt <ps@pks.im> > Helped-by: Phillip Wood <phillip.wood@dunelm.org.uk> > Signed-off-by: D. Ben Knoble <ben.knoble+github@gmail.com> > --- > > Notes (benknoble/commits): > Changes from v6 (<5dcd4e9308100a25603c50fecb36447c0ee4df62.1771682788.git.ben.knoble+github@gmail.com>): > > • Fix Make-based builds when a dependency is removed by generating the > expected empty targets. (Thanks to a report from Szeder Gábor.) OK, now we are pretty much completed and ready to merge it down to 'next'? Let me mark it as such. Thanks. ^ permalink raw reply [flat|nested] 46+ messages in thread
* Re: [PATCH v7] build: regenerate config-list.h when Documentation changes 2026-02-25 18:45 ` Junio C Hamano @ 2026-02-26 3:20 ` Ben Knoble 0 siblings, 0 replies; 46+ messages in thread From: Ben Knoble @ 2026-02-26 3:20 UTC (permalink / raw) To: Junio C Hamano Cc: D. Ben Knoble, git, Phillip Wood, Patrick Steinhardt, Marc Branchaud, SZEDER Gábor, Evan Martin, brian m. carlson > Le 25 févr. 2026 à 13:45, Junio C Hamano <gitster@pobox.com> a écrit : > > "D. Ben Knoble" <ben.knoble+github@gmail.com> writes: > >> The Meson-based build doesn't know when to rebuild config-list.h, so the >> header is sometimes stale. >> ... >> Helped-by: Patrick Steinhardt <ps@pks.im> >> Helped-by: Phillip Wood <phillip.wood@dunelm.org.uk> >> Signed-off-by: D. Ben Knoble <ben.knoble+github@gmail.com> >> --- >> >> Notes (benknoble/commits): >> Changes from v6 (<5dcd4e9308100a25603c50fecb36447c0ee4df62.1771682788.git.ben.knoble+github@gmail.com>): >> >> • Fix Make-based builds when a dependency is removed by generating the >> expected empty targets. (Thanks to a report from Szeder Gábor.) > > OK, now we are pretty much completed and ready to merge it down to > 'next'? Let me mark it as such. > > Thanks. I certainly hope so. Thanks. Family are in town and new kittens come home Saturday, so replies may come slowly. But of course I will be responsive to lingering issues uncovered. ^ permalink raw reply [flat|nested] 46+ messages in thread
* Re: [PATCH] meson: regenerate config-list.h when Documentation changes 2026-02-07 21:59 [PATCH] meson: regenerate config-list.h when Documentation changes D. Ben Knoble 2026-02-07 22:38 ` Ben Knoble 2026-02-09 15:19 ` [PATCH v2] " D. Ben Knoble @ 2026-02-09 15:25 ` Patrick Steinhardt 2026-02-09 21:50 ` D. Ben Knoble 2 siblings, 1 reply; 46+ messages in thread From: Patrick Steinhardt @ 2026-02-09 15:25 UTC (permalink / raw) To: D. Ben Knoble; +Cc: git, Junio C Hamano, Evan Martin On Sat, Feb 07, 2026 at 04:59:17PM -0500, D. Ben Knoble wrote: > The Meson-based build doesn't know when to rebuild config-list.h, so the > header is sometimes stale. > > For example, an old build directory might have config-list.h from before > 4173df5187 (submodule: introduce extensions.submodulePathConfig, > 2026-01-12), which added submodule.<name>.gitdir to the list. Without > it, t9902-completion.sh fails. Regenerating the config-list.h artifact > from sources fixes the artifact and the test. > > Teach the meson build to depend on the Documentation files that > generate-configlist.sh reads by having it use the output of > generate-configlist-deps.sh as a list of dependency files, since Meson > does not have (or want) builtin support for globbing like Make. > > Signed-off-by: D. Ben Knoble <ben.knoble+github@gmail.com> > --- > > Notes (benknoble/commits): > I considered having generate-configlist.sh write its own dependency > list, which Meson also supports… idk though. Input welcome :) I think that would actually be the better approach, also because the list of files with `run_command()` would only be computed at setup time. I guess it could look something like the below patch -- please feel free to reuse it at will. Thanks! Patrick diff --git a/generate-configlist.sh b/generate-configlist.sh index 75c39ade20..2c93ffc58a 100755 --- a/generate-configlist.sh +++ b/generate-configlist.sh @@ -2,10 +2,11 @@ SOURCE_DIR="$1" OUTPUT="$2" +DEPFILE="$3" if test -z "$SOURCE_DIR" || ! test -d "$SOURCE_DIR" || test -z "$OUTPUT" then - echo >&2 "USAGE: $0 <SOURCE_DIR> <OUTPUT>" + echo >&2 "USAGE: $0 <SOURCE_DIR> <OUTPUT> [<DEPFILE>]" exit 1 fi @@ -36,3 +37,9 @@ EOF echo print_config_list } >"$OUTPUT" + +if test -n "$DEPFILE" +then + printf "$OUTPUT: %s\n" "$SOURCE_DIR"/Documentation/*config.adoc \ + "$SOURCE_DIR"/Documentation/config/*.adoc >"$DEPFILE" +fi diff --git a/meson.build b/meson.build index dd52efd1c8..03ad7a2152 100644 --- a/meson.build +++ b/meson.build @@ -718,11 +718,13 @@ endif builtin_sources += custom_target( output: 'config-list.h', + depfile: 'config-list.h.d', command: [ shell, - meson.current_source_dir() + '/generate-configlist.sh', + meson.current_source_dir() / 'generate-configlist.sh', meson.current_source_dir(), '@OUTPUT@', + meson.current_build_dir() / 'config-list.h.d', ], env: script_environment, ) ^ permalink raw reply related [flat|nested] 46+ messages in thread
* Re: [PATCH] meson: regenerate config-list.h when Documentation changes 2026-02-09 15:25 ` [PATCH] meson: " Patrick Steinhardt @ 2026-02-09 21:50 ` D. Ben Knoble 2026-02-11 7:42 ` Patrick Steinhardt 0 siblings, 1 reply; 46+ messages in thread From: D. Ben Knoble @ 2026-02-09 21:50 UTC (permalink / raw) To: git, Patrick Steinhardt; +Cc: D. Ben Knoble, Junio C Hamano, Evan Martin Hi Patrick, > On Sat, Feb 07, 2026 at 04:59:17PM -0500, D. Ben Knoble wrote: > > The Meson-based build doesn't know when to rebuild config-list.h, so the > > header is sometimes stale. > > > > For example, an old build directory might have config-list.h from before > > 4173df5187 (submodule: introduce extensions.submodulePathConfig, > > 2026-01-12), which added submodule.<name>.gitdir to the list. Without > > it, t9902-completion.sh fails. Regenerating the config-list.h artifact > > from sources fixes the artifact and the test. > > > > Teach the meson build to depend on the Documentation files that > > generate-configlist.sh reads by having it use the output of > > generate-configlist-deps.sh as a list of dependency files, since Meson > > does not have (or want) builtin support for globbing like Make. > > > > Signed-off-by: D. Ben Knoble <ben.knoble+github@gmail.com> > > --- > > > > Notes (benknoble/commits): > > I considered having generate-configlist.sh write its own dependency > > list, which Meson also supports… idk though. Input welcome :) > > I think that would actually be the better approach, also because the > list of files with `run_command()` would only be computed at setup time. Oh, interesting. I didn't consider that, but it seems that adding a new file doesn't cause the dependency list to get updated in my version. Good catch > I guess it could look something like the below patch -- please feel free > to reuse it at will. > > Thanks! > > Patrick [snip patch] I've applied this locally as so (tinkering since I saw the same symptoms below with your version): ---- 8< ---- diff --git c/generate-configlist.sh w/generate-configlist.sh index 75c39ade20..2c93ffc58a 100755 --- c/generate-configlist.sh +++ w/generate-configlist.sh @@ -2,10 +2,11 @@ SOURCE_DIR="$1" OUTPUT="$2" +DEPFILE="$3" if test -z "$SOURCE_DIR" || ! test -d "$SOURCE_DIR" || test -z "$OUTPUT" then - echo >&2 "USAGE: $0 <SOURCE_DIR> <OUTPUT>" + echo >&2 "USAGE: $0 <SOURCE_DIR> <OUTPUT> [<DEPFILE>]" exit 1 fi @@ -36,3 +37,9 @@ print_config_list () { echo print_config_list } >"$OUTPUT" + +if test -n "$DEPFILE" +then + printf "$OUTPUT: %s\n" "$SOURCE_DIR"/Documentation/*config.adoc \ + "$SOURCE_DIR"/Documentation/config/*.adoc >"$DEPFILE" +fi diff --git c/meson.build w/meson.build index 3a1d12caa4..fb5d7367f5 100644 --- c/meson.build +++ w/meson.build @@ -720,11 +720,13 @@ endif builtin_sources += custom_target( output: 'config-list.h', + depfile: 'config-list.h.d', command: [ shell, - meson.current_source_dir() + '/generate-configlist.sh', + meson.current_source_dir() / 'generate-configlist.sh', meson.current_source_dir(), '@OUTPUT@', + '@DEPFILE@', ], env: script_environment, ) ---- 8< ---- Only, things are behaving oddly. For example: λ meson setup build2 λ ninja -C build2 works fine, but λ ls -l build2/config* -rw-r--r-- 1 benknoble benknoble 17169 9 févr. 16:39 build2/config-list.h I don't see the dependency file. Further, re-building seems to get stuck (I get similar symptoms if I add or remove a relevant config.adoc file, but let's keep it simple for now): λ ninja -C build2 ninja: Entering directory `build2' [1/28] Generating GIT-VERSION-FILE with a custom command (wrapped by meson to set env) Of course, if I invoke the command myself, I can fix the build: λ grep generate-config build2/build.ninja COMMAND = /usr/bin/sh /home/benknoble/code/git/generate-configlist.sh /home/benknoble/code/git config-list.h config-list.h.d λ (cd build2 && ../generate-configlist.sh .. config-list.h config-list.h.d) λ ninja -C build2 ninja: Entering directory `build2' [7/7] Linking target git-upload-pack but I certainly wouldn't have expected to have to do that! Interestingly, after the "setup" step, build2/meson-info/intro-targets.json has this block { "name": "config-list.h", "id": "config-list.h@cus", "type": "custom", "defined_in": "/home/benknoble/code/git/meson.build", "filename": [ "/home/benknoble/code/git/build2/config-list.h" ], "build_by_default": false, "target_sources": [ { "language": "unknown", "compiler": [ "/usr/bin/sh", "/home/benknoble/code/git/generate-configlist.sh", "/home/benknoble/code/git", "@OUTPUT@", "@DEPFILE@" ], "parameters": [], "sources": [], "generated_sources": [] } ], "extra_files": [], "subproject": null, "dependencies": [], "depends": [], "installed": false }, which doesn't mention the .d file anywhere. The _only_ reference to it is build2/build.ninja. This doesn't change (nor are there more references to the generate-config script) that I can find inside build2/ after any of these steps, which is odd. I can't think of any good next debugging steps, so I'm open to ideas on this oddity. ^ permalink raw reply related [flat|nested] 46+ messages in thread
* Re: [PATCH] meson: regenerate config-list.h when Documentation changes 2026-02-09 21:50 ` D. Ben Knoble @ 2026-02-11 7:42 ` Patrick Steinhardt 2026-02-11 9:44 ` Phillip Wood 2026-02-11 19:58 ` D. Ben Knoble 0 siblings, 2 replies; 46+ messages in thread From: Patrick Steinhardt @ 2026-02-11 7:42 UTC (permalink / raw) To: D. Ben Knoble; +Cc: git, Junio C Hamano, Evan Martin On Mon, Feb 09, 2026 at 04:50:06PM -0500, D. Ben Knoble wrote: > > On Sat, Feb 07, 2026 at 04:59:17PM -0500, D. Ben Knoble wrote: [snip] > Only, things are behaving oddly. For example: > > λ meson setup build2 > λ ninja -C build2 > > works fine, but > > λ ls -l build2/config* > -rw-r--r-- 1 benknoble benknoble 17169 9 févr. 16:39 build2/config-list.h > > I don't see the dependency file. > Further, re-building seems to get stuck (I get > similar symptoms if I add or remove a relevant config.adoc file, but let's keep > it simple for now): > > λ ninja -C build2 > ninja: Entering directory `build2' > [1/28] Generating GIT-VERSION-FILE with a custom command (wrapped by meson to set env) With "stuck" you mean that it doesn't do anything, or that it doesn't actually rebuild? I guess it kind of makes sense that a new file wouldn't trigger a rebuild, even though I would have expected a removed one to trigger one. After all, the dependency file only tracks the set of _existing_ files so that we know when to rebuild, and of course the dependency file only gets regenerated in case any of those files changes. The thing is that build systems like Meson really want to know the list of files ahead of time so that they can have an optimal build graph. So we could of course list all the files that we actually depend on. But I guess that's something we want to avoid? There's another, alternative approach: you can have a separate build step that's marked as `build_always_stale: true` that lists all the config files. This step would then always run, and it would only update its target file in case any of the files has changed. Combined with the depfile we'd then rebuild in all cases: - When a file gets added or removed, as that would cause the `build_always_stale` target to be rewritten. - When any of the files changes, because that would cause the dependencies in the depfile to change. Something like the attached patch (note that I don't perform the necessary changes for the Makefile). I confirmed that it works for all of the above cases. Thanks! Patrick --- >8 --- diff --git a/generate-configlist.sh b/generate-configlist.sh index 75c39ade20..17605e6f77 100755 --- a/generate-configlist.sh +++ b/generate-configlist.sh @@ -1,13 +1,6 @@ #!/bin/sh -SOURCE_DIR="$1" -OUTPUT="$2" - -if test -z "$SOURCE_DIR" || ! test -d "$SOURCE_DIR" || test -z "$OUTPUT" -then - echo >&2 "USAGE: $0 <SOURCE_DIR> <OUTPUT>" - exit 1 -fi +set -e print_config_list () { cat <<EOF @@ -30,9 +23,50 @@ EOF EOF } -{ - echo "/* Automatically generated by generate-configlist.sh */" - echo - echo - print_config_list -} >"$OUTPUT" +case "$1" in +generate) + SOURCE_DIR="$2" + OUTPUT="$3" + DEPFILE="$4" + + if test -z "$SOURCE_DIR" || ! test -d "$SOURCE_DIR" || test -z "$OUTPUT" + then + echo >&2 "USAGE: $0 generate <SOURCE_DIR> <OUTPUT>" + exit 1 + fi + + if test -n "$DEPFILE" + then + printf "$OUTPUT: %s\n" "$SOURCE_DIR"/Documentation/*config.adoc \ + "$SOURCE_DIR"/Documentation/config/*.adoc >"$DEPFILE" + fi + + { + echo "/* Automatically generated by generate-configlist.sh */" + echo + echo + print_config_list + } >"$OUTPUT" + ;; +deps) + SOURCE_DIR="$2" + OUTPUT="$3" + + if test -z "$SOURCE_DIR" || ! test -d "$SOURCE_DIR" || test -z "$OUTPUT" + then + echo >&2 "USAGE: $0 deps <SOURCE_DIR> <OUTPUT>" + exit 1 + fi + + TMPFILE=$(mktemp "$OUTPUT".XXXXXX) + printf "%s\n" "$SOURCE_DIR"/Documentation/*config.adoc \ + "$SOURCE_DIR"/Documentation/config/*.adoc | sort >"$TMPFILE" + + if ! test -f "$OUTPUT" || ! cmp "$TMPFILE" "$OUTPUT" >/dev/null + then + mv "$TMPFILE" "$OUTPUT" + else + rm "$TMPFILE" + fi + ;; +esac diff --git a/meson.build b/meson.build index dd52efd1c8..6b9147a39a 100644 --- a/meson.build +++ b/meson.build @@ -716,14 +716,29 @@ if not get_option('breaking_changes') builtin_sources += 'builtin/pack-redundant.c' endif +configlist_deps = custom_target( + output: 'config-list.h.deps', + command: [ + meson.current_source_dir() + '/generate-configlist.sh', + 'deps', + meson.current_source_dir(), + '@OUTPUT@', + ], + build_always_stale: true, +) + builtin_sources += custom_target( output: 'config-list.h', command: [ shell, meson.current_source_dir() + '/generate-configlist.sh', + 'generate', meson.current_source_dir(), '@OUTPUT@', + '@OUTPUT@.d', ], + depends: [ configlist_deps, ], + depfile: 'config-list.h.d', env: script_environment, ) ^ permalink raw reply related [flat|nested] 46+ messages in thread
* Re: [PATCH] meson: regenerate config-list.h when Documentation changes 2026-02-11 7:42 ` Patrick Steinhardt @ 2026-02-11 9:44 ` Phillip Wood 2026-02-11 10:57 ` Phillip Wood 2026-02-11 10:58 ` Patrick Steinhardt 2026-02-11 19:58 ` D. Ben Knoble 1 sibling, 2 replies; 46+ messages in thread From: Phillip Wood @ 2026-02-11 9:44 UTC (permalink / raw) To: Patrick Steinhardt, D. Ben Knoble; +Cc: git, Junio C Hamano, Evan Martin On 11/02/2026 07:42, Patrick Steinhardt wrote: > On Mon, Feb 09, 2026 at 04:50:06PM -0500, D. Ben Knoble wrote: >>> On Sat, Feb 07, 2026 at 04:59:17PM -0500, D. Ben Knoble wrote: > [snip] >> Only, things are behaving oddly. For example: >> >> λ meson setup build2 >> λ ninja -C build2 >> >> works fine, but >> >> λ ls -l build2/config* >> -rw-r--r-- 1 benknoble benknoble 17169 9 févr. 16:39 build2/config-list.h >> >> I don't see the dependency file. > >> Further, re-building seems to get stuck (I get >> similar symptoms if I add or remove a relevant config.adoc file, but let's keep >> it simple for now): >> >> λ ninja -C build2 >> ninja: Entering directory `build2' >> [1/28] Generating GIT-VERSION-FILE with a custom command (wrapped by meson to set env) > > With "stuck" you mean that it doesn't do anything, or that it doesn't > actually rebuild? > > I guess it kind of makes sense that a new file wouldn't trigger a > rebuild, even though I would have expected a removed one to trigger one. > After all, the dependency file only tracks the set of _existing_ files > so that we know when to rebuild, and of course the dependency file only > gets regenerated in case any of those files changes. If anyone adds a new file under Documentation/config/ they will need to update Documentation/config.adoc which should then trigger the rebuild. That rebuld will then add the new file to the list of dependencies. If they remove a file we should pick that up with the dependencies that are already listed. Do we need to create the depfile when meson is setup? What does meson do when the depfile is missing? > The thing is that build systems like Meson really want to know the list > of files ahead of time so that they can have an optimal build graph. So > we could of course list all the files that we actually depend on. But I > guess that's something we want to avoid? > > There's another, alternative approach: you can have a separate build > step that's marked as `build_always_stale: true` that lists all the > config files. This step would then always run, and it would only update > its target file in case any of the files has changed. It would be really nice if we can avoid regenerating the depfile with every build. Thanks Phillip > Combined with the depfile we'd then rebuild in all cases: > > - When a file gets added or removed, as that would cause the > `build_always_stale` target to be rewritten. > > - When any of the files changes, because that would cause the > dependencies in the depfile to change. > > Something like the attached patch (note that I don't perform the > necessary changes for the Makefile). I confirmed that it works for all > of the above cases. > > Thanks! > > Patrick > > --- >8 --- > > diff --git a/generate-configlist.sh b/generate-configlist.sh > index 75c39ade20..17605e6f77 100755 > --- a/generate-configlist.sh > +++ b/generate-configlist.sh > @@ -1,13 +1,6 @@ > #!/bin/sh > > -SOURCE_DIR="$1" > -OUTPUT="$2" > - > -if test -z "$SOURCE_DIR" || ! test -d "$SOURCE_DIR" || test -z "$OUTPUT" > -then > - echo >&2 "USAGE: $0 <SOURCE_DIR> <OUTPUT>" > - exit 1 > -fi > +set -e > > print_config_list () { > cat <<EOF > @@ -30,9 +23,50 @@ EOF > EOF > } > > -{ > - echo "/* Automatically generated by generate-configlist.sh */" > - echo > - echo > - print_config_list > -} >"$OUTPUT" > +case "$1" in > +generate) > + SOURCE_DIR="$2" > + OUTPUT="$3" > + DEPFILE="$4" > + > + if test -z "$SOURCE_DIR" || ! test -d "$SOURCE_DIR" || test -z "$OUTPUT" > + then > + echo >&2 "USAGE: $0 generate <SOURCE_DIR> <OUTPUT>" > + exit 1 > + fi > + > + if test -n "$DEPFILE" > + then > + printf "$OUTPUT: %s\n" "$SOURCE_DIR"/Documentation/*config.adoc \ > + "$SOURCE_DIR"/Documentation/config/*.adoc >"$DEPFILE" > + fi > + > + { > + echo "/* Automatically generated by generate-configlist.sh */" > + echo > + echo > + print_config_list > + } >"$OUTPUT" > + ;; > +deps) > + SOURCE_DIR="$2" > + OUTPUT="$3" > + > + if test -z "$SOURCE_DIR" || ! test -d "$SOURCE_DIR" || test -z "$OUTPUT" > + then > + echo >&2 "USAGE: $0 deps <SOURCE_DIR> <OUTPUT>" > + exit 1 > + fi > + > + TMPFILE=$(mktemp "$OUTPUT".XXXXXX) > + printf "%s\n" "$SOURCE_DIR"/Documentation/*config.adoc \ > + "$SOURCE_DIR"/Documentation/config/*.adoc | sort >"$TMPFILE" > + > + if ! test -f "$OUTPUT" || ! cmp "$TMPFILE" "$OUTPUT" >/dev/null > + then > + mv "$TMPFILE" "$OUTPUT" > + else > + rm "$TMPFILE" > + fi > + ;; > +esac > diff --git a/meson.build b/meson.build > index dd52efd1c8..6b9147a39a 100644 > --- a/meson.build > +++ b/meson.build > @@ -716,14 +716,29 @@ if not get_option('breaking_changes') > builtin_sources += 'builtin/pack-redundant.c' > endif > > +configlist_deps = custom_target( > + output: 'config-list.h.deps', > + command: [ > + meson.current_source_dir() + '/generate-configlist.sh', > + 'deps', > + meson.current_source_dir(), > + '@OUTPUT@', > + ], > + build_always_stale: true, > +) > + > builtin_sources += custom_target( > output: 'config-list.h', > command: [ > shell, > meson.current_source_dir() + '/generate-configlist.sh', > + 'generate', > meson.current_source_dir(), > '@OUTPUT@', > + '@OUTPUT@.d', > ], > + depends: [ configlist_deps, ], > + depfile: 'config-list.h.d', > env: script_environment, > ) > > ^ permalink raw reply [flat|nested] 46+ messages in thread
* Re: [PATCH] meson: regenerate config-list.h when Documentation changes 2026-02-11 9:44 ` Phillip Wood @ 2026-02-11 10:57 ` Phillip Wood 2026-02-11 11:00 ` Patrick Steinhardt 2026-02-11 10:58 ` Patrick Steinhardt 1 sibling, 1 reply; 46+ messages in thread From: Phillip Wood @ 2026-02-11 10:57 UTC (permalink / raw) To: Patrick Steinhardt, D. Ben Knoble; +Cc: git, Junio C Hamano, Evan Martin On 11/02/2026 09:44, Phillip Wood wrote: > On 11/02/2026 07:42, Patrick Steinhardt wrote: >> On Mon, Feb 09, 2026 at 04:50:06PM -0500, D. Ben Knoble wrote: >>>> On Sat, Feb 07, 2026 at 04:59:17PM -0500, D. Ben Knoble wrote: >> [snip] >>> Only, things are behaving oddly. For example: >>> >>> λ meson setup build2 >>> λ ninja -C build2 >>> >>> works fine, but >>> >>> λ ls -l build2/config* >>> -rw-r--r-- 1 benknoble benknoble 17169 9 févr. 16:39 build2/ >>> config-list.h >>> >>> I don't see the dependency file. I've just had a play with this and I don't see the dependency file either - I wonder if ninja deletes it after it has read it. If I delete Documentation/config/add.adoc then config-list.h is rebuilt. However if I edit generate-configlist.sh it is not rebuilt - I guess we need to add the script to the dependency file. Thanks Phillip >>> Further, re-building seems to get stuck (I get >>> similar symptoms if I add or remove a relevant config.adoc file, but >>> let's keep >>> it simple for now): >>> >>> λ ninja -C build2 >>> ninja: Entering directory `build2' >>> [1/28] Generating GIT-VERSION-FILE with a custom command >>> (wrapped by meson to set env) >> >> With "stuck" you mean that it doesn't do anything, or that it doesn't >> actually rebuild? >> >> I guess it kind of makes sense that a new file wouldn't trigger a >> rebuild, even though I would have expected a removed one to trigger one. >> After all, the dependency file only tracks the set of _existing_ files >> so that we know when to rebuild, and of course the dependency file only >> gets regenerated in case any of those files changes. > > If anyone adds a new file under Documentation/config/ they will need to > update Documentation/config.adoc which should then trigger the rebuild. > That rebuld will then add the new file to the list of dependencies. If > they remove a file we should pick that up with the dependencies that are > already listed. > > Do we need to create the depfile when meson is setup? What does meson do > when the depfile is missing? > >> The thing is that build systems like Meson really want to know the list >> of files ahead of time so that they can have an optimal build graph. So >> we could of course list all the files that we actually depend on. But I >> guess that's something we want to avoid? >> >> There's another, alternative approach: you can have a separate build >> step that's marked as `build_always_stale: true` that lists all the >> config files. This step would then always run, and it would only update >> its target file in case any of the files has changed. > > It would be really nice if we can avoid regenerating the depfile with > every build. > > Thanks > > Phillip > >> Combined with the depfile we'd then rebuild in all cases: >> >> - When a file gets added or removed, as that would cause the >> `build_always_stale` target to be rewritten. >> >> - When any of the files changes, because that would cause the >> dependencies in the depfile to change. >> >> Something like the attached patch (note that I don't perform the >> necessary changes for the Makefile). I confirmed that it works for all >> of the above cases. >> >> Thanks! >> >> Patrick >> >> --- >8 --- >> >> diff --git a/generate-configlist.sh b/generate-configlist.sh >> index 75c39ade20..17605e6f77 100755 >> --- a/generate-configlist.sh >> +++ b/generate-configlist.sh >> @@ -1,13 +1,6 @@ >> #!/bin/sh >> -SOURCE_DIR="$1" >> -OUTPUT="$2" >> - >> -if test -z "$SOURCE_DIR" || ! test -d "$SOURCE_DIR" || test -z "$OUTPUT" >> -then >> - echo >&2 "USAGE: $0 <SOURCE_DIR> <OUTPUT>" >> - exit 1 >> -fi >> +set -e >> print_config_list () { >> cat <<EOF >> @@ -30,9 +23,50 @@ EOF >> EOF >> } >> -{ >> - echo "/* Automatically generated by generate-configlist.sh */" >> - echo >> - echo >> - print_config_list >> -} >"$OUTPUT" >> +case "$1" in >> +generate) >> + SOURCE_DIR="$2" >> + OUTPUT="$3" >> + DEPFILE="$4" >> + >> + if test -z "$SOURCE_DIR" || ! test -d "$SOURCE_DIR" || test -z >> "$OUTPUT" >> + then >> + echo >&2 "USAGE: $0 generate <SOURCE_DIR> <OUTPUT>" >> + exit 1 >> + fi >> + >> + if test -n "$DEPFILE" >> + then >> + printf "$OUTPUT: %s\n" "$SOURCE_DIR"/Documentation/ >> *config.adoc \ >> + "$SOURCE_DIR"/Documentation/config/*.adoc >"$DEPFILE" >> + fi >> + >> + { >> + echo "/* Automatically generated by generate-configlist.sh */" >> + echo >> + echo >> + print_config_list >> + } >"$OUTPUT" >> + ;; >> +deps) >> + SOURCE_DIR="$2" >> + OUTPUT="$3" >> + >> + if test -z "$SOURCE_DIR" || ! test -d "$SOURCE_DIR" || test -z >> "$OUTPUT" >> + then >> + echo >&2 "USAGE: $0 deps <SOURCE_DIR> <OUTPUT>" >> + exit 1 >> + fi >> + >> + TMPFILE=$(mktemp "$OUTPUT".XXXXXX) >> + printf "%s\n" "$SOURCE_DIR"/Documentation/*config.adoc \ >> + "$SOURCE_DIR"/Documentation/config/*.adoc | sort >"$TMPFILE" >> + >> + if ! test -f "$OUTPUT" || ! cmp "$TMPFILE" "$OUTPUT" >/dev/null >> + then >> + mv "$TMPFILE" "$OUTPUT" >> + else >> + rm "$TMPFILE" >> + fi >> + ;; >> +esac >> diff --git a/meson.build b/meson.build >> index dd52efd1c8..6b9147a39a 100644 >> --- a/meson.build >> +++ b/meson.build >> @@ -716,14 +716,29 @@ if not get_option('breaking_changes') >> builtin_sources += 'builtin/pack-redundant.c' >> endif >> +configlist_deps = custom_target( >> + output: 'config-list.h.deps', >> + command: [ >> + meson.current_source_dir() + '/generate-configlist.sh', >> + 'deps', >> + meson.current_source_dir(), >> + '@OUTPUT@', >> + ], >> + build_always_stale: true, >> +) >> + >> builtin_sources += custom_target( >> output: 'config-list.h', >> command: [ >> shell, >> meson.current_source_dir() + '/generate-configlist.sh', >> + 'generate', >> meson.current_source_dir(), >> '@OUTPUT@', >> + '@OUTPUT@.d', >> ], >> + depends: [ configlist_deps, ], >> + depfile: 'config-list.h.d', >> env: script_environment, >> ) >> > ^ permalink raw reply [flat|nested] 46+ messages in thread
* Re: [PATCH] meson: regenerate config-list.h when Documentation changes 2026-02-11 10:57 ` Phillip Wood @ 2026-02-11 11:00 ` Patrick Steinhardt 0 siblings, 0 replies; 46+ messages in thread From: Patrick Steinhardt @ 2026-02-11 11:00 UTC (permalink / raw) To: phillip.wood; +Cc: D. Ben Knoble, git, Junio C Hamano, Evan Martin On Wed, Feb 11, 2026 at 10:57:10AM +0000, Phillip Wood wrote: > On 11/02/2026 09:44, Phillip Wood wrote: > > On 11/02/2026 07:42, Patrick Steinhardt wrote: > > > On Mon, Feb 09, 2026 at 04:50:06PM -0500, D. Ben Knoble wrote: > > > > > On Sat, Feb 07, 2026 at 04:59:17PM -0500, D. Ben Knoble wrote: > > > [snip] > > > > Only, things are behaving oddly. For example: > > > > > > > > λ meson setup build2 > > > > λ ninja -C build2 > > > > > > > > works fine, but > > > > > > > > λ ls -l build2/config* > > > > -rw-r--r-- 1 benknoble benknoble 17169 9 févr. 16:39 > > > > build2/ config-list.h > > > > > > > > I don't see the dependency file. > > I've just had a play with this and I don't see the dependency file either - > I wonder if ninja deletes it after it has read it. Yeah, that's expected. Meson will prune the depfile after consuming it. > If I delete Documentation/config/add.adoc then config-list.h is rebuilt. > However if I edit generate-configlist.sh it is not rebuilt - I guess we need > to add the script to the dependency file. True. This is typically handled automatically by Meson, but in our case it doesn't know that the string we pass to the shell refers to a script, and that it should thus cause a rebuild if it changes. Patrick ^ permalink raw reply [flat|nested] 46+ messages in thread
* Re: [PATCH] meson: regenerate config-list.h when Documentation changes 2026-02-11 9:44 ` Phillip Wood 2026-02-11 10:57 ` Phillip Wood @ 2026-02-11 10:58 ` Patrick Steinhardt 2026-02-11 14:05 ` Phillip Wood 1 sibling, 1 reply; 46+ messages in thread From: Patrick Steinhardt @ 2026-02-11 10:58 UTC (permalink / raw) To: phillip.wood; +Cc: D. Ben Knoble, git, Junio C Hamano, Evan Martin On Wed, Feb 11, 2026 at 09:44:48AM +0000, Phillip Wood wrote: > On 11/02/2026 07:42, Patrick Steinhardt wrote: > > On Mon, Feb 09, 2026 at 04:50:06PM -0500, D. Ben Knoble wrote: > > > > On Sat, Feb 07, 2026 at 04:59:17PM -0500, D. Ben Knoble wrote: > > [snip] > > > Only, things are behaving oddly. For example: > > > > > > λ meson setup build2 > > > λ ninja -C build2 > > > > > > works fine, but > > > > > > λ ls -l build2/config* > > > -rw-r--r-- 1 benknoble benknoble 17169 9 févr. 16:39 build2/config-list.h > > > > > > I don't see the dependency file. > > > > > Further, re-building seems to get stuck (I get > > > similar symptoms if I add or remove a relevant config.adoc file, but let's keep > > > it simple for now): > > > > > > λ ninja -C build2 > > > ninja: Entering directory `build2' > > > [1/28] Generating GIT-VERSION-FILE with a custom command (wrapped by meson to set env) > > > > With "stuck" you mean that it doesn't do anything, or that it doesn't > > actually rebuild? > > > > I guess it kind of makes sense that a new file wouldn't trigger a > > rebuild, even though I would have expected a removed one to trigger one. > > After all, the dependency file only tracks the set of _existing_ files > > so that we know when to rebuild, and of course the dependency file only > > gets regenerated in case any of those files changes. > > If anyone adds a new file under Documentation/config/ they will need to > update Documentation/config.adoc which should then trigger the rebuild. That > rebuld will then add the new file to the list of dependencies. If they > remove a file we should pick that up with the dependencies that are already > listed. Oh? Well, if that's the case then the additional changes should indeed not be required. > Do we need to create the depfile when meson is setup? What does meson do > when the depfile is missing? The first diff I sent already takes care of generating the depfile. I guess the complaint was that simply removing/adding a file didn't cause a rebuild, but based on your finding that's not an issue if folks would have to modify "config.adoc" anyway. > > The thing is that build systems like Meson really want to know the list > > of files ahead of time so that they can have an optimal build graph. So > > we could of course list all the files that we actually depend on. But I > > guess that's something we want to avoid? > > > > There's another, alternative approach: you can have a separate build > > step that's marked as `build_always_stale: true` that lists all the > > config files. This step would then always run, and it would only update > > its target file in case any of the files has changed. > > It would be really nice if we can avoid regenerating the depfile with every > build. Agreed. So maybe the first patch I sent is sufficient after all? Thanks! Patrick ^ permalink raw reply [flat|nested] 46+ messages in thread
* Re: [PATCH] meson: regenerate config-list.h when Documentation changes 2026-02-11 10:58 ` Patrick Steinhardt @ 2026-02-11 14:05 ` Phillip Wood 2026-02-11 20:15 ` D. Ben Knoble 0 siblings, 1 reply; 46+ messages in thread From: Phillip Wood @ 2026-02-11 14:05 UTC (permalink / raw) To: Patrick Steinhardt, phillip.wood Cc: D. Ben Knoble, git, Junio C Hamano, Evan Martin On 11/02/2026 10:58, Patrick Steinhardt wrote: > On Wed, Feb 11, 2026 at 09:44:48AM +0000, Phillip Wood wrote: >> On 11/02/2026 07:42, Patrick Steinhardt wrote: >>> On Mon, Feb 09, 2026 at 04:50:06PM -0500, D. Ben Knoble wrote: >>>>> On Sat, Feb 07, 2026 at 04:59:17PM -0500, D. Ben Knoble wrote: >>> [snip] >>>> Only, things are behaving oddly. For example: >>>> >>>> λ meson setup build2 >>>> λ ninja -C build2 >>>> >>>> works fine, but >>>> >>>> λ ls -l build2/config* >>>> -rw-r--r-- 1 benknoble benknoble 17169 9 févr. 16:39 build2/config-list.h >>>> >>>> I don't see the dependency file. >>> >>>> Further, re-building seems to get stuck (I get >>>> similar symptoms if I add or remove a relevant config.adoc file, but let's keep >>>> it simple for now): >>>> >>>> λ ninja -C build2 >>>> ninja: Entering directory `build2' >>>> [1/28] Generating GIT-VERSION-FILE with a custom command (wrapped by meson to set env) >>> >>> With "stuck" you mean that it doesn't do anything, or that it doesn't >>> actually rebuild? >>> >>> I guess it kind of makes sense that a new file wouldn't trigger a >>> rebuild, even though I would have expected a removed one to trigger one. >>> After all, the dependency file only tracks the set of _existing_ files >>> so that we know when to rebuild, and of course the dependency file only >>> gets regenerated in case any of those files changes. >> >> If anyone adds a new file under Documentation/config/ they will need to >> update Documentation/config.adoc which should then trigger the rebuild. That >> rebuld will then add the new file to the list of dependencies. If they >> remove a file we should pick that up with the dependencies that are already >> listed. > > Oh? Well, if that's the case then the additional changes should indeed > not be required. I think so. The only problem I can think of is that if you delete a file, build, restore the file without changing anything else and build again then config-list.h will not be rebuilt because the deleted file would have been removed from the list of dependencies by the previous build. >> >> It would be really nice if we can avoid regenerating the depfile with every >> build. > > Agreed. So maybe the first patch I sent is sufficient after all? We need to add the script to the list of dependencies and reading the comments in https://github.com/ninja-build/ninja/blob/master/src/depfile_parser.in.cc we should be backslash escaping space, hash and backslash in the filename when we write the dependencies. Apart from that I think it is ok. I guess the alternative is to bite the bullet and list these dependencies explicitly as we do for other targets. Thanks Phillip ^ permalink raw reply [flat|nested] 46+ messages in thread
* Re: [PATCH] meson: regenerate config-list.h when Documentation changes 2026-02-11 14:05 ` Phillip Wood @ 2026-02-11 20:15 ` D. Ben Knoble 0 siblings, 0 replies; 46+ messages in thread From: D. Ben Knoble @ 2026-02-11 20:15 UTC (permalink / raw) To: phillip.wood; +Cc: Patrick Steinhardt, git, Junio C Hamano, Evan Martin On Wed, Feb 11, 2026 at 9:05 AM Phillip Wood <phillip.wood123@gmail.com> wrote: > > On 11/02/2026 10:58, Patrick Steinhardt wrote: > > On Wed, Feb 11, 2026 at 09:44:48AM +0000, Phillip Wood wrote: > >> On 11/02/2026 07:42, Patrick Steinhardt wrote: > >>> On Mon, Feb 09, 2026 at 04:50:06PM -0500, D. Ben Knoble wrote: > >>>>> On Sat, Feb 07, 2026 at 04:59:17PM -0500, D. Ben Knoble wrote: > >>> [snip] > >>>> Only, things are behaving oddly. For example: > >>>> > >>>> λ meson setup build2 > >>>> λ ninja -C build2 > >>>> > >>>> works fine, but > >>>> > >>>> λ ls -l build2/config* > >>>> -rw-r--r-- 1 benknoble benknoble 17169 9 févr. 16:39 build2/config-list.h > >>>> > >>>> I don't see the dependency file. > >>> > >>>> Further, re-building seems to get stuck (I get > >>>> similar symptoms if I add or remove a relevant config.adoc file, but let's keep > >>>> it simple for now): > >>>> > >>>> λ ninja -C build2 > >>>> ninja: Entering directory `build2' > >>>> [1/28] Generating GIT-VERSION-FILE with a custom command (wrapped by meson to set env) > >>> > >>> With "stuck" you mean that it doesn't do anything, or that it doesn't > >>> actually rebuild? > >>> > >>> I guess it kind of makes sense that a new file wouldn't trigger a > >>> rebuild, even though I would have expected a removed one to trigger one. > >>> After all, the dependency file only tracks the set of _existing_ files > >>> so that we know when to rebuild, and of course the dependency file only > >>> gets regenerated in case any of those files changes. > >> > >> If anyone adds a new file under Documentation/config/ they will need to > >> update Documentation/config.adoc which should then trigger the rebuild. That > >> rebuld will then add the new file to the list of dependencies. If they > >> remove a file we should pick that up with the dependencies that are already > >> listed. > > > > Oh? Well, if that's the case then the additional changes should indeed > > not be required. > > I think so. The only problem I can think of is that if you delete a > file, build, restore the file without changing anything else and build > again then config-list.h will not be rebuilt because the deleted file > would have been removed from the list of dependencies by the previous build. > > >> > >> It would be really nice if we can avoid regenerating the depfile with every > >> build. > > > > Agreed. So maybe the first patch I sent is sufficient after all? > > We need to add the script to the list of dependencies and reading the > comments in > https://github.com/ninja-build/ninja/blob/master/src/depfile_parser.in.cc > we should be backslash escaping space, hash and backslash in the > filename when we write the dependencies. Apart from that I think it is ok. Re-reading, I now see something actionable: - use Patrick's original patch - add the script itself to dependencies - quote dependencies correctly Thanks > I guess the alternative is to bite the bullet and list these > dependencies explicitly as we do for other targets. > > Thanks > > Phillip > ^ permalink raw reply [flat|nested] 46+ messages in thread
* Re: [PATCH] meson: regenerate config-list.h when Documentation changes 2026-02-11 7:42 ` Patrick Steinhardt 2026-02-11 9:44 ` Phillip Wood @ 2026-02-11 19:58 ` D. Ben Knoble 2026-02-12 8:10 ` Patrick Steinhardt 1 sibling, 1 reply; 46+ messages in thread From: D. Ben Knoble @ 2026-02-11 19:58 UTC (permalink / raw) To: Patrick Steinhardt; +Cc: git, Junio C Hamano, Evan Martin, Phillip Wood I'm not totally sure where the discussion ended up (what's actionable isn't clear to me), but let me respond to at least this bit: On Wed, Feb 11, 2026 at 2:43 AM Patrick Steinhardt <ps@pks.im> wrote: > > On Mon, Feb 09, 2026 at 04:50:06PM -0500, D. Ben Knoble wrote: > > > On Sat, Feb 07, 2026 at 04:59:17PM -0500, D. Ben Knoble wrote: > [snip] > > Only, things are behaving oddly. For example: > > > > λ meson setup build2 > > λ ninja -C build2 > > > > works fine, but > > > > λ ls -l build2/config* > > -rw-r--r-- 1 benknoble benknoble 17169 9 févr. 16:39 build2/config-list.h > > > > I don't see the dependency file. > > > Further, re-building seems to get stuck (I get > > similar symptoms if I add or remove a relevant config.adoc file, but let's keep > > it simple for now): > > > > λ ninja -C build2 > > ninja: Entering directory `build2' > > [1/28] Generating GIT-VERSION-FILE with a custom command (wrapped by meson to set env) > > With "stuck" you mean that it doesn't do anything, or that it doesn't > actually rebuild? I mean, that's all the output I get, and the build seems unable to make progress without the depfile present. Maybe I'm misreading the above output, so let me try again with a different kind of change that would cause recompilation: meson setup build2 && ninja -C build2 touch git.c ninja -C build2 Indeed, this time it definitely works ([6/6] Linking…), so I'm _probably_ misinterpreting the output. > I guess it kind of makes sense that a new file wouldn't trigger a > rebuild, even though I would have expected a removed one to trigger one. > After all, the dependency file only tracks the set of _existing_ files > so that we know when to rebuild, and of course the dependency file only > gets regenerated in case any of those files changes. Trying this bit again, yeah, config-list.h doesn't get rebuilt if I do `touch Documentation/fooconfig.adoc` (I think make would rebuild though). And I can't tell if that's due to the weird [1/28] output or due to something else, since I can't "see" if Meson recomputed the depfile or not; with the depfile gone, it seems like there's nothing present to tell Meson (ninja) when to rebuild, which is weird to me. It seems this is expected, but it makes it difficult for me to tell what's going on here. After `touch Documentation/config.adoc`, ninja executes 7 steps, including rebuilding the config-list.h, at which point it also knows to rebuild after touching "fooconfig.adoc" again. So maybe that's expected? FWIW, I ran into this because the staleness in the proposed commit caused some trouble while bisecting a (spurious-due-to-staleness) test failure, too. Hopefully with the fix in place I won't need to compile twice during a bisect, ha ^ permalink raw reply [flat|nested] 46+ messages in thread
* Re: [PATCH] meson: regenerate config-list.h when Documentation changes 2026-02-11 19:58 ` D. Ben Knoble @ 2026-02-12 8:10 ` Patrick Steinhardt 0 siblings, 0 replies; 46+ messages in thread From: Patrick Steinhardt @ 2026-02-12 8:10 UTC (permalink / raw) To: D. Ben Knoble; +Cc: git, Junio C Hamano, Evan Martin, Phillip Wood On Wed, Feb 11, 2026 at 02:58:27PM -0500, D. Ben Knoble wrote: > I'm not totally sure where the discussion ended up (what's actionable > isn't clear to me), but let me respond to at least this bit: > > On Wed, Feb 11, 2026 at 2:43 AM Patrick Steinhardt <ps@pks.im> wrote: > > > > On Mon, Feb 09, 2026 at 04:50:06PM -0500, D. Ben Knoble wrote: > > > > On Sat, Feb 07, 2026 at 04:59:17PM -0500, D. Ben Knoble wrote: > > [snip] > > > Only, things are behaving oddly. For example: > > > > > > λ meson setup build2 > > > λ ninja -C build2 > > > > > > works fine, but > > > > > > λ ls -l build2/config* > > > -rw-r--r-- 1 benknoble benknoble 17169 9 févr. 16:39 build2/config-list.h > > > > > > I don't see the dependency file. > > > > > Further, re-building seems to get stuck (I get > > > similar symptoms if I add or remove a relevant config.adoc file, but let's keep > > > it simple for now): > > > > > > λ ninja -C build2 > > > ninja: Entering directory `build2' > > > [1/28] Generating GIT-VERSION-FILE with a custom command (wrapped by meson to set env) > > > > With "stuck" you mean that it doesn't do anything, or that it doesn't > > actually rebuild? > > I mean, that's all the output I get, and the build seems unable to > make progress without the depfile present. Maybe I'm misreading the > above output, so let me try again with a different kind of change that > would cause recompilation: I think you're simply getting confused by Ninja's output. Ninja knows to short-circuit compilation in case regenerating a target that is used as input for another target will not cause the file to change. So what the "[1/28]" says is that we're regenerating the "GIT-VERSION-FILE", and if it would change we would have to recompile a bunch of other targets. But we see that it didn't change, and as a consequence we can skip compiling remaining targets. > > I guess it kind of makes sense that a new file wouldn't trigger a > > rebuild, even though I would have expected a removed one to trigger one. > > After all, the dependency file only tracks the set of _existing_ files > > so that we know when to rebuild, and of course the dependency file only > > gets regenerated in case any of those files changes. > > Trying this bit again, yeah, config-list.h doesn't get rebuilt if I do > `touch Documentation/fooconfig.adoc` (I think make would rebuild > though). And I can't tell if that's due to the weird [1/28] output or > due to something else, since I can't "see" if Meson recomputed the > depfile or not; with the depfile gone, it seems like there's nothing > present to tell Meson (ninja) when to rebuild, which is weird to me. > It seems this is expected, but it makes it difficult for me to tell > what's going on here. > > After `touch Documentation/config.adoc`, ninja executes 7 steps, > including rebuilding the config-list.h, at which point it also knows > to rebuild after touching "fooconfig.adoc" again. So maybe that's > expected? I assume that you simply didn't have a depfile yet initially, and because the script itself isn't part of the deps Meson didn't know to reexecute it as it changed to gain support for the depfile. Not sure though, but from all I can see things work as expected now with the current patch that you've sent. Patrick ^ permalink raw reply [flat|nested] 46+ messages in thread
end of thread, other threads:[~2026-02-26 3:20 UTC | newest] Thread overview: 46+ messages (download: mbox.gz follow: Atom feed -- links below jump to the message on this page -- 2026-02-07 21:59 [PATCH] meson: regenerate config-list.h when Documentation changes D. Ben Knoble 2026-02-07 22:38 ` Ben Knoble 2026-02-09 15:19 ` [PATCH v2] " D. Ben Knoble 2026-02-11 23:51 ` [PATCH v3] " D. Ben Knoble 2026-02-12 8:06 ` Patrick Steinhardt 2026-02-12 10:29 ` Phillip Wood 2026-02-12 14:14 ` Phillip Wood 2026-02-12 15:56 ` Ben Knoble 2026-02-16 22:28 ` [PATCH v4] " D. Ben Knoble 2026-02-17 0:33 ` Ben Knoble 2026-02-17 7:03 ` Patrick Steinhardt 2026-02-17 13:28 ` D. Ben Knoble 2026-02-17 7:02 ` Patrick Steinhardt 2026-02-17 13:28 ` D. Ben Knoble 2026-02-17 20:24 ` Junio C Hamano 2026-02-17 9:20 ` Phillip Wood 2026-02-17 13:38 ` D. Ben Knoble 2026-02-17 15:11 ` Phillip Wood 2026-02-18 14:37 ` [PATCH v5] build: " D. Ben Knoble 2026-02-19 10:19 ` Phillip Wood 2026-02-19 13:40 ` D. Ben Knoble 2026-02-19 13:56 ` Patrick Steinhardt 2026-02-21 13:58 ` D. Ben Knoble 2026-02-19 15:10 ` Marc Branchaud 2026-02-21 13:58 ` D. Ben Knoble 2026-02-21 14:07 ` [PATCH v6] " D. Ben Knoble 2026-02-23 6:37 ` Patrick Steinhardt 2026-02-23 6:55 ` SZEDER Gábor 2026-02-23 21:41 ` Ben Knoble 2026-02-24 9:58 ` Patrick Steinhardt 2026-02-24 11:00 ` Phillip Wood 2026-02-24 14:12 ` D. Ben Knoble 2026-02-24 14:39 ` [PATCH v7] " D. Ben Knoble 2026-02-25 18:45 ` Junio C Hamano 2026-02-26 3:20 ` Ben Knoble 2026-02-09 15:25 ` [PATCH] meson: " Patrick Steinhardt 2026-02-09 21:50 ` D. Ben Knoble 2026-02-11 7:42 ` Patrick Steinhardt 2026-02-11 9:44 ` Phillip Wood 2026-02-11 10:57 ` Phillip Wood 2026-02-11 11:00 ` Patrick Steinhardt 2026-02-11 10:58 ` Patrick Steinhardt 2026-02-11 14:05 ` Phillip Wood 2026-02-11 20:15 ` D. Ben Knoble 2026-02-11 19:58 ` D. Ben Knoble 2026-02-12 8:10 ` Patrick Steinhardt
This is a public inbox, see mirroring instructions for how to clone and mirror all data and code used for this inbox