lol
1--- a/giscanner/scannermain.py
2+++ b/giscanner/scannermain.py
3@@ -100,6 +100,39 @@
4 return group
5
6
7+def _get_default_fallback_libpath():
8+ # Newer multiple-output-optimized stdenv has an environment variable
9+ # $outputLib which in turn specifies another variable which then is used as
10+ # the destination for the library contents (${!outputLib}/lib).
11+ store_path = os.environ.get(os.environ.get("outputLib"))
12+ if store_path is None:
13+ outputs = os.environ.get("outputs", "out").split()
14+ if "lib" in outputs:
15+ # For multiple output derivations let's try whether there is a $lib
16+ # environment variable and use that as the base store path.
17+ store_path = os.environ.get("lib")
18+ elif "out" in outputs:
19+ # Otherwise we have a single output derivation, so the libraries
20+ # most certainly will end up in "$out/lib".
21+ store_path = os.environ.get("out")
22+
23+ if store_path is not None:
24+ # Even if we have a $lib as output, there still should be a $lib/lib
25+ # directory.
26+ return os.path.join(store_path, 'lib')
27+ else:
28+ # If we haven't found a possible scenario, let's return an empty string
29+ # so that the shared library won't be prepended with a path.
30+ #
31+ # Note that this doesn't mean that all hope is lost, because after all
32+ # we can still use --fallback-library-path to set one.
33+ #
34+ # Also, we're not returning None, because that would make it very
35+ # difficult to disable adding fallback paths altogether using something
36+ # like: --fallback-library-path=""
37+ return ""
38+
39+
40 def _get_option_parser():
41 parser = optparse.OptionParser('%prog [options] sources')
42 parser.add_option('', "--quiet",
43@@ -209,6 +242,10 @@
44 parser.add_option("", "--filelist",
45 action="store", dest="filelist", default=[],
46 help="file containing headers and sources to be scanned")
47+ parser.add_option("", "--fallback-library-path",
48+ action="store", dest="fallback_libpath",
49+ default=_get_default_fallback_libpath(),
50+ help="Path to prepend to unknown shared libraries")
51
52 group = get_preprocessor_option_group(parser)
53 parser.add_option_group(group)
54--- a/giscanner/shlibs.py
55+++ b/giscanner/shlibs.py
56@@ -63,6 +63,11 @@
57 pattern = "([^\s]*lib*%s[^A-Za-z0-9_-][^\s\(\)]*)"
58 return re.compile(pattern % re.escape(library_name))
59
60+def _ldd_library_nix_pattern(library_name):
61+ nix_store_dir = re.escape('@nixStoreDir@'.rstrip('/'))
62+ pattern = r'(%s(?:/[^/]*)+lib%s[^A-Za-z0-9_-][^\s\(\)]*)'
63+ return re.compile(pattern % (nix_store_dir, re.escape(library_name)))
64+
65
66 # This is a what we do for non-la files. We assume that we are on an
67 # ELF-like system where ldd exists and the soname extracted with ldd is
68@@ -112,7 +117,7 @@
69 proc = subprocess.Popen(args, stdout=subprocess.PIPE)
70 patterns = {}
71 for library in libraries:
72- patterns[library] = _ldd_library_pattern(library)
73+ patterns[library] = (_ldd_library_pattern(library), _ldd_library_nix_pattern(library))
74
75 shlibs = []
76 for line in proc.stdout:
77@@ -122,11 +127,14 @@
78 # possible for the name of the binary to match _ldd_library_pattern.
79 if line == binary.args[0] + ':\n':
80 continue
81- for library, pattern in patterns.items():
82- m = pattern.search(line)
83+ for library, (pattern, nix_pattern) in patterns.items():
84+ if line.find('@nixStoreDir@') != -1:
85+ m = nix_pattern.search(line)
86+ else:
87+ m = pattern.search(line)
88 if m:
89 del patterns[library]
90- shlibs.append(m.group(1))
91+ shlibs.append(os.path.join(options.fallback_libpath, m.group(1)))
92 break
93
94 if len(patterns) > 0:
95--- a/giscanner/utils.py
96+++ b/giscanner/utils.py
97@@ -113,17 +113,11 @@
98 if dlname is None:
99 return None
100
101- # Darwin uses absolute paths where possible; since the libtool files never
102- # contain absolute paths, use the libdir field
103- if platform.system() == 'Darwin':
104- dlbasename = os.path.basename(dlname)
105- libdir = _extract_libdir_field(la_file)
106- if libdir is None:
107- return dlbasename
108- return libdir + '/' + dlbasename
109- # From the comments in extract_libtool(), older libtools had
110- # a path rather than the raw dlname
111- return os.path.basename(dlname)
112+ dlbasename = os.path.basename(dlname)
113+ libdir = _extract_libdir_field(la_file)
114+ if libdir is None:
115+ return dlbasename
116+ return libdir + '/' + dlbasename
117
118
119 def extract_libtool(la_file):