Repository: mesonbuild/meson

Issue:
@BUILD_ROOT@ and @SOURCE_ROOT@ don't get replaced before running gtk-doc helper
This happens when building gstreamer with gtk-doc enabled.
Running `git bisect` shows it is caused by commit 976c9ab.

```
Running custom install script '/usr/local/bin/python3 /tmp/meson/meson.py --internal gtkdoc --sourcedir=/home/lantw44/gnome/source/gstreamer --builddir=/tmp/gstreamer-build --subdir=docs/gst --headerdirs=/home/lantw44/gnome/source/gstreamer/docs/gst/../../gst --mainfile=gstreamer-docs.sgml --modulename=gstreamer --mode=auto --scanargs=--deprecated-guards=GST_DISABLE_DEPRECATED@@--ignore-decorators=GST_EXPORT@@--ignore-headers=gettext.h glib-compat-private.h glib-compat.h gst-i18n-app.h gst-i18n-lib.h gst_private.h gstelementdetails.h gstmacros.h grammar.tab.h grammar.tab.pre.h math-compat.h types.h --gobjects-types-file=/tmp/gstreamer-build/docs/gst/gstreamer.types --content-files=building.xml@@running.xml@@/tmp/gstreamer-build/docs/version.entities --cflags=-I@BUILD_ROOT@/. -I@SOURCE_ROOT@/. -I/home/lantw44/gnome/devinstall/include/glib-2.0 -I/home/lantw44/gnome/devinstall/lib/glib-2.0/include -pthread --ldflags=-lgstreamer-1.0 -L/tmp/gstreamer-build/gst -Wl,-rpath /tmp/gstreamer-build/gst -L/home/lantw44/gnome/devinstall/lib -lgobject-2.0 -lglib-2.0 -lintl -lgmodule-2.0 -pthread -lm -L/usr/local/lib -lunwind -lexecinfo --cc=clang -pedantic -std=c11 --ld=clang -pedantic -std=c11'
Building documentation for gstreamer

Error in gtkdoc helper script:
'gtkdoc-scangobj' failed with status 1
gstreamer-scan.c:7:10: fatal error: 'gst/gst.h' file not found
#include <gst/gst.h>
         ^
1 error generated.
Traceback (most recent call last):
  File "/home/lantw44/gnome/devinstall/bin/gtkdoc-scangobj", line 69, in <module>
    sys.exit(scangobj.run(options))
  File "/home/lantw44/gnome/devinstall/share/gtk-doc/python/gtkdoc/scangobj.py", line 1255, in run
    res = subprocess.check_call(command, shell=True)
  File "/usr/local/lib/python2.7/subprocess.py", line 186, in check_call
    raise CalledProcessError(retcode, cmd)
subprocess.CalledProcessError: Command 'clang -pedantic -std=c11 >/dev/null -I@BUILD_ROOT@/. -I@SOURCE_ROOT@/. -I/home/lantw44/gnome/devinstall/include/glib-2.0 -I/home/lantw44/gnome/devinstall/lib/glib-2.0/include -pthread -c -o gstreamer-scan.o gstreamer-scan.c' returned non-zero exit status 1
```


Discussion:

Resolving patch:
diff --git a/mesonbuild/backend/ninjabackend.py b/mesonbuild/backend/ninjabackend.py
--- a/mesonbuild/backend/ninjabackend.py
+++ b/mesonbuild/backend/ninjabackend.py
@@ -720,7 +720,19 @@ def generate_target_install(self, d):
                         d.targets.append([f, outdir, {}, False, None])
 
     def generate_custom_install_script(self, d):
-        d.install_scripts = self.build.install_scripts
+        result = []
+        srcdir = self.environment.get_source_dir()
+        builddir = self.environment.get_build_dir()
+        for i in self.build.install_scripts:
+            exe = i['exe']
+            args = i['args']
+            fixed_args = []
+            for a in args:
+                a = a.replace('@SOURCE_ROOT@', srcdir)
+                a = a.replace('@BUILD_ROOT@', builddir)
+                fixed_args.append(a)
+            result.append(build.RunScript(exe, fixed_args))
+        d.install_scripts = result
 
     def generate_header_install(self, d):
         incroot = self.environment.get_includedir()


Test patch: