Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 5 additions & 5 deletions java/kotlin-extractor/build.py
Original file line number Diff line number Diff line change
Expand Up @@ -35,8 +35,12 @@ def is_windows():
return True
return False

# kotlinc might be kotlinc.bat or kotlinc.cmd on Windows, so we use `which` to find out what it is
kotlinc = shutil.which('kotlinc')
if kotlinc is None:
print("Cannot build the Kotlin extractor: no kotlinc found on your PATH", file = sys.stderr)
sys.exit(1)

kotlinc = 'kotlinc.bat' if is_windows() else 'kotlinc'
javac = 'javac'
kotlin_dependency_folder = args.dependencies

Expand Down Expand Up @@ -201,10 +205,6 @@ 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)
Expand Down
11 changes: 6 additions & 5 deletions java/kotlin-extractor/kotlin_plugin_versions.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import platform
import re
import shutil
import subprocess
import sys

Expand All @@ -26,11 +27,11 @@ 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.
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)
# kotlinc might be kotlinc.bat or kotlinc.cmd on Windows, so we use `which` to find out what it is
kotlinc = shutil.which('kotlinc')
if kotlinc is None:
raise KotlincNotFoundException()
versionOutput = subprocess.run([kotlinc, '-version'], stdout=subprocess.PIPE, stderr=subprocess.PIPE, universal_newlines=True).stderr if fakeVersionOutput is None else fakeVersionOutput
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) + ')')
Expand Down