Kotlin: Build the appropriate single version, rather than always 1.5

This commit is contained in:
Ian Lynagh
2021-12-01 13:00:19 +00:00
parent abc0da3e60
commit 2dcd49c6a5
2 changed files with 15 additions and 2 deletions

View File

@@ -173,4 +173,4 @@ if args.many:
compile_standalone(version)
compile_embeddable(version)
else:
compile_standalone(kotlin_plugin_versions.single_version)
compile_standalone(kotlin_plugin_versions.get_single_version())

View File

@@ -1,2 +1,15 @@
import re
import subprocess
many_versions = [ '1.4.32', '1.5.31', '1.6.0-RC2' ]
single_version = '1.5.31'
def get_single_version():
versionOutput = subprocess.run(['kotlinc', '-version'], capture_output=True, text=True)
m = re.match(r'.* kotlinc-jvm ([0-9]+\.[0-9]+\.)[0-9]+ .*', versionOutput.stderr)
if m is None:
raise Exception('Cannot detect version of kotlinc')
prefix = m.group(1)
for version in many_versions:
if version.startswith(prefix):
return version
raise Exception('No suitable kotlinc version found for ' + prefix)