mirror of
https://github.com/github/codeql.git
synced 2025-12-17 01:03:14 +01:00
Kotlin/Bazel: fix wrapper on Windows
This commit is contained in:
@@ -15,7 +15,6 @@ is available in `resources/lib/windows/ripunzip` then).
|
||||
"""
|
||||
|
||||
import pathlib
|
||||
import os
|
||||
import urllib
|
||||
import urllib.request
|
||||
import urllib.error
|
||||
@@ -29,6 +28,7 @@ import io
|
||||
|
||||
DEFAULT_VERSION = "1.9.0"
|
||||
|
||||
|
||||
def options():
|
||||
parser = argparse.ArgumentParser(add_help=False)
|
||||
parser.add_argument("--select")
|
||||
@@ -71,6 +71,7 @@ def check_version(version: str):
|
||||
raise Error(f"Version {version} not found in github.com/JetBrains/kotlin/releases") from e
|
||||
raise
|
||||
|
||||
|
||||
def get_version(file: pathlib.Path) -> str:
|
||||
try:
|
||||
return file.read_text()
|
||||
@@ -108,9 +109,12 @@ def forward(forwarded_opts):
|
||||
kotlinc = install_dir / "kotlinc" / "bin" / "kotlinc"
|
||||
if platform.system() == "Windows":
|
||||
kotlinc = kotlinc.with_suffix(".bat")
|
||||
args = [sys.argv[0]]
|
||||
assert kotlinc.exists(), f"{kotlinc} not found"
|
||||
args = [kotlinc]
|
||||
args.extend(forwarded_opts)
|
||||
os.execv(kotlinc, args)
|
||||
ret = subprocess.run(args).returncode
|
||||
sys.exit(ret)
|
||||
|
||||
|
||||
def clear():
|
||||
if install_dir.exists():
|
||||
@@ -123,6 +127,7 @@ def clear():
|
||||
print(f"removing {version_file}", file=sys.stderr)
|
||||
version_file.unlink()
|
||||
|
||||
|
||||
def main(opts, forwarded_opts):
|
||||
if opts.clear:
|
||||
clear()
|
||||
|
||||
@@ -1,2 +1,4 @@
|
||||
@echo off
|
||||
python3 %~dp0/kotlinc
|
||||
|
||||
python "%~dp0/kotlinc" %*
|
||||
exit /b %ERRORLEVEL%
|
||||
|
||||
Reference in New Issue
Block a user