aboutsummaryrefslogtreecommitdiffstats
path: root/meta/recipes-gnome/gobject-introspection/gobject-introspection/0003-giscanner-add-use-binary-wrapper-option.patch
blob: f21eaca855677f4352d3bf81ba5b4776cba11952 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
From 704b888d0abfb01067352c40156f49f655691c7c Mon Sep 17 00:00:00 2001
From: Alexander Kanavin <alex.kanavin@gmail.com>
Date: Mon, 19 Oct 2015 18:26:40 +0300
Subject: [PATCH 3/5] giscanner: add --use-binary-wrapper option

With this option, giscanner will use a wrapper executable to run
binaries it's producing, instead of running them directly. This
is useful when binaries are cross-compiled and cannot be run directly,
but they can be run using for example QEMU emulation.

Upstream-Status: Pending [review on oe-core list]
Signed-off-by: Alexander Kanavin <alex.kanavin@gmail.com>
---
 giscanner/scannermain.py | 14 ++++++++++++++
 1 file changed, 14 insertions(+)

diff --git a/giscanner/scannermain.py b/giscanner/scannermain.py
index 633496f..d684cd0 100755
--- a/giscanner/scannermain.py
+++ b/giscanner/scannermain.py
@@ -124,6 +124,9 @@ def _get_option_parser():
     parser.add_option("", "--program",
                       action="store", dest="program", default=None,
                       help="program to execute")
+    parser.add_option("", "--use-binary-wrapper",
+                      action="store", dest="wrapper", default=None,
+                      help="wrapper to use for running programs (useful when cross-compiling)")
     parser.add_option("", "--program-arg",
                       action="append", dest="program_args", default=[],
                       help="extra arguments to program")
@@ -419,6 +422,17 @@ def create_binary(transformer, options, args):
                                               gdump_parser.get_error_quark_functions())
 
     shlibs = resolve_shlibs(options, binary, options.libraries)
+    if options.wrapper:
+        # The wrapper needs the binary itself, not the libtool wrapper script,
+        # so we check if libtool has sneaked the binary into .libs subdirectory
+        # and adjust the path accordingly
+        import os.path
+        dir_name, binary_name  = os.path.split(binary.args[0])
+        libtool_binary = os.path.join(dir_name, '.libs', binary_name)
+        if os.path.exists(libtool_binary):
+            binary.args[0] = libtool_binary
+	# Then prepend the wrapper to the command line to execute
+        binary.args = [options.wrapper] + binary.args
     gdump_parser.set_introspection_binary(binary)
     gdump_parser.parse()
     return shlibs
-- 
2.7.0