1 From 704b888d0abfb01067352c40156f49f655691c7c Mon Sep 17 00:00:00 2001
2 From: Alexander Kanavin <alex.kanavin@gmail.com>
3 Date: Mon, 19 Oct 2015 18:26:40 +0300
4 Subject: [PATCH 3/5] giscanner: add --use-binary-wrapper option
6 With this option, giscanner will use a wrapper executable to run
7 binaries it's producing, instead of running them directly. This
8 is useful when binaries are cross-compiled and cannot be run directly,
9 but they can be run using for example QEMU emulation.
11 Upstream-Status: Pending [review on oe-core list]
12 Signed-off-by: Alexander Kanavin <alex.kanavin@gmail.com>
14 giscanner/scannermain.py | 14 ++++++++++++++
15 1 file changed, 14 insertions(+)
17 diff --git a/giscanner/scannermain.py b/giscanner/scannermain.py
18 index 633496f..d684cd0 100755
19 --- a/giscanner/scannermain.py
20 +++ b/giscanner/scannermain.py
21 @@ -124,6 +124,9 @@ def _get_option_parser():
22 parser.add_option("", "--program",
23 action="store", dest="program", default=None,
24 help="program to execute")
25 + parser.add_option("", "--use-binary-wrapper",
26 + action="store", dest="wrapper", default=None,
27 + help="wrapper to use for running programs (useful when cross-compiling)")
28 parser.add_option("", "--program-arg",
29 action="append", dest="program_args", default=[],
30 help="extra arguments to program")
31 @@ -419,6 +422,17 @@ def create_binary(transformer, options, args):
32 gdump_parser.get_error_quark_functions())
34 shlibs = resolve_shlibs(options, binary, options.libraries)
36 + # The wrapper needs the binary itself, not the libtool wrapper script,
37 + # so we check if libtool has sneaked the binary into .libs subdirectory
38 + # and adjust the path accordingly
40 + dir_name, binary_name = os.path.split(binary.args[0])
41 + libtool_binary = os.path.join(dir_name, '.libs', binary_name)
42 + if os.path.exists(libtool_binary):
43 + binary.args[0] = libtool_binary
44 + # Then prepend the wrapper to the command line to execute
45 + binary.args = [options.wrapper] + binary.args
46 gdump_parser.set_introspection_binary(binary)