Skip to content

Commit 1944623

Browse files
committed
Add Kotlin support
1 parent bfa03d6 commit 1944623

File tree

4 files changed

+57
-6
lines changed

4 files changed

+57
-6
lines changed

aoc

Lines changed: 11 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@ SAMPLE_TEST_JSON = "{}"
1919
RUNNERS = {
2020
"py": (None, ["./runners/py.sh"]),
2121
"go": (["./runners/buildGo.sh"], None),
22+
"kt": (["./runners/buildKotlin.sh"], ["./runners/jar.sh"]),
2223
}
2324

2425

@@ -167,11 +168,11 @@ def get_runner_command(
167168
print(f"No build or run command specified for runner {file_extension}")
168169
raise SystemExit(1)
169170

170-
if runner_run is not None and runner_build is not None:
171-
print(
172-
f"Build command and run command specified for {file_extension} - cannot determine path forwards."
173-
)
174-
raise SystemExit(1)
171+
# if runner_run is not None and runner_build is not None:
172+
# print(
173+
# f"Build command and run command specified for {file_extension} - cannot determine path forwards."
174+
# )
175+
# raise SystemExit(1)
175176

176177
command = runner_build + [file_name]
177178
set_terminal_colour("grey")
@@ -182,7 +183,11 @@ def get_runner_command(
182183
print(f"Failed to build: `{command}` returned exit code {exit_code}")
183184
raise SystemExit(1)
184185
fpstr = fpath.decode().strip()
185-
return [fpstr], lambda: os.unlink(fpstr)
186+
187+
if runner_run is None:
188+
return [fpstr], lambda: os.unlink(fpstr)
189+
190+
return runner_run + [fpstr], lambda: os.unlink(fpstr)
186191

187192

188193
class CLI(object):

runners/buildKotlin.sh

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
#!/usr/bin/env bash
2+
3+
set -e
4+
5+
TEMPDIR="$(mktemp -d)"
6+
FNAME=$(basename $1 | sed 's/\.kt$/.jar/')
7+
FULLPATH="$TEMPDIR/$FNAME"
8+
kotlinc "$1" -include-runtime -d "$FULLPATH"
9+
echo $FULLPATH

runners/jar.sh

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
#!/usr/bin/env bash
2+
3+
set -e
4+
5+
java -jar $@

templates/main.kt

Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
1+
import java.lang.System
2+
import kotlin.system.*
3+
import kotlin.sequences.generateSequence
4+
5+
fun parse(instr: String) {
6+
7+
}
8+
9+
fun one(instr: String): Int {
10+
return 0
11+
}
12+
13+
fun two(instr: String): Int {
14+
return 0
15+
}
16+
17+
fun main(args: Array<String>) {
18+
if (args.size < 1 || !(args[0] == "1" || args[0] == "2")) {
19+
debug("Missing or invalid day argument")
20+
exitProcess(1)
21+
}
22+
val inp = generateSequence(::readLine).joinToString("\n")
23+
if (args[0] == "1") {
24+
println("${one(inp)}")
25+
} else {
26+
println("${two(inp)}")
27+
}
28+
}
29+
30+
fun debug(msg: String) {
31+
System.err.println(msg)
32+
}

0 commit comments

Comments
 (0)
pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy