Brad Bishop | 1a4b7ee | 2018-12-16 17:11:34 -0800 | [diff] [blame^] | 1 | From 3ac4e58c5494bd7e603a325b5b5c2b8075849fee Mon Sep 17 00:00:00 2001 |
Brad Bishop | 316dfdd | 2018-06-25 12:45:53 -0400 | [diff] [blame] | 2 | From: Alexander Kanavin <alex.kanavin@gmail.com> |
| 3 | Date: Fri, 4 Aug 2017 16:16:41 +0300 |
Brad Bishop | 1a4b7ee | 2018-12-16 17:11:34 -0800 | [diff] [blame^] | 4 | Subject: [PATCH] gtkdoc: fix issues that arise when cross-compiling |
Brad Bishop | 316dfdd | 2018-06-25 12:45:53 -0400 | [diff] [blame] | 5 | |
| 6 | Specifically: |
| 7 | 1) Make it possible to specify a wrapper for executing binaries |
| 8 | (usually, some kind of target hardware emulator, such as qemu) |
| 9 | 2) Explicitly provide CC and LD via command line, as otherwise gtk-doc will |
| 10 | try to guess them, incorrectly. |
| 11 | 3) If things break down, print the full command with arguments, |
| 12 | not just the binary name. |
| 13 | 4) Correctly determine the compiler/linker executables and cross-options when cross-compiling |
| 14 | |
| 15 | Upstream-Status: Pending |
| 16 | Signed-off-by: Alexander Kanavin <alex.kanavin@gmail.com> |
| 17 | |
| 18 | --- |
| 19 | mesonbuild/modules/gnome.py | 18 +++++++++++++++--- |
| 20 | mesonbuild/scripts/gtkdochelper.py | 9 +++++++-- |
| 21 | 2 files changed, 22 insertions(+), 5 deletions(-) |
| 22 | |
| 23 | diff --git a/mesonbuild/modules/gnome.py b/mesonbuild/modules/gnome.py |
Brad Bishop | 1a4b7ee | 2018-12-16 17:11:34 -0800 | [diff] [blame^] | 24 | index cb69641..727eb6a 100644 |
Brad Bishop | 316dfdd | 2018-06-25 12:45:53 -0400 | [diff] [blame] | 25 | --- a/mesonbuild/modules/gnome.py |
| 26 | +++ b/mesonbuild/modules/gnome.py |
Brad Bishop | 1a4b7ee | 2018-12-16 17:11:34 -0800 | [diff] [blame^] | 27 | @@ -792,6 +792,10 @@ This will become a hard error in the future.''') |
Brad Bishop | 316dfdd | 2018-06-25 12:45:53 -0400 | [diff] [blame] | 28 | '--mode=' + mode] |
| 29 | if namespace: |
| 30 | args.append('--namespace=' + namespace) |
| 31 | + gtkdoc_exe_wrapper = state.environment.cross_info.config["properties"].get('gtkdoc_exe_wrapper', None) |
| 32 | + if gtkdoc_exe_wrapper is not None: |
| 33 | + args.append('--gtkdoc-exe-wrapper=' + gtkdoc_exe_wrapper) |
| 34 | + |
| 35 | args += self._unpack_args('--htmlargs=', 'html_args', kwargs) |
| 36 | args += self._unpack_args('--scanargs=', 'scan_args', kwargs) |
| 37 | args += self._unpack_args('--scanobjsargs=', 'scanobjs_args', kwargs) |
Brad Bishop | 316dfdd | 2018-06-25 12:45:53 -0400 | [diff] [blame] | 38 | diff --git a/mesonbuild/scripts/gtkdochelper.py b/mesonbuild/scripts/gtkdochelper.py |
Brad Bishop | 1a4b7ee | 2018-12-16 17:11:34 -0800 | [diff] [blame^] | 39 | index 948dc5a..9c5bd19 100644 |
Brad Bishop | 316dfdd | 2018-06-25 12:45:53 -0400 | [diff] [blame] | 40 | --- a/mesonbuild/scripts/gtkdochelper.py |
| 41 | +++ b/mesonbuild/scripts/gtkdochelper.py |
Brad Bishop | 1a4b7ee | 2018-12-16 17:11:34 -0800 | [diff] [blame^] | 42 | @@ -45,6 +45,7 @@ parser.add_argument('--ignore-headers', dest='ignore_headers', default='') |
Brad Bishop | 316dfdd | 2018-06-25 12:45:53 -0400 | [diff] [blame] | 43 | parser.add_argument('--namespace', dest='namespace', default='') |
| 44 | parser.add_argument('--mode', dest='mode', default='') |
| 45 | parser.add_argument('--installdir', dest='install_dir') |
| 46 | +parser.add_argument('--gtkdoc-exe-wrapper', dest='gtkdoc_exe_wrapper') |
| 47 | |
Brad Bishop | 1a4b7ee | 2018-12-16 17:11:34 -0800 | [diff] [blame^] | 48 | def gtkdoc_run_check(cmd, cwd, library_paths=None): |
| 49 | if library_paths is None: |
| 50 | @@ -64,7 +65,7 @@ def gtkdoc_run_check(cmd, cwd, library_paths=None): |
Brad Bishop | 316dfdd | 2018-06-25 12:45:53 -0400 | [diff] [blame] | 51 | # This preserves the order of messages. |
Brad Bishop | 1a4b7ee | 2018-12-16 17:11:34 -0800 | [diff] [blame^] | 52 | p, out = Popen_safe(cmd, cwd=cwd, env=env, stderr=subprocess.STDOUT)[0:2] |
Brad Bishop | 316dfdd | 2018-06-25 12:45:53 -0400 | [diff] [blame] | 53 | if p.returncode != 0: |
| 54 | - err_msg = ["{!r} failed with status {:d}".format(cmd[0], p.returncode)] |
| 55 | + err_msg = ["{!r} failed with status {:d}".format(cmd, p.returncode)] |
| 56 | if out: |
| 57 | err_msg.append(out) |
| 58 | raise MesonException('\n'.join(err_msg)) |
Brad Bishop | 1a4b7ee | 2018-12-16 17:11:34 -0800 | [diff] [blame^] | 59 | @@ -74,7 +75,7 @@ def gtkdoc_run_check(cmd, cwd, library_paths=None): |
Brad Bishop | 316dfdd | 2018-06-25 12:45:53 -0400 | [diff] [blame] | 60 | def build_gtkdoc(source_root, build_root, doc_subdir, src_subdirs, |
| 61 | main_file, module, |
| 62 | html_args, scan_args, fixxref_args, mkdb_args, |
| 63 | - gobject_typesfile, scanobjs_args, ld, cc, ldflags, cflags, |
| 64 | + gobject_typesfile, scanobjs_args, gtkdoc_exe_wrapper, ld, cc, ldflags, cflags, |
| 65 | html_assets, content_files, ignore_headers, namespace, |
| 66 | expand_content_files, mode): |
| 67 | print("Building documentation for %s" % module) |
Brad Bishop | 1a4b7ee | 2018-12-16 17:11:34 -0800 | [diff] [blame^] | 68 | @@ -135,6 +136,9 @@ def build_gtkdoc(source_root, build_root, doc_subdir, src_subdirs, |
Brad Bishop | 316dfdd | 2018-06-25 12:45:53 -0400 | [diff] [blame] | 69 | if gobject_typesfile: |
| 70 | scanobjs_cmd = ['gtkdoc-scangobj'] + scanobjs_args + ['--types=' + gobject_typesfile, |
| 71 | '--module=' + module, |
| 72 | + '--run=' + gtkdoc_exe_wrapper, |
| 73 | + '--cc=' + cc, |
| 74 | + '--ld=' + ld, |
| 75 | '--cflags=' + cflags, |
| 76 | '--ldflags=' + ldflags, |
Brad Bishop | 1a4b7ee | 2018-12-16 17:11:34 -0800 | [diff] [blame^] | 77 | '--cc=' + cc, |
| 78 | @@ -238,6 +242,7 @@ def run(args): |
Brad Bishop | 316dfdd | 2018-06-25 12:45:53 -0400 | [diff] [blame] | 79 | mkdbargs, |
| 80 | options.gobject_typesfile, |
| 81 | scanobjsargs, |
| 82 | + options.gtkdoc_exe_wrapper, |
| 83 | options.ld, |
| 84 | options.cc, |
| 85 | options.ldflags, |