From ea9b431386e31e36b7c9dec62b5fa818396923bf Mon Sep 17 00:00:00 2001 From: Kovid Goyal Date: Fri, 20 Apr 2018 21:02:05 +0530 Subject: [PATCH] Allow changing the source used by test_compile --- setup.py | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/setup.py b/setup.py index 4c0f95992..7c3ad93a3 100755 --- a/setup.py +++ b/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 ''