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 if skipofiles
and w
[-2:] == '.o':
49 if w
[0] != '-' and w
[-2:] in ('.o', '.a'):
50 w
= os
.path
.join(e
, w
)
54 cc_flags
= ['-I', '-D', '-U']
55 cc_exts
= ['.c', '.C', '.cc', '.c++']
61 return w
# Assume loader flag
62 head
, tail
= os
.path
.split(w
)
63 base
, ext
= os
.path
.splitext(tail
)
66 w
= os
.path
.join(head
, tail
)
69 def expandvars(str, vars):
72 i
= k
= string
.find(str, '$', i
)
79 j
= string
.find(str, ')', i
)
85 str = str[:k
] + vars[var
] + str[i
:]