Allow changing the source used by test_compile
This commit is contained in:
parent
23077fd6a6
commit
ea9b431386
9
setup.py
9
setup.py
@ -141,16 +141,17 @@ def get_sanitize_args(cc, ccver):
|
||||
return sanitize_args
|
||||
|
||||
|
||||
def test_compile(cc, *cflags):
|
||||
def test_compile(cc, *cflags, src=None):
|
||||
with tempfile.NamedTemporaryFile(suffix='.c') as f:
|
||||
f.write(b'int main(void) { return 0; }')
|
||||
src = src or 'int main(void) { return 0; }'
|
||||
f.write(src.encode('utf-8'))
|
||||
f.flush()
|
||||
return subprocess.Popen([cc] + list(cflags) + [f.name, '-o', os.devnull]).wait() == 0
|
||||
|
||||
|
||||
def first_successful_compile(cc, *cflags):
|
||||
def first_successful_compile(cc, *cflags, src=None):
|
||||
for x in cflags:
|
||||
if test_compile(cc, *shlex.split(x)):
|
||||
if test_compile(cc, *shlex.split(x), src=src):
|
||||
return x
|
||||
return ''
|
||||
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user