Add Kotlin support
This commit is contained in:
parent
bfa03d6369
commit
1944623f5e
4 changed files with 57 additions and 6 deletions
17
aoc
17
aoc
|
@ -19,6 +19,7 @@ SAMPLE_TEST_JSON = "{}"
|
||||||
RUNNERS = {
|
RUNNERS = {
|
||||||
"py": (None, ["./runners/py.sh"]),
|
"py": (None, ["./runners/py.sh"]),
|
||||||
"go": (["./runners/buildGo.sh"], None),
|
"go": (["./runners/buildGo.sh"], None),
|
||||||
|
"kt": (["./runners/buildKotlin.sh"], ["./runners/jar.sh"]),
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ -167,11 +168,11 @@ def get_runner_command(
|
||||||
print(f"No build or run command specified for runner {file_extension}")
|
print(f"No build or run command specified for runner {file_extension}")
|
||||||
raise SystemExit(1)
|
raise SystemExit(1)
|
||||||
|
|
||||||
if runner_run is not None and runner_build is not None:
|
# if runner_run is not None and runner_build is not None:
|
||||||
print(
|
# print(
|
||||||
f"Build command and run command specified for {file_extension} - cannot determine path forwards."
|
# f"Build command and run command specified for {file_extension} - cannot determine path forwards."
|
||||||
)
|
# )
|
||||||
raise SystemExit(1)
|
# raise SystemExit(1)
|
||||||
|
|
||||||
command = runner_build + [file_name]
|
command = runner_build + [file_name]
|
||||||
set_terminal_colour("grey")
|
set_terminal_colour("grey")
|
||||||
|
@ -182,7 +183,11 @@ def get_runner_command(
|
||||||
print(f"Failed to build: `{command}` returned exit code {exit_code}")
|
print(f"Failed to build: `{command}` returned exit code {exit_code}")
|
||||||
raise SystemExit(1)
|
raise SystemExit(1)
|
||||||
fpstr = fpath.decode().strip()
|
fpstr = fpath.decode().strip()
|
||||||
return [fpstr], lambda: os.unlink(fpstr)
|
|
||||||
|
if runner_run is None:
|
||||||
|
return [fpstr], lambda: os.unlink(fpstr)
|
||||||
|
|
||||||
|
return runner_run + [fpstr], lambda: os.unlink(fpstr)
|
||||||
|
|
||||||
|
|
||||||
class CLI(object):
|
class CLI(object):
|
||||||
|
|
9
runners/buildKotlin.sh
Normal file
9
runners/buildKotlin.sh
Normal file
|
@ -0,0 +1,9 @@
|
||||||
|
#!/usr/bin/env bash
|
||||||
|
|
||||||
|
set -e
|
||||||
|
|
||||||
|
TEMPDIR="$(mktemp -d)"
|
||||||
|
FNAME=$(basename $1 | sed 's/\.kt$/.jar/')
|
||||||
|
FULLPATH="$TEMPDIR/$FNAME"
|
||||||
|
kotlinc "$1" -include-runtime -d "$FULLPATH"
|
||||||
|
echo $FULLPATH
|
5
runners/jar.sh
Normal file
5
runners/jar.sh
Normal file
|
@ -0,0 +1,5 @@
|
||||||
|
#!/usr/bin/env bash
|
||||||
|
|
||||||
|
set -e
|
||||||
|
|
||||||
|
java -jar $@
|
32
templates/main.kt
Normal file
32
templates/main.kt
Normal file
|
@ -0,0 +1,32 @@
|
||||||
|
import java.lang.System
|
||||||
|
import kotlin.system.*
|
||||||
|
import kotlin.sequences.generateSequence
|
||||||
|
|
||||||
|
fun parse(instr: String) {
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
fun one(instr: String): Int {
|
||||||
|
return 0
|
||||||
|
}
|
||||||
|
|
||||||
|
fun two(instr: String): Int {
|
||||||
|
return 0
|
||||||
|
}
|
||||||
|
|
||||||
|
fun main(args: Array<String>) {
|
||||||
|
if (args.size < 1 || !(args[0] == "1" || args[0] == "2")) {
|
||||||
|
debug("Missing or invalid day argument")
|
||||||
|
exitProcess(1)
|
||||||
|
}
|
||||||
|
val inp = generateSequence(::readLine).joinToString("\n")
|
||||||
|
if (args[0] == "1") {
|
||||||
|
println("${one(inp)}")
|
||||||
|
} else {
|
||||||
|
println("${two(inp)}")
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
fun debug(msg: String) {
|
||||||
|
System.err.println(msg)
|
||||||
|
}
|
Loading…
Add table
Add a link
Reference in a new issue