Handle missing kotlinc gracefully

This commit is contained in:
Chris Smowton
2022-05-19 21:54:18 +01:00
parent f918b2e763
commit d9f65fe34f
2 changed files with 11 additions and 1 deletions

View File

@@ -201,6 +201,10 @@ def compile_standalone(version):
'build/temp_src',
version)
if shutil.which(kotlinc) == None:
print("Cannot build the Kotlin extractor: no '%s' found on your PATH" % kotlinc, file = sys.stderr)
sys.exit(1)
if args.many:
for version in kotlin_plugin_versions.many_versions:
compile_standalone(version)

View File

@@ -22,9 +22,15 @@ many_versions = [ '1.4.32', '1.5.31', '1.6.10', '1.6.20' ]
many_versions_tuples = [version_string_to_tuple(v) for v in many_versions]
class KotlincNotFoundException(Exception):
pass
def get_single_version(fakeVersionOutput = None):
# TODO: `shell=True` is a workaround to get CI working on Windows. It breaks the build on Linux.
versionOutput = subprocess.run(['kotlinc', '-version'], stdout=subprocess.PIPE, stderr=subprocess.PIPE, universal_newlines=True, shell=is_windows()).stderr if fakeVersionOutput is None else fakeVersionOutput
try:
versionOutput = subprocess.run(['kotlinc', '-version'], stdout=subprocess.PIPE, stderr=subprocess.PIPE, universal_newlines=True, shell=is_windows()).stderr if fakeVersionOutput is None else fakeVersionOutput
except FileNotFoundError as e:
raise KotlincNotFoundException(e)
m = re.match(r'.* kotlinc-jvm ([0-9]+\.[0-9]+\.[0-9]+) .*', versionOutput)
if m is None:
raise Exception('Cannot detect version of kotlinc (got ' + str(versionOutput) + ')')