-
Notifications
You must be signed in to change notification settings - Fork 1
/
cli.sh
executable file
·59 lines (49 loc) · 1.58 KB
/
cli.sh
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
#!/bin/bash
set -euo pipefail
# Run from top-level project root.
./gradlew :kotlinc:compiler-plugin-standalone:assemble
cd samples/cli
mkdir -p build/cli-sample
cd build/cli-sample
# Kotlin compiler
KOTLINC_VERSION=1.7.10
if [[ ! -f kotlinc.zip ]]; then
echo "Downloading kotlinc..."
curl \
--output kotlinc.zip \
--location \
--fail \
https://github.com/JetBrains/kotlin/releases/download/v$KOTLINC_VERSION/kotlin-compiler-$KOTLINC_VERSION.zip
unzip kotlinc.zip
fi
if [[ ! -f kotlinc-native.tar.gz ]]; then
echo "Downloading kotlinc-native..."
curl \
--output kotlinc-native.tar.gz \
--location \
--fail \
https://github.com/JetBrains/kotlin/releases/download/v$KOTLINC_VERSION/kotlin-native-macos-aarch64-$KOTLINC_VERSION.tar.gz
tar -xf kotlinc-native.tar.gz
fi
KOTLINC=./kotlinc/bin/kotlinc
KOTLINC_NATIVE=./kotlin-native-macos-aarch64-$KOTLINC_VERSION/bin/kotlinc-native
KETOLANG_KOTLINC_PLUGIN_JAR=../../../../kotlinc/compiler-plugin-standalone/build/libs/compiler-plugin.jar
rm -rf kotlinc-out
mkdir kotlinc-out
set -x
echo "Compiling for JVM..."
$KOTLINC \
-Xplugin=$KETOLANG_KOTLINC_PLUGIN_JAR \
-no-reflect \
-no-jdk \
-Werror \
-d kotlinc-out/result.jar \
../../src/main/kotlin/com/pushtorefresh/ketolang/sample/User.kt
echo "Compiling for Native..."
$KOTLINC_NATIVE \
-Xplugin=$KETOLANG_KOTLINC_PLUGIN_JAR \
-nomain \
-produce library \
-Werror \
-output kotlinc-out/result.bin \
../../src/main/kotlin/com/pushtorefresh/ketolang/sample/User.kt