lang -> source_ext since it is now file extension not language name

This commit is contained in:
Kovid Goyal 2021-09-30 14:25:48 +05:30
parent abf6a3f91d
commit 7530bfd1a1
No known key found for this signature in database
GPG Key ID: 06BC317B515ACE7C

View File

@ -232,7 +232,7 @@ def get_sanitize_args(cc: str, ccver: Tuple[int, int]) -> List[str]:
def test_compile( def test_compile(
cc: str, *cflags: str, cc: str, *cflags: str,
src: str = '', src: str = '',
lang: str = 'c', source_ext: str = 'c',
link_also: bool = True, link_also: bool = True,
show_stderr: bool = False, show_stderr: bool = False,
libraries: Iterable[str] = (), libraries: Iterable[str] = (),
@ -240,7 +240,7 @@ def test_compile(
) -> bool: ) -> bool:
src = src or 'int main(void) { return 0; }' src = src or 'int main(void) { return 0; }'
with tempfile.TemporaryDirectory(prefix='kitty-test-compile-') as tdir: with tempfile.TemporaryDirectory(prefix='kitty-test-compile-') as tdir:
with open(os.path.join(tdir, f'source.{lang}'), 'w', encoding='utf-8') as srcf: with open(os.path.join(tdir, f'source.{source_ext}'), 'w', encoding='utf-8') as srcf:
print(src, file=srcf) print(src, file=srcf)
return subprocess.Popen( return subprocess.Popen(
[cc] + list(cflags) + ([] if link_also else ['-c']) + [cc] + list(cflags) + ([] if link_also else ['-c']) +
@ -251,9 +251,9 @@ def test_compile(
).wait() == 0 ).wait() == 0
def first_successful_compile(cc: str, *cflags: str, src: str = '', lang: str = 'c') -> str: def first_successful_compile(cc: str, *cflags: str, src: str = '', source_ext: str = 'c') -> str:
for x in cflags: for x in cflags:
if test_compile(cc, *shlex.split(x), src=src, lang=lang): if test_compile(cc, *shlex.split(x), src=src, source_ext=source_ext):
return x return x
return '' return ''
@ -411,7 +411,7 @@ def kitty_env() -> Env:
test_program_src = '''#include <UserNotifications/UserNotifications.h> test_program_src = '''#include <UserNotifications/UserNotifications.h>
int main(void) { return 0; }\n''' int main(void) { return 0; }\n'''
user_notifications_framework = first_successful_compile( user_notifications_framework = first_successful_compile(
ans.cc, '-framework UserNotifications', src=test_program_src, lang='m') ans.cc, '-framework UserNotifications', src=test_program_src, source_ext='m')
if user_notifications_framework: if user_notifications_framework:
platform_libs.extend(shlex.split(user_notifications_framework)) platform_libs.extend(shlex.split(user_notifications_framework))
else: else: