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.
8 def checkextensions(unknown
, extensions
):
13 setup
= os
.path
.join(e
, 'Setup')
14 liba
= os
.path
.join(e
, 'lib.a')
15 if not os
.path
.isfile(liba
):
17 edict
[e
] = parsesetup
.getsetupinfo(setup
), liba
20 (mods
, vars), liba
= edict
[e
]
21 if not mods
.has_key(mod
):
25 # If we find a lib.a, use it, ignore the
26 # .o files, and use *all* libraries for
27 # *all* modules in the Setup file
32 files
= files
+ select(e
, mods
, vars,
35 files
= files
+ select(e
, mods
, vars, mod
, 0)
39 def select(e
, mods
, vars, mod
, skipofiles
):
45 w
= expandvars(w
, vars)
47 if skipofiles
and w
[-2:] == '.o':
49 # Assume $var expands to absolute pathname
50 if w
[0] not in ('-', '$') and w
[-2:] in ('.o', '.a'):
51 w
= os
.path
.join(e
, w
)
52 if w
[:2] in ('-L', '-R') and w
[2:3] != '$':
53 w
= w
[:2] + os
.path
.join(e
, w
[2:])
57 cc_flags
= ['-I', '-D', '-U']
58 cc_exts
= ['.c', '.C', '.cc', '.c++']
64 return w
# Assume loader flag
65 head
, tail
= os
.path
.split(w
)
66 base
, ext
= os
.path
.splitext(tail
)
69 w
= os
.path
.join(head
, tail
)
72 def expandvars(str, vars):
75 i
= k
= str.find('$', i
)
88 str = str[:k
] + vars[var
] + str[i
:]