Repository: mesonbuild/meson

Issue:
Directories added to REGENERATE_BUILD ninja target
The gtk+ build currently causes a meson to regenerate the build files on every change. This seems to happen because both the `gtk/` and the `gdk/` subdirectory are added to the `REGENERATE_BUILD` rule in the generated `build.ninja`:
```
build build.ninja: REGENERATE_BUILD ../meson.build ../modules/input/meson.build ../gdk/meson.build ../gdk/gen-gdk-gresources-xml.py ../gdk ../build/gdk/gdk.gresource.xml ../gdk/gdkconfig.h.meson ../gdk/gdkversionmacros.h.in ../gdk/wayland/meson.build ../gdk/x11/meson.build ../gsk/meson.build ../gsk/gen-gsk-gresources-xml.py ../build/gsk/gsk.resources.xml ../gtk/meson.build ../gtk/deprecated
/meson.build ../gtk/a11y/meson.build ../gtk/inspector/meson.build ../gtk/gen-gtk-gresources-xml.py ../gtk ../build/gtk/gtk.gresources.xml ../gtk/theme/Adwaita/meson.build ../gtk/theme/HighContrast/meson.build ../gtk/gtkversion.h.in ../modules/meson.build ../modules/printbackends/meson.build ../modules/printbackends/file/meson.build ../modules/printbackends/cups/meson.build ../modules/printbackends/cloudprint/meson.build ../tests/meson.build ../tests/visuals/meson.build ../testsuite/meson.build ../testsuite/gdk/meson.build ../testsuite/gsk/meson.build ../testsuite/gtk/meson.build ../testsuite
/css/meson.build ../testsuite/css/parser/meson.build ../testsuite/css/nodes/meson.build ../testsuite/css/style/meson.build ../testsuite/a11y/meson.build ../testsuite/tools/meson.build ../testsuite/tools/simplify.in ../testsuite/tools/settings.in ../demos/meson.build ../demos/gtk-demo/meson.build ../demos/icon-browser/meson.build ../demos/widget-factory/meson.build ../examples/meson.build ../examples/bp/meson.build ../examples/application1/meson.build ../examples/application2/meson.build 
../examples/application3/meson.build ../examples/application4/meson.build ../examples/application5/meson.build ../examples/application6/meson.build ../examples/application7/meson.build ../examples
/application8/meson.build ../examples/application9/meson.build ../examples/application10/meson.build ../config.h.meson ../gtk+-4.0.pc.in ../gtk+-unix-print-4.0.pc.in ../po/meson.build ../po-properties/meson.build meson-private/coredata.dat ../meson_options.txt
```
... which contains an entry for `..gdk/` and `..gtk/`.

This happens both with 0.44 and master from yesterday as far as I can tell.


Discussion:
The reason this happens is this code snippet in `gtk` subdir:

```meson
gtk_gresources_xml = configure_file(output: 'gtk.gresources.xml',
                                    command: [
                                      gen_gtk_gresources_xml,
                                      meson.current_source_dir(),
                                      '@OUTPUT@'
                                    ])
```

You are passing it the gtk subdirectory as an argument. The dependency detector system picks that up and assumes you want to track it. Which kind of makes sense when you think about it (since the output of this command _may_ depend on any file in the subdir).

The simple solution would be to not set up rebuild dependencies to directories. That is unlikely to break anything.

Resolving patch:
diff --git a/mesonbuild/interpreter.py b/mesonbuild/interpreter.py
--- a/mesonbuild/interpreter.py
+++ b/mesonbuild/interpreter.py
@@ -1711,7 +1711,7 @@ def run_command_impl(self, node, args, kwargs, in_builddir=False):
         for a in expanded_args:
             if not os.path.isabs(a):
                 a = os.path.join(builddir if in_builddir else srcdir, self.subdir, a)
-            if os.path.exists(a):
+            if os.path.isfile(a):
                 a = os.path.relpath(a, start=srcdir)
                 if not a.startswith('..'):
                     if a not in self.build_def_files:


Test patch: