Repository: mesonbuild/meson

Issue:
[0.48.0] fails to build file-roller
When using meson 0.48.0, file-roller (tested verison 3.30.1) no longer builds/confifures successfully but errs on a meson internal library:

```
  File "/usr/lib/python3.6/site-packages/mesonbuild/modules/i18n.py", line 89, in merge_file
    ifile_abs = inputfile.absolute_path(state.environment.source_dir,
AttributeError: 'CustomTargetHolder' object has no attribute 'absolute_path'
```

Complete trace, for reference:
```
The Meson build system
Version: 0.48.0
Source dir: /home/abuild/rpmbuild/BUILD/file-roller-3.30.1
Build dir: /home/abuild/rpmbuild/BUILD/file-roller-3.30.1/build
Build type: native build
Project name: file-roller
Project version: 3.30.1
Native C compiler: cc (gcc 8.2.1 "cc (SUSE Linux) 8.2.1 20180831 [gcc-8-branch revision 264010]")
Build machine cpu family: x86_64
Build machine cpu: x86_64
Program postinstall.py found: YES (/home/abuild/rpmbuild/BUILD/file-roller-3.30.1/postinstall.py)
Library m found: YES
Dependency threads found: YES 
Found pkg-config: /usr/bin/pkg-config (0.29.2)
Dependency glib-2.0 found: YES 2.58.1
Dependency gthread-2.0 found: YES 2.58.1
Dependency gtk+-3.0 found: YES 3.24.1
Dependency libnautilus-extension found: NO (tried pkgconfig)
Dependency json-glib-1.0 found: YES 1.4.4
Dependency libnotify found: YES 0.7.7
Dependency libarchive found: YES 3.3.3
Checking for function "mkdtemp" : YES
Program gcpio found: NO
Program cpio found: YES (/usr/bin/cpio)
Configuring config.h using configuration
Compiler for C supports arguments -Wall: YES
Compiler for C supports arguments -Wcast-align: YES
Compiler for C supports arguments -Wtype-limits: YES
Compiler for C supports arguments -Wclobbered: YES
Compiler for C supports arguments -Wempty-body: YES
Compiler for C supports arguments -Wignored-qualifiers: YES
Compiler for C supports arguments -Wmissing-prototypes: YES
Compiler for C supports arguments -Wnested-externs: YES
Compiler for C supports arguments -Wpointer-arith: YES
Compiler for C supports arguments -Wno-sign-compare -Wsign-compare: YES
Compiler for C supports arguments -Wformat-security: YES
Program set-mime-type-entry.py found: YES (/home/abuild/rpmbuild/BUILD/file-roller-3.30.1/data/set-mime-type-entry.py)
Traceback (most recent call last):
  File "/usr/lib/python3.6/site-packages/mesonbuild/mesonmain.py", line 364, in run
    app.generate()
  File "/usr/lib/python3.6/site-packages/mesonbuild/mesonmain.py", line 136, in generate
    self._generate(env)
  File "/usr/lib/python3.6/site-packages/mesonbuild/mesonmain.py", line 165, in _generate
    intr.run()
  File "/usr/lib/python3.6/site-packages/mesonbuild/interpreter.py", line 3836, in run
    super().run()
  File "/usr/lib/python3.6/site-packages/mesonbuild/interpreterbase.py", line 380, in run
    self.evaluate_codeblock(self.ast, start=1)
  File "/usr/lib/python3.6/site-packages/mesonbuild/interpreterbase.py", line 404, in evaluate_codeblock
    raise e
  File "/usr/lib/python3.6/site-packages/mesonbuild/interpreterbase.py", line 398, in evaluate_codeblock
    self.evaluate_statement(cur)
  File "/usr/lib/python3.6/site-packages/mesonbuild/interpreterbase.py", line 409, in evaluate_statement
    return self.function_call(cur)
  File "/usr/lib/python3.6/site-packages/mesonbuild/interpreterbase.py", line 705, in function_call
    return func(node, posargs, kwargs)
  File "/usr/lib/python3.6/site-packages/mesonbuild/interpreterbase.py", line 273, in wrapped
    return f(*wrapped_args, **wrapped_kwargs)
  File "/usr/lib/python3.6/site-packages/mesonbuild/interpreterbase.py", line 162, in wrapped
    return f(*wrapped_args, **wrapped_kwargs)
  File "/usr/lib/python3.6/site-packages/mesonbuild/interpreter.py", line 3422, in func_subdir
    self.evaluate_codeblock(codeblock)
  File "/usr/lib/python3.6/site-packages/mesonbuild/interpreterbase.py", line 404, in evaluate_codeblock
    raise e
  File "/usr/lib/python3.6/site-packages/mesonbuild/interpreterbase.py", line 398, in evaluate_codeblock
    self.evaluate_statement(cur)
  File "/usr/lib/python3.6/site-packages/mesonbuild/interpreterbase.py", line 413, in evaluate_statement
    return self.method_call(cur)
  File "/usr/lib/python3.6/site-packages/mesonbuild/interpreterbase.py", line 741, in method_call
    return obj.method_call(method_name, args, kwargs)
  File "/usr/lib/python3.6/site-packages/mesonbuild/interpreter.py", line 1622, in method_call
    value = fn(state, args, kwargs)
  File "/usr/lib/python3.6/site-packages/mesonbuild/interpreterbase.py", line 219, in wrapped
    return f(*wrapped_args, **wrapped_kwargs)
  File "/usr/lib/python3.6/site-packages/mesonbuild/interpreterbase.py", line 162, in wrapped
    return f(*wrapped_args, **wrapped_kwargs)
  File "/usr/lib/python3.6/site-packages/mesonbuild/modules/i18n.py", line 89, in merge_file
    ifile_abs = inputfile.absolute_path(state.environment.source_dir,
AttributeError: 'CustomTargetHolder' object has no attribute 'absolute_path'

```


Discussion:
Bisection says that this was caused by commit 176af2c8c33e79732680ebb1e2a25b5cd7a51bb9 which seems to be authored by @tintou.



Resolving patch:
diff --git a/mesonbuild/modules/i18n.py b/mesonbuild/modules/i18n.py
--- a/mesonbuild/modules/i18n.py
+++ b/mesonbuild/modules/i18n.py
@@ -82,17 +82,19 @@ def merge_file(self, state, args, kwargs):
         kwargs['command'] = command
 
         inputfile = kwargs['input']
-        if isinstance(inputfile, str):
-            inputfile = mesonlib.File.from_source_file(state.environment.source_dir,
+        if hasattr(inputfile, 'held_object'):
+            ct = build.CustomTarget(kwargs['output'] + '_merge', state.subdir, state.subproject, kwargs)
+        else:
+            if isinstance(inputfile, str):
+                inputfile = mesonlib.File.from_source_file(state.environment.source_dir,
                                                        state.subdir, inputfile)
-        output = kwargs['output']
-        ifile_abs = inputfile.absolute_path(state.environment.source_dir,
-                                            state.environment.build_dir)
-        values = mesonlib.get_filenames_templates_dict([ifile_abs], None)
-        outputs = mesonlib.substitute_values([output], values)
-        output = outputs[0]
-
-        ct = build.CustomTarget(output + '_' + state.subdir + '_merge', state.subdir, state.subproject, kwargs)
+            output = kwargs['output']
+            ifile_abs = inputfile.absolute_path(state.environment.source_dir,
+                                                state.environment.build_dir)
+            values = mesonlib.get_filenames_templates_dict([ifile_abs], None)
+            outputs = mesonlib.substitute_values([output], values)
+            output = outputs[0]
+            ct = build.CustomTarget(output + '_' + state.subdir + '_merge', state.subdir, state.subproject, kwargs)
         return ModuleReturnValue(ct, [ct])
 
     @FeatureNewKwargs('i18n.gettext', '0.37.0', ['preset'])


Test patch:
diff --git a/test cases/frameworks/6 gettext/generated/desktopgenerator.py b/test cases/frameworks/6 gettext/generated/desktopgenerator.py
new file mode 100644
--- /dev/null
+++ b/test cases/frameworks/6 gettext/generated/desktopgenerator.py	
@@ -0,0 +1,9 @@
+#!/usr/bin/env python3
+
+import sys, shutil
+
+ifile = sys.argv[1]
+ofile = sys.argv[2]
+
+os.unlink(ofile)
+shutil.copy(ifile, ofile)
diff --git a/test cases/frameworks/6 gettext/generated/meson.build b/test cases/frameworks/6 gettext/generated/meson.build
new file mode 100644
--- /dev/null
+++ b/test cases/frameworks/6 gettext/generated/meson.build	
@@ -0,0 +1,14 @@
+dgen = find_program('desktopgenerator.py')
+
+desktop_in_file = custom_target('something.desktop.in',
+  input : ['something.desktop.in.in'],
+  output : 'something.desktop.in',
+  command : [dgen, '@INPUT@', '@OUTPUT@'],
+)
+
+i18n.merge_file(
+  input : desktop_in_file,
+  output : 'something.desktop',
+  type : 'desktop',
+  po_dir : '../po',
+)
diff --git a/test cases/frameworks/6 gettext/generated/something.desktop.in.in b/test cases/frameworks/6 gettext/generated/something.desktop.in.in
new file mode 100644
--- /dev/null
+++ b/test cases/frameworks/6 gettext/generated/something.desktop.in.in	
@@ -0,0 +1,15 @@
+[Desktop Entry]
+Name=Something doer
+Comment=Do something
+# Translators: Search terms to find this application. Do NOT translate or localize the semicolons! The list MUST also end with a semicolon!
+Keywords=zip;tar;extract;unpack;
+TryExec=file-roller
+Exec=file-roller %U
+StartupNotify=true
+Terminal=false
+Type=Application
+# Translators: Do NOT translate or transliterate this text (this is an icon file name)!
+Icon=something
+Categories=GTK;GNOME;Utility
+X-GNOME-DocPath=file-roller/file-roller.xml
+X-GNOME-UsesNotifications=true
diff --git a/test cases/frameworks/6 gettext/meson.build b/test cases/frameworks/6 gettext/meson.build
--- a/test cases/frameworks/6 gettext/meson.build	
+++ b/test cases/frameworks/6 gettext/meson.build	
@@ -15,3 +15,4 @@ subdir('po')
 subdir('src')
 subdir('data')
 subdir('data2')
+subdir('generated')