Skip to content

Commit

Permalink
Add clikt, build uber jar (#7)
Browse files Browse the repository at this point in the history
* add clikt, build uber jar

* graalvm no fallback

* add test binary step in gh action
  • Loading branch information
yujinyan authored Apr 16, 2021
1 parent e82e0e5 commit fe2a632
Show file tree
Hide file tree
Showing 5 changed files with 46 additions and 3 deletions.
5 changes: 4 additions & 1 deletion .github/workflows/build.yml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# This is a basic workflow to help you get started with Actions

name: CI
name: Build

# Controls when the action will run.
on:
Expand Down Expand Up @@ -38,6 +38,9 @@ jobs:
dependencies-cache-enabled: true
configuration-cache-enabled: true

- name: Test Binary
run: build/graal/klisp -e "(+ 1 1)"

# Runs a set of commands using the runners shell
- uses: actions/upload-artifact@v2
with:
Expand Down
11 changes: 10 additions & 1 deletion .github/workflows/release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,13 @@ jobs:
with:
java-version: '11'
distribution: 'adopt'
- name: Build Fat Jar
uses: eskatos/[email protected]
with:
arguments: shadowJar
wrapper-cache-enabled: true
dependencies-cache-enabled: true
configuration-cache-enabled: true
- name: Build GraalVM Native Image
uses: eskatos/[email protected]
with:
Expand All @@ -24,7 +31,9 @@ jobs:
- name: Release
uses: softprops/action-gh-release@v1
with:
files: build/graal/klisp
files: |
build/graal/klisp
build/libs/klisp.jar
draft: true
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
15 changes: 15 additions & 0 deletions build.gradle.kts
Original file line number Diff line number Diff line change
@@ -1,8 +1,11 @@
import com.github.jengelman.gradle.plugins.shadow.tasks.ShadowJar
import org.jetbrains.kotlin.gradle.tasks.KotlinCompile

plugins {
application
kotlin("jvm") version "1.4.32"
id("com.palantir.graal") version "0.7.2"
id("com.github.johnrengelman.shadow") version "6.1.0"
}

group = "me.yujinyan"
Expand All @@ -19,10 +22,21 @@ tasks.withType<KotlinCompile>().configureEach {
}
}

tasks.withType<ShadowJar>().configureEach {
archiveFileName.set("klisp.jar")
}

application {
// https://github.com/johnrengelman/shadow/pull/612
// mainClass.set("MainKt")
mainClassName = "MainKt"
}

graal {
javaVersion("11")
mainClass("MainKt")
outputName("klisp")
option("--no-fallback")
}

repositories {
Expand All @@ -32,5 +46,6 @@ repositories {
dependencies {
testImplementation("io.kotest:kotest-runner-junit5:4.4.3")
testImplementation("io.kotest:kotest-assertions-core:4.4.3")
implementation("com.github.ajalt.clikt:clikt:3.1.0")
implementation(kotlin("stdlib"))
}
16 changes: 16 additions & 0 deletions src/main/kotlin/Cli.kt
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
import com.github.ajalt.clikt.core.CliktCommand
import com.github.ajalt.clikt.parameters.options.option

class Cli : CliktCommand() {
private val expressionToEvaluate: String? by option("-e", "--evaluate", help = "evaluate expression")

override fun run() {
val env = DefaultEnv()
expressionToEvaluate?.let {
println(buildAst(it).evaluate(env))
return@run
}

repl()
}
}
2 changes: 1 addition & 1 deletion src/main/kotlin/Main.kt
Original file line number Diff line number Diff line change
Expand Up @@ -51,4 +51,4 @@ fun repl() {
}
}

fun main() = repl()
fun main(args: Array<String>) = Cli().main(args)

0 comments on commit fe2a632

Please sign in to comment.