Brad Bishop | c342db3 | 2019-05-15 21:57:59 -0400 | [diff] [blame] | 1 | From 5f985fd8a24764ccb38af6335d4584d7e33fc3a1 Mon Sep 17 00:00:00 2001 |
Patrick Williams | c0f7c04 | 2017-02-23 20:41:17 -0600 | [diff] [blame] | 2 | From: Alexander Kanavin <alex.kanavin@gmail.com> |
| 3 | Date: Mon, 19 Oct 2015 18:26:40 +0300 |
Brad Bishop | 1a4b7ee | 2018-12-16 17:11:34 -0800 | [diff] [blame] | 4 | Subject: [PATCH] giscanner: add --use-binary-wrapper option |
Patrick Williams | c0f7c04 | 2017-02-23 20:41:17 -0600 | [diff] [blame] | 5 | |
| 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. |
| 10 | |
| 11 | Upstream-Status: Pending [review on oe-core list] |
| 12 | Signed-off-by: Alexander Kanavin <alex.kanavin@gmail.com> |
Brad Bishop | 1a4b7ee | 2018-12-16 17:11:34 -0800 | [diff] [blame] | 13 | |
Patrick Williams | c0f7c04 | 2017-02-23 20:41:17 -0600 | [diff] [blame] | 14 | --- |
| 15 | giscanner/scannermain.py | 14 ++++++++++++++ |
| 16 | 1 file changed, 14 insertions(+) |
| 17 | |
| 18 | diff --git a/giscanner/scannermain.py b/giscanner/scannermain.py |
Brad Bishop | c342db3 | 2019-05-15 21:57:59 -0400 | [diff] [blame] | 19 | index c004fb1..0b6a2d2 100644 |
Patrick Williams | c0f7c04 | 2017-02-23 20:41:17 -0600 | [diff] [blame] | 20 | --- a/giscanner/scannermain.py |
| 21 | +++ b/giscanner/scannermain.py |
Brad Bishop | c342db3 | 2019-05-15 21:57:59 -0400 | [diff] [blame] | 22 | @@ -120,6 +120,9 @@ def _get_option_parser(): |
Patrick Williams | c0f7c04 | 2017-02-23 20:41:17 -0600 | [diff] [blame] | 23 | parser.add_option("", "--program", |
| 24 | action="store", dest="program", default=None, |
| 25 | help="program to execute") |
| 26 | + parser.add_option("", "--use-binary-wrapper", |
| 27 | + action="store", dest="wrapper", default=None, |
| 28 | + help="wrapper to use for running programs (useful when cross-compiling)") |
| 29 | parser.add_option("", "--program-arg", |
| 30 | action="append", dest="program_args", default=[], |
| 31 | help="extra arguments to program") |
Brad Bishop | c342db3 | 2019-05-15 21:57:59 -0400 | [diff] [blame] | 32 | @@ -417,6 +420,17 @@ def create_binary(transformer, options, args): |
Patrick Williams | c0f7c04 | 2017-02-23 20:41:17 -0600 | [diff] [blame] | 33 | gdump_parser.get_error_quark_functions()) |
| 34 | |
| 35 | shlibs = resolve_shlibs(options, binary, options.libraries) |
| 36 | + if options.wrapper: |
| 37 | + # The wrapper needs the binary itself, not the libtool wrapper script, |
| 38 | + # so we check if libtool has sneaked the binary into .libs subdirectory |
| 39 | + # and adjust the path accordingly |
| 40 | + import os.path |
| 41 | + dir_name, binary_name = os.path.split(binary.args[0]) |
| 42 | + libtool_binary = os.path.join(dir_name, '.libs', binary_name) |
| 43 | + if os.path.exists(libtool_binary): |
| 44 | + binary.args[0] = libtool_binary |
| 45 | + # Then prepend the wrapper to the command line to execute |
| 46 | + binary.args = [options.wrapper] + binary.args |
| 47 | gdump_parser.set_introspection_binary(binary) |
| 48 | gdump_parser.parse() |
| 49 | return shlibs |