1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24 __revision__ = "src/engine/SCons/Scanner/Prog.py rel_2.4.0:3365:9259ea1c13d7 2015/09/21 14:03:43 bdbaddog"
25
26 import SCons.Node
27 import SCons.Node.FS
28 import SCons.Scanner
29 import SCons.Util
30
31
32 print_find_libs = None
33
35 """Return a prototype Scanner instance for scanning executable
36 files for static-lib dependencies"""
37 kw['path_function'] = SCons.Scanner.FindPathDirs('LIBPATH')
38 ps = SCons.Scanner.Base(scan, "ProgramScanner", **kw)
39 return ps
40
42 """
43 Substitute environment variables and split into list.
44 """
45 if SCons.Util.is_String(libs):
46 libs = env.subst(libs)
47 if SCons.Util.is_String(libs):
48 libs = libs.split()
49 elif SCons.Util.is_Sequence(libs):
50 _libs = []
51 for l in libs:
52 _libs += _subst_libs(env, l)
53 libs = _libs
54 else:
55
56 libs = [libs]
57 return libs
58
59 -def scan(node, env, libpath = ()):
60 """
61 This scanner scans program files for static-library
62 dependencies. It will search the LIBPATH environment variable
63 for libraries specified in the LIBS variable, returning any
64 files it finds as dependencies.
65 """
66 try:
67 libs = env['LIBS']
68 except KeyError:
69
70 return []
71
72 libs = _subst_libs(env, libs)
73
74 try:
75 prefix = env['LIBPREFIXES']
76 if not SCons.Util.is_List(prefix):
77 prefix = [ prefix ]
78 except KeyError:
79 prefix = [ '' ]
80
81 try:
82 suffix = env['LIBSUFFIXES']
83 if not SCons.Util.is_List(suffix):
84 suffix = [ suffix ]
85 except KeyError:
86 suffix = [ '' ]
87
88 pairs = []
89 for suf in map(env.subst, suffix):
90 for pref in map(env.subst, prefix):
91 pairs.append((pref, suf))
92
93 result = []
94
95 if callable(libpath):
96 libpath = libpath()
97
98 find_file = SCons.Node.FS.find_file
99 adjustixes = SCons.Util.adjustixes
100 for lib in libs:
101 if SCons.Util.is_String(lib):
102 for pref, suf in pairs:
103 l = adjustixes(lib, pref, suf)
104 l = find_file(l, libpath, verbose=print_find_libs)
105 if l:
106 result.append(l)
107 else:
108 result.append(lib)
109
110 return result
111
112
113
114
115
116
117