Skip to contentSkip to conversation

meson: regenerate config-list.h when Documentation changes

PATCH Superseded D. Ben Knoble 7 participants 46 messages Feb 7 – Feb 26

Subsystems (2)
lore
Share & tools
lore
#0 lore raw

PATCH 1/1 meson: 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.

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.

---

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
generate-configlist-deps.sh new file +5 -0
new file mode 100755
index 0000000000..a873e976b6
@@ -0,0 +1,5 @@
+#! /bin/sh
+
+printf '%s\n' \
+  "$MESON_SOURCE_ROOT"/Documentation/*config.adoc \
+  "$MESON_SOURCE_ROOT"/Documentation/config/*.adoc
meson.build +1 -0
index 3a1d12caa4..4df7caa206 100644
@@ -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',
Signature · 1 line
2.52.0.rc0.971.g305ecc6b61.dirty
#1 lore raw
Quoted 20 lines · D. Ben Knoble
generate-configlist-deps.sh new file +5 -0
new file mode 100755
index 0000000000..a873e976b6
@@ -0,0 +1,5 @@
+#! /bin/sh
+
+printf '%s\n' \
+  "$MESON_SOURCE_ROOT"/Documentation/*config.adoc \
+  "$MESON_SOURCE_ROOT"/Documentation/config/*.adoc
meson.build +0 -0
index 3a1d12caa4..4df7caa206 100644
@@ -720,6 +720,7 @@ endif
 
Quoted 4 lines

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.

#2 lore raw

PATCH v2 1/1 meson: regenerate config-list.h when Documentation changes

In reply to D. Ben Knoble

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.

---

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/[email protected]/

 generate-configlist-deps.sh | 5 +++++
 meson.build                 | 1 +
 2 files changed, 6 insertions(+)
 create mode 100755 generate-configlist-deps.sh
generate-configlist-deps.sh new file +5 -0
new file mode 100755
index 0000000000..a873e976b6
@@ -0,0 +1,5 @@
+#! /bin/sh
+
+printf '%s\n' \
+  "$MESON_SOURCE_ROOT"/Documentation/*config.adoc \
+  "$MESON_SOURCE_ROOT"/Documentation/config/*.adoc
meson.build +1 -0
index 3a1d12caa4..eb6a149c9f 100644
@@ -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

Signature · 1 line
2.52.0.rc0.1018.g3ad6585c12.dirty
#35 lore raw
In reply to D. Ben Knoble
Quoted 14 lines · D. Ben Knoble

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.

Quoted 6 lines

---

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

generate-configlist.sh +8 -1
index 75c39ade20..2c93ffc58a 100755
@@ -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
meson.build +3 -1
index dd52efd1c8..03ad7a2152 100644
@@ -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,
 )
#36 lore raw

Hi Patrick,

Quoted 18 lines · D. Ben Knoble
Quoted 17 lines

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.

---

Quoted 6 lines
Quoted 3 lines

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

Quoted 6 lines

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< ----

generate-configlist.sh +8 -1
index 75c39ade20..2c93ffc58a 100755
@@ -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
meson.build +3 -1
index 3a1d12caa4..fb5d7367f5 100644
@@ -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.

#37 lore raw
Quoted 1 line · D. Ben Knoble
Quoted 1 line · D. Ben Knoble

[snip]

Quoted 12 lines

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.

Quoted 7 lines

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 ---

generate-configlist.sh +48 -14
index 75c39ade20..17605e6f77 100755
@@ -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
meson.build +15 -0
index dd52efd1c8..6b9147a39a 100644
@@ -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@',
+    '@[email protected]',
   ],
+  depends: [ configlist_deps, ],
+  depfile: 'config-list.h.d',
   env: script_environment,
 )
 
#38 lore raw
Quoted 23 lines · Patrick Steinhardt
Quoted 1 line · D. Ben Knoble
Quoted 1 line · D. Ben Knoble

[snip]

Quoted 12 lines

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.

Quoted 7 lines

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)

Quoted 8 lines

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?

Quoted 9 lines

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

Quoted 129 lines

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 ---

generate-configlist.sh +48 -14
index 75c39ade20..17605e6f77 100755
@@ -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
meson.build +15 -0
index dd52efd1c8..6b9147a39a 100644
@@ -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@',
+    '@[email protected]',
    ],
+  depends: [ configlist_deps, ],
+  depfile: 'config-list.h.d',
    env: script_environment,
  )
 
#39 lore raw
Quoted 9 lines · Phillip Wood
Quoted 8 lines · Patrick Steinhardt
Quoted 1 line · D. Ben Knoble
Quoted 1 line · D. Ben Knoble

[snip]

Quoted 5 lines

Only, things are behaving oddly. For example:

     λ meson setup build2
     λ ninja -C build2

Quoted 6 lines
Quoted 6 lines
Quoted 6 lines

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

Quoted 165 lines
Quoted 8 lines
Quoted 7 lines

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)

Quoted 8 lines

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?

Quoted 9 lines

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

Quoted 127 lines

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 ---

generate-configlist.sh +1 -8
index 75c39ade20..17605e6f77 100755
@@ -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

generate-configlist.sh +0 -0
@@ -30,9 +23,50 @@ EOF

  EOF
  }

generate-configlist.sh +7 -6
-{
-    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

generate-configlist.sh +13 -0
+
+    {
+        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

generate-configlist.sh +13 -0
+
+    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
meson.build +0 -0
index dd52efd1c8..6b9147a39a 100644
@@ -716,14 +716,29 @@ if not get_option('breaking_changes')

    builtin_sources += 'builtin/pack-redundant.c'
  endif

meson.build +11 -0
+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@',
+    '@[email protected]',
    ],
+  depends: [ configlist_deps, ],
+  depfile: 'config-list.h.d',
    env: script_environment,
  )

#41 lore raw
In reply to Phillip Wood
Quoted 33 lines · Phillip Wood
Quoted 23 lines · Patrick Steinhardt
Quoted 1 line · D. Ben Knoble
Quoted 1 line · D. Ben Knoble

[snip]

Quoted 12 lines

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.

Quoted 7 lines

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)

Quoted 8 lines

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.

Quoted 5 lines

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.

Quoted 2 lines

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.

Quoted 5 lines
Quoted 5 lines

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?

Quoted 7 lines
Quoted 4 lines

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

#40 lore raw
In reply to Phillip Wood
Quoted 12 lines · Phillip Wood
Quoted 11 lines · Phillip Wood
Quoted 10 lines · Patrick Steinhardt
Quoted 1 line · D. Ben Knoble
Quoted 1 line · D. Ben Knoble

[snip]

Quoted 7 lines

Only, things are behaving oddly. For example:

     λ meson setup build2
     λ ninja -C build2

works fine, but

Quoted 8 lines
Quoted 5 lines
Quoted 5 lines
Quoted 5 lines

     λ 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.

Quoted 3 lines

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

#42 lore raw
In reply to Patrick Steinhardt
Quoted 34 lines · Patrick Steinhardt
Quoted 33 lines · Phillip Wood
Quoted 31 lines · Patrick Steinhardt
Quoted 1 line · D. Ben Knoble
Quoted 1 line · D. Ben Knoble

[snip]

Quoted 12 lines

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.

Quoted 7 lines

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.

Quoted 8 lines
Quoted 5 lines

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.

Quoted 5 lines
Quoted 3 lines

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

#44 lore raw
In reply to Patrick Steinhardt

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:

Quoted 20 lines · Patrick Steinhardt
Quoted 1 line · D. Ben Knoble
Quoted 1 line · D. Ben Knoble

[snip]

Quoted 16 lines

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):

Quoted 6 lines
Quoted 3 lines

λ 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.

Quoted 5 lines

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

#43 lore raw
In reply to Phillip Wood
Quoted 54 lines · Phillip Wood
Quoted 34 lines · Patrick Steinhardt
Quoted 33 lines · Phillip Wood
Quoted 31 lines · Patrick Steinhardt
Quoted 1 line · D. Ben Knoble
Quoted 1 line · D. Ben Knoble

[snip]

Quoted 12 lines

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.

Quoted 7 lines

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.

Quoted 8 lines
Quoted 5 lines

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.

Quoted 4 lines
Quoted 3 lines

It would be really nice if we can avoid regenerating the depfile with every build.

Quoted 7 lines
Quoted 1 line

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

Quoted 7 lines

I guess the alternative is to bite the bullet and list these dependencies explicitly as we do for other targets.

Thanks

Phillip

#3 lore raw

PATCH v3 1/1 meson: regenerate config-list.h when Documentation changes

In reply to D. Ben Knoble

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.

---

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(-)
generate-configlist.sh +9 -1
index 75c39ade20..091efd4564 100755
@@ -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
meson.build +3 -1
index 3a1d12caa4..fb5d7367f5 100644
@@ -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

Signature · 1 line
2.52.0.rc0.1058.g68d811a4ee.dirty
#4 lore raw
Quoted 10 lines · D. Ben Knoble

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.

Quoted 5 lines

λ 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.

Quoted 9 lines
 generate-configlist.sh | 10 +++++++++-
 meson.build            |  4 +++-
 2 files changed, 12 insertions(+), 2 deletions(-)
generate-configlist.sh +0 -0
index 75c39ade20..091efd4564 100755

generate-configlist.sh print_config_list () { · line 43

Quoted 7 lines
generate-configlist.sh +4 -0
@@ -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.

generate-configlist.sh print_config_list () { · line 46

Quoted 3 lines
generate-configlist.sh +3 -0
+	    "$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.".

Quoted 6 lines
meson.build +0 -0
index 3a1d12caa4..fb5d7367f5 100644
@@ -720,11 +720,13 @@ endif
 

meson.build endif · line 729

Quoted 10 lines
meson.build +3 -1
 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

#45 lore raw
In reply to D. Ben Knoble
Quoted 28 lines · D. Ben Knoble

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:

Quoted 24 lines · Patrick Steinhardt
Quoted 1 line · D. Ben Knoble
Quoted 1 line · D. Ben Knoble

[snip]

Quoted 19 lines

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)

Quoted 7 lines
Quoted 2 lines

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.

Quoted 15 lines
Quoted 5 lines

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.

Quoted 4 lines

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

#5 lore raw
In reply to D. Ben Knoble

Hi Ben

Quoted 9 lines · D. Ben Knoble

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.

Quoted 4 lines

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.

Quoted 15 lines

---

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

Quoted 5 lines

λ 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

generate-configlist.sh print_config_list () { · line 45

Quoted 5 lines
generate-configlist.sh +5 -0
+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

Quoted 23 lines
generate-configlist.sh +1 -0
+fi
meson.build +3 -1
index 3a1d12caa4..fb5d7367f5 100644
@@ -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

#6 lore raw
Quoted 2 lines · Phillip Wood

    printf '%s\n' ... | sed "s/[# ]/\\&/g; s|^|$OUTPUT|" >"$DEPFILE"

Sorry that's missing ": " after $OUTPUT

Thanks

Phillip

#7 lore raw
In reply to D. Ben Knoble

Apologies, this has a rather obvious bug:

Quoted 60 lines · D. Ben Knoble

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.

---

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(-)
generate-configlist.sh +0 -0
index 75c39ade20..091efd4564 100755
@@ -2,10 +2,11 @@
 

SOURCE_DIR="$1"
OUTPUT="$2"
+DEPFILE="$3"

if test -z "$SOURCE_DIR" || ! test -d "$SOURCE_DIR" || test -z "$OUTPUT" then

generate-configlist.sh +1 -1
-    echo >&2 "USAGE: $0 <SOURCE_DIR> <OUTPUT>"
+    echo >&2 "USAGE: $0 <SOURCE_DIR> <OUTPUT> [<DEPFILE>]"
   exit 1

fi

generate-configlist.sh print_config_list () { · line 45

Quoted 9 lines
generate-configlist.sh +6 -0
@@ -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.

#8 lore raw

PATCH v4 1/1 meson: regenerate config-list.h when Documentation changes

In reply to D. Ben Knoble

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.

---

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(-)
generate-configlist.sh +11 -1
index 75c39ade209..63a2e8b6938 100755
@@ -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
meson.build +4 -1
index 3a1d12caa4b..e4b8f1e33d2 100644
@@ -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: Phillip Wood <[email protected]>

## 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

Signature · 1 line
2.48.1
#9 lore raw
Quoted 180 lines · D. Ben Knoble

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.

---

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(-)
generate-configlist.sh +0 -0
index 75c39ade209..63a2e8b6938 100755
@@ -2,10 +2,11 @@
 

SOURCE_DIR="$1"
OUTPUT="$2"
+DEPFILE="$3"

if test -z "$SOURCE_DIR" || ! test -d "$SOURCE_DIR" || test -z "$OUTPUT" then

generate-configlist.sh +1 -1
-    echo >&2 "USAGE: $0 <SOURCE_DIR> <OUTPUT>"
+    echo >&2 "USAGE: $0 <SOURCE_DIR> <OUTPUT> [<DEPFILE>]"
   exit 1

fi

generate-configlist.sh +9 -0
@@ -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
meson.build +0 -0
index 3a1d12caa4b..e4b8f1e33d2 100644
@@ -720,11 +720,14 @@ endif
 

builtin_sources += custom_target(
output: 'config-list.h',

meson.build +4 -1
+  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: Phillip Wood <[email protected]>

## 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',
Quoted 4 lines

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.

#12 lore raw
In reply to D. Ben Knoble
Quoted 18 lines · D. Ben Knoble

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.

Quoted 8 lines

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.

Quoted 5 lines
generate-configlist.sh +0 -0
index 75c39ade209..63a2e8b6938 100755

generate-configlist.sh print_config_list () · line 46

Quoted 10 lines
generate-configlist.sh +7 -0
@@ -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 ...)"?

Quoted 10 lines
meson.build +2 -0
index 3a1d12caa4b..e4b8f1e33d2 100644
@@ -720,11 +720,14 @@ endif
 
 builtin_sources += custom_target(
   output: 'config-list.h',
+  depfile: 'config-list.h.d',
+  depend_files: [ 'generate-configlist.sh' ],

meson.build endif · line 733

Quoted 10 lines
meson.build +2 -1
   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:

Makefile +4 -2
index 47ed9fa7fd..ed82775ec2 100644
@@ -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

#10 lore raw
In reply to Ben Knoble
Quoted 2 lines · Ben Knoble

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

#15 lore raw
In reply to D. Ben Knoble
Quoted 23 lines · D. Ben Knoble

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

Quoted 7 lines

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.

Thanks for the nicely written commit message.

generate-configlist.sh print_config_list ()

Quoted 6 lines
generate-configlist.sh +6 -0
+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

#13 lore raw
In reply to Patrick Steinhardt
Quoted 40 lines · Patrick Steinhardt
Quoted 18 lines · D. Ben Knoble

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.

Quoted 8 lines

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.

Quoted 9 lines
generate-configlist.sh +1 -0
index 75c39ade209..63a2e8b6938 100755
@@ -36,3 +37,12 @@ print_config_list ()
      echo
      print_config_list
 } >"$OUTPUT"
+
Quoted 8 lines

generate-configlist.sh print_config_list () · line 46

Quoted 6 lines
generate-configlist.sh +6 -0
+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.

Quoted 46 lines
Quoted 10 lines
meson.build +2 -0
index 3a1d12caa4b..e4b8f1e33d2 100644
@@ -720,11 +720,14 @@ endif
 
 builtin_sources += custom_target(
   output: 'config-list.h',
+  depfile: 'config-list.h.d',
+  depend_files: [ 'generate-configlist.sh' ],

meson.build endif · line 733

Quoted 10 lines
meson.build +2 -1
   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:

Makefile +4 -2
index 47ed9fa7fd..ed82775ec2 100644
@@ -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
 
Quoted 5 lines

Please feel free to skip this part though.

Thanks!

Patrick

That seems reasonable. I'll add to the next version.

#11 lore raw
In reply to Patrick Steinhardt
Quoted 11 lines · Patrick Steinhardt
Quoted 2 lines · Ben Knoble

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).

Quoted 3 lines

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

Signature · 1 line
D. Ben Knoble
#16 lore raw
In reply to Phillip Wood
Quoted 10 lines · Phillip Wood

generate-configlist.sh print_config_list ()

Quoted 6 lines · D. Ben Knoble
generate-configlist.sh +6 -0
+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…

Quoted 7 lines

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 :)

#17 lore raw
Quoted 23 lines · D. Ben Knoble
Quoted 10 lines · Phillip Wood

generate-configlist.sh print_config_list ()

Quoted 6 lines · D. Ben Knoble
generate-configlist.sh +6 -0
+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…

Quoted 7 lines

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"
Quoted 8 lines

…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

Quoted 11 lines

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

Quoted 2 lines

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

#14 lore raw
In reply to D. Ben Knoble
Quoted 11 lines · D. Ben Knoble
Quoted 6 lines

Review

Quoted 4 lines
(quoted diff) +4 -0
+     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?

#18 lore raw

PATCH v5 1/1 build: regenerate config-list.h when Documentation changes

In reply to D. Ben Knoble

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.

---

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(-)
Makefile +3 -2
index 7f37ad8f58..6f926ffb1f 100644
@@ -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
 
generate-configlist.sh +10 -1
index 75c39ade20..39ac8845ab 100755
@@ -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
meson.build +4 -1
index 762e2d0fc0..74b459b004 100644
@@ -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 <[email protected]>

## 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

Signature · 1 line
2.53.0
#19 lore raw

Re: [PATCH v5] build: regenerate config-list.h when Documentation changes

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

Quoted 224 lines · D. Ben Knoble

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.

---

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(-)
Makefile +3 -2
index 7f37ad8f58..6f926ffb1f 100644
@@ -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
 
generate-configlist.sh +10 -1
index 75c39ade20..39ac8845ab 100755
@@ -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
meson.build +4 -1
index 762e2d0fc0..74b459b004 100644
@@ -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 <[email protected]>

## 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

#20 lore raw

Re: [PATCH v5] build: regenerate config-list.h when Documentation changes

Quoted 10 lines · Phillip Wood

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'
Quoted 8 lines

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!

#21 lore raw

Re: [PATCH v5] build: regenerate config-list.h when Documentation changes

In reply to D. Ben Knoble

generate-configlist.sh print_config_list () { · line 41

Quoted 10 lines · D. Ben Knoble
generate-configlist.sh +2 -0
index 75c39ade20..39ac8845ab 100755
@@ -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.

generate-configlist.sh print_config_list () { · line 47

Quoted 6 lines
generate-configlist.sh +6 -0
+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.

Quoted 21 lines
meson.build +4 -1
index 762e2d0fc0..74b459b004 100644
@@ -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,
 )
Quoted 2 lines

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

#23 lore raw

Re: [PATCH v5] build: regenerate config-list.h when Documentation changes

In reply to D. Ben Knoble
Quoted 9 lines · D. Ben Knoble

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.

Quoted 3 lines

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.
Quoted 212 lines

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.

---

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(-)
Makefile +3 -2
index 7f37ad8f58..6f926ffb1f 100644
@@ -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
 
generate-configlist.sh +10 -1
index 75c39ade20..39ac8845ab 100755
@@ -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
meson.build +4 -1
index 762e2d0fc0..74b459b004 100644
@@ -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 <[email protected]>

## 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

#22 lore raw

Re: [PATCH v5] build: regenerate config-list.h when Documentation changes

In reply to Patrick Steinhardt
Quoted 15 lines · Patrick Steinhardt

generate-configlist.sh print_config_list () { · line 41

Quoted 10 lines · D. Ben Knoble
generate-configlist.sh +2 -0
index 75c39ade20..39ac8845ab 100755
@@ -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.

Quoted 35 lines

generate-configlist.sh print_config_list () { · line 47

Quoted 6 lines
generate-configlist.sh +6 -0
+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.

Quoted 21 lines
meson.build +4 -1
index 762e2d0fc0..74b459b004 100644
@@ -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,
 )
Quoted 4 lines
Quoted 2 lines

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.

Quoted 3 lines

Overall this patch looks good to me, thanks!

Patrick

Thanks for the help and reviews!

#24 lore raw

Re: [PATCH v5] build: regenerate config-list.h when Documentation changes

In reply to Marc Branchaud
Quoted 17 lines · Marc Branchaud
Quoted 9 lines · D. Ben Knoble

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.

Quoted 4 lines

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.

Quoted 7 lines

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.

#25 lore raw

PATCH v6 1/1 build: regenerate config-list.h when Documentation changes

In reply to D. Ben Knoble

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.

---

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(-)
Makefile +3 -2
index 7f37ad8f58..6f926ffb1f 100644
@@ -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
 
generate-configlist.sh +10 -1
index 75c39ade20..39ac8845ab 100755
@@ -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
meson.build +4 -1
index 762e2d0fc0..74b459b004 100644
@@ -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

Signature · 1 line
2.53.0
#26 lore raw

Re: [PATCH v6] build: regenerate config-list.h when Documentation changes

Quoted 4 lines · D. Ben Knoble

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

#27 lore raw

Re: [PATCH v6] build: regenerate config-list.h when Documentation changes

In reply to D. Ben Knoble
Quoted 51 lines · D. Ben Knoble

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.

---

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(-)
Makefile +0 -0
index 7f37ad8f58..6f926ffb1f 100644

Makefile $(BUILT_INS): git$X · line 2694

Quoted 9 lines
Makefile +3 -2
@@ -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
Quoted 104 lines
Makefile +0 -0
 command-list.h: generate-cmdlist.sh command-list.txt
 
generate-configlist.sh +10 -1
index 75c39ade20..39ac8845ab 100755
@@ -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
meson.build +4 -1
index 762e2d0fc0..74b459b004 100644
@@ -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

Signature · 1 line
2.53.0
#28 lore raw

Re: [PATCH v6] build: regenerate config-list.h when Documentation changes

Quoted 83 lines · SZEDER Gábor
Quoted 54 lines · D. Ben Knoble

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.

---

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(-)
Makefile +0 -0
index 7f37ad8f58..6f926ffb1f 100644
@@ -2688,9 +2688,10 @@ $(BUILT_INS): git$X
   cp $< $@
 

config-list.h: generate-configlist.sh

Makefile $(BUILT_INS): git$X · line 2694

Quoted 6 lines
Makefile +3 -2
+    @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
Quoted 8 lines
 $ 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 :)

#29 lore raw

Re: [PATCH v6] build: regenerate config-list.h when Documentation changes

Quoted 44 lines · Ben Knoble
Quoted 35 lines · SZEDER Gábor
Quoted 8 lines · D. Ben Knoble
Makefile +0 -0
index 7f37ad8f58..6f926ffb1f 100644
@@ -2688,9 +2688,10 @@ $(BUILT_INS): git$X
   cp $< $@
 

config-list.h: generate-configlist.sh

Makefile

Quoted 6 lines
Makefile +3 -2
+    @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
Quoted 8 lines
 $ 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
Quoted 3 lines

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:

generate-configlist.sh +8 -3
index 39ac8845ab..e28054f9e0 100755
@@ -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

#30 lore raw

Re: [PATCH v6] build: regenerate config-list.h when Documentation changes

Quoted 75 lines · Patrick Steinhardt
Quoted 44 lines · Ben Knoble
Quoted 35 lines · SZEDER Gábor
Quoted 8 lines · D. Ben Knoble
Makefile +0 -0
index 7f37ad8f58..6f926ffb1f 100644
@@ -2688,9 +2688,10 @@ $(BUILT_INS): git$X
    cp $< $@
 

config-list.h: generate-configlist.sh

Makefile

Quoted 6 lines
Makefile +3 -2
+    @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
Quoted 8 lines
  $ 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
Quoted 3 lines

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:

generate-configlist.sh +8 -3
index 39ac8845ab..e28054f9e0 100755
@@ -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
Quoted 2 lines

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

Quoted 15 lines
     $ 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

#31 lore raw

Re: [PATCH v6] build: regenerate config-list.h when Documentation changes

Quoted 88 lines · Phillip Wood
Quoted 75 lines · Patrick Steinhardt
Quoted 44 lines · Ben Knoble
Quoted 35 lines · SZEDER Gábor
Quoted 8 lines · D. Ben Knoble
Makefile +0 -0
index 7f37ad8f58..6f926ffb1f 100644
@@ -2688,9 +2688,10 @@ $(BUILT_INS): git$X
    cp $< $@
 

config-list.h: generate-configlist.sh

Makefile

Quoted 6 lines
Makefile +3 -2
+    @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
Quoted 8 lines
  $ 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
Quoted 3 lines

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:

generate-configlist.sh +8 -3
index 39ac8845ab..e28054f9e0 100755
@@ -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
Quoted 2 lines

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.

Quoted 19 lines

Thanks

Phillip

Quoted 15 lines
     $ 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.

Signature · 1 line
D. Ben Knoble
#32 lore raw

PATCH v7 1/1 build: regenerate config-list.h when Documentation changes

In reply to D. Ben Knoble

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.

---

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(-)
Makefile +3 -2
index 7f37ad8f58..6f926ffb1f 100644
@@ -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
 
generate-configlist.sh +15 -1
index 75c39ade20..e28054f9e0 100755
@@ -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
meson.build +4 -1
index 6f155beafa..4b536e0124 100644
@@ -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

Signature · 1 line
2.53.0.537.g7ffbde5f8a.dirty
#33 lore raw

Re: [PATCH v7] build: regenerate config-list.h when Documentation changes

Quoted 6 lines · D. Ben Knoble

The Meson-based build doesn't know when to rebuild config-list.h, so the header is sometimes stale.
...

Quoted 7 lines

---

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.

#34 lore raw

Re: [PATCH v7] build: regenerate config-list.h when Documentation changes

Quoted 16 lines · Junio C Hamano
Quoted 11 lines · "D. Ben Knoble

The Meson-based build doesn't know when to rebuild config-list.h, so the header is sometimes stale.
...

---

Notes (benknoble/commits):

   Changes from v6 (<5dcd4e9308100a25603c50fecb36447c0ee4df62.1771682788.git.ben.knoble+github@gmail.com>):
Quoted 7 lines
Quoted 2 lines

• 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.