0004-giscanner-add-use-binary-wrapper-option.patch 2.3 KB

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