1 # Check for a module in a set of extension directories.
2 # An extension directory should contain a Setup file
3 # and one or more .o files or a lib.a file.
9 def checkextensions(unknown
, extensions
):
14 setup
= os
.path
.join(e
, 'Setup')
15 liba
= os
.path
.join(e
, 'lib.a')
16 if not os
.path
.isfile(liba
):
18 edict
[e
] = parsesetup
.getsetupinfo(setup
), liba
21 (mods
, vars), liba
= edict
[e
]
22 if not mods
.has_key(mod
):
26 # If we find a lib.a, use it, ignore the
27 # .o files, and use *all* libraries for
28 # *all* modules in the Setup file
33 files
= files
+ select(e
, mods
, vars,
36 files
= files
+ select(e
, mods
, vars, mod
, 0)
40 def select(e
, mods
, vars, mod
, skipofiles
):
46 w
= expandvars(w
, vars)
47 for w
in string
.split(w
):
48 if skipofiles
and w
[-2:] == '.o':
50 # Assume $var expands to absolute pathname
51 if w
[0] not in ('-', '$') and w
[-2:] in ('.o', '.a'):
52 w
= os
.path
.join(e
, w
)
53 if w
[:2] in ('-L', '-R') and w
[2:3] != '$':
54 w
= w
[:2] + os
.path
.join(e
, w
[2:])
58 cc_flags
= ['-I', '-D', '-U']
59 cc_exts
= ['.c', '.C', '.cc', '.c++']
65 return w
# Assume loader flag
66 head
, tail
= os
.path
.split(w
)
67 base
, ext
= os
.path
.splitext(tail
)
70 w
= os
.path
.join(head
, tail
)
73 def expandvars(str, vars):
76 i
= k
= string
.find(str, '$', i
)
83 j
= string
.find(str, ')', i
)
89 str = str[:k
] + vars[var
] + str[i
:]