Cleanup any extra files produced by clang in debug mode when test compiling
This commit is contained in:
parent
d982a3c94e
commit
fe0d1034aa
20
setup.py
20
setup.py
@ -239,20 +239,20 @@ def test_compile(
|
|||||||
ldflags: Iterable[str] = (),
|
ldflags: Iterable[str] = (),
|
||||||
) -> bool:
|
) -> bool:
|
||||||
src = src or 'int main(void) { return 0; }'
|
src = src or 'int main(void) { return 0; }'
|
||||||
with tempfile.NamedTemporaryFile(prefix='kitty-test-compile-') as f:
|
with tempfile.TemporaryDirectory(prefix='kitty-test-compile-') as tdir:
|
||||||
p = subprocess.Popen(
|
p = subprocess.Popen(
|
||||||
[cc] + list(cflags) + ([] if link_also else ['-c']) + ['-x', lang, '-o', f.name, '-'] +
|
[cc] + list(cflags) + ([] if link_also else ['-c']) + ['-x', lang, '-o', os.path.join(tdir, 'dummy'), '-'] +
|
||||||
[f'-l{x}' for x in libraries] + list(ldflags),
|
[f'-l{x}' for x in libraries] + list(ldflags),
|
||||||
stdout=subprocess.DEVNULL, stdin=subprocess.PIPE, stderr=None if show_stderr else subprocess.DEVNULL
|
stdout=subprocess.DEVNULL, stdin=subprocess.PIPE, stderr=None if show_stderr else subprocess.DEVNULL
|
||||||
)
|
)
|
||||||
stdin = p.stdin
|
stdin = p.stdin
|
||||||
assert stdin is not None
|
assert stdin is not None
|
||||||
try:
|
try:
|
||||||
stdin.write((src + '\n').encode('utf-8'))
|
stdin.write((src + '\n').encode('utf-8'))
|
||||||
stdin.close()
|
stdin.close()
|
||||||
except BrokenPipeError:
|
except BrokenPipeError:
|
||||||
return False
|
return False
|
||||||
return p.wait() == 0
|
return p.wait() == 0
|
||||||
|
|
||||||
|
|
||||||
def first_successful_compile(cc: str, *cflags: str, src: Optional[str] = None, lang: str = 'c') -> str:
|
def first_successful_compile(cc: str, *cflags: str, src: Optional[str] = None, lang: str = 'c') -> str:
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user