Brad Bishop | 316dfdd | 2018-06-25 12:45:53 -0400 | [diff] [blame] | 1 | From e48f1e18f5ea41656f0ba10fe61d69d2604b0064 Mon Sep 17 00:00:00 2001 |
| 2 | From: Alexander Kanavin <alex.kanavin@gmail.com> |
| 3 | Date: Wed, 3 Jan 2018 17:02:01 +0200 |
| 4 | Subject: [PATCH] giscanner: add a --lib-dirs-envvar option |
| 5 | |
| 6 | By default LD_LIBRARY_PATH is set to the list of target library paths; |
| 7 | this breaks down in cross-compilation environment, as we need to run a |
| 8 | native emulation wrapper rather than the target binary itself. This patch |
| 9 | allows exporting those paths to a different environment variable |
| 10 | which can be picked up and used by the wrapper. |
| 11 | |
| 12 | Upstream-Status: Pending |
| 13 | Signed-off-by: Alexander Kanavin <alex.kanavin@gmail.com> |
| 14 | |
| 15 | --- |
| 16 | giscanner/ccompiler.py | 4 ++-- |
| 17 | giscanner/dumper.py | 3 ++- |
| 18 | giscanner/scannermain.py | 3 +++ |
| 19 | 3 files changed, 7 insertions(+), 3 deletions(-) |
| 20 | |
| 21 | diff --git a/giscanner/ccompiler.py b/giscanner/ccompiler.py |
| 22 | index 29de0ee..928eae8 100644 |
| 23 | --- a/giscanner/ccompiler.py |
| 24 | +++ b/giscanner/ccompiler.py |
| 25 | @@ -109,7 +109,7 @@ class CCompiler(object): |
| 26 | |
| 27 | self._cflags_no_deprecation_warnings = "-Wno-deprecated-declarations" |
| 28 | |
| 29 | - def get_internal_link_flags(self, args, libtool, libraries, extra_libraries, libpaths): |
| 30 | + def get_internal_link_flags(self, args, libtool, libraries, extra_libraries, libpaths, lib_dirs_envvar): |
| 31 | # An "internal" link is where the library to be introspected |
| 32 | # is being built in the current directory. |
| 33 | |
| 34 | @@ -119,7 +119,7 @@ class CCompiler(object): |
| 35 | if self.check_is_msvc(): |
| 36 | runtime_path_envvar = ['LIB', 'PATH'] |
| 37 | else: |
| 38 | - runtime_path_envvar = ['LD_LIBRARY_PATH'] |
| 39 | + runtime_path_envvar = ['LD_LIBRARY_PATH'] if not lib_dirs_envvar else [lib_dirs_envvar] |
| 40 | # Search the current directory first |
| 41 | # (This flag is not supported nor needed for Visual C++) |
| 42 | args.append('-L.') |
| 43 | diff --git a/giscanner/dumper.py b/giscanner/dumper.py |
| 44 | index 7f77bd2..db96df6 100644 |
| 45 | --- a/giscanner/dumper.py |
| 46 | +++ b/giscanner/dumper.py |
| 47 | @@ -259,7 +259,8 @@ class DumpCompiler(object): |
| 48 | libtool, |
| 49 | self._options.libraries, |
| 50 | self._options.extra_libraries, |
| 51 | - self._options.library_paths) |
| 52 | + self._options.library_paths, |
| 53 | + self._options.lib_dirs_envvar) |
| 54 | args.extend(pkg_config_libs) |
| 55 | |
| 56 | else: |
| 57 | diff --git a/giscanner/scannermain.py b/giscanner/scannermain.py |
| 58 | index 38a45c1..b603850 100755 |
| 59 | --- a/giscanner/scannermain.py |
| 60 | +++ b/giscanner/scannermain.py |
| 61 | @@ -130,6 +130,9 @@ def _get_option_parser(): |
| 62 | parser.add_option("", "--use-ldd-wrapper", |
| 63 | action="store", dest="ldd_wrapper", default=None, |
| 64 | help="wrapper to use instead of ldd (useful when cross-compiling)") |
| 65 | + parser.add_option("", "--lib-dirs-envvar", |
| 66 | + action="store", dest="lib_dirs_envvar", default=None, |
| 67 | + help="environment variable to write a list of library directories to (for running the transient binary), instead of standard LD_LIBRARY_PATH") |
| 68 | parser.add_option("", "--program-arg", |
| 69 | action="append", dest="program_args", default=[], |
| 70 | help="extra arguments to program") |
| 71 | -- |
| 72 | 2.15.1 |
| 73 | |