mirror of
https://github.com/GayPizzaSpecifications/pork.git
synced 2025-08-03 05:10:55 +00:00
minimal: pork-rt minimal runtime
This commit is contained in:
parent
2ee1565fb5
commit
14b3f4c6e9
15
.github/workflows/graal.yml
vendored
15
.github/workflows/graal.yml
vendored
@ -20,6 +20,11 @@ jobs:
|
|||||||
with:
|
with:
|
||||||
name: pork-linux-amd64
|
name: pork-linux-amd64
|
||||||
path: tool/build/native/nativeCompile/pork
|
path: tool/build/native/nativeCompile/pork
|
||||||
|
- name: Archive Pork Runtime Executable
|
||||||
|
uses: actions/upload-artifact@v3
|
||||||
|
with:
|
||||||
|
name: pork-rt-linux-amd64
|
||||||
|
path: minimal/build/native/nativeCompile/pork-rt
|
||||||
darwin-amd64:
|
darwin-amd64:
|
||||||
runs-on: macos-latest
|
runs-on: macos-latest
|
||||||
steps:
|
steps:
|
||||||
@ -39,6 +44,11 @@ jobs:
|
|||||||
with:
|
with:
|
||||||
name: pork-darwin-amd64
|
name: pork-darwin-amd64
|
||||||
path: tool/build/native/nativeCompile/pork
|
path: tool/build/native/nativeCompile/pork
|
||||||
|
- name: Archive Pork Runtime Executable
|
||||||
|
uses: actions/upload-artifact@v3
|
||||||
|
with:
|
||||||
|
name: pork-rt-darwin-amd64
|
||||||
|
path: minimal/build/native/nativeCompile/pork-rt
|
||||||
windows-amd64:
|
windows-amd64:
|
||||||
runs-on: windows-latest
|
runs-on: windows-latest
|
||||||
steps:
|
steps:
|
||||||
@ -58,3 +68,8 @@ jobs:
|
|||||||
with:
|
with:
|
||||||
name: pork-windows-amd64
|
name: pork-windows-amd64
|
||||||
path: tool/build/native/nativeCompile/pork.exe
|
path: tool/build/native/nativeCompile/pork.exe
|
||||||
|
- name: Archive Pork Runtime Executable
|
||||||
|
uses: actions/upload-artifact@v3
|
||||||
|
with:
|
||||||
|
name: pork-rt-windows-amd64
|
||||||
|
path: minimal/build/native/nativeCompile/pork-rt.exe
|
||||||
|
49
minimal/build.gradle.kts
Normal file
49
minimal/build.gradle.kts
Normal file
@ -0,0 +1,49 @@
|
|||||||
|
plugins {
|
||||||
|
application
|
||||||
|
id("gay.pizza.pork.module")
|
||||||
|
id("com.github.johnrengelman.shadow") version "8.1.1"
|
||||||
|
id("org.graalvm.buildtools.native") version "0.9.25"
|
||||||
|
}
|
||||||
|
|
||||||
|
dependencies {
|
||||||
|
api(project(":ast"))
|
||||||
|
api(project(":parser"))
|
||||||
|
api(project(":frontend"))
|
||||||
|
api(project(":evaluator"))
|
||||||
|
api(project(":stdlib"))
|
||||||
|
api(project(":ffi"))
|
||||||
|
implementation(project(":common"))
|
||||||
|
}
|
||||||
|
|
||||||
|
application {
|
||||||
|
applicationName = "pork-rt"
|
||||||
|
mainClass.set("gay.pizza.pork.minimal.MainKt")
|
||||||
|
}
|
||||||
|
|
||||||
|
for (task in arrayOf(tasks.shadowDistTar, tasks.shadowDistZip, tasks.shadowJar)) {
|
||||||
|
val suffix = when {
|
||||||
|
task == tasks.shadowJar -> ""
|
||||||
|
task.name.startsWith("shadow") -> "-shadow"
|
||||||
|
else -> ""
|
||||||
|
}
|
||||||
|
task.get().archiveBaseName.set("pork-rt${suffix}")
|
||||||
|
}
|
||||||
|
|
||||||
|
graalvmNative {
|
||||||
|
binaries {
|
||||||
|
named("main") {
|
||||||
|
imageName.set("pork-rt")
|
||||||
|
mainClass.set("gay.pizza.pork.minimal.MainKt")
|
||||||
|
sharedLibrary.set(false)
|
||||||
|
buildArgs("-march=compatibility")
|
||||||
|
resources {
|
||||||
|
includedPatterns.addAll(listOf(
|
||||||
|
".*/*.pork$",
|
||||||
|
".*/*.manifest$"
|
||||||
|
))
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
tasks.run.get().outputs.upToDateWhen { false }
|
@ -1,4 +1,4 @@
|
|||||||
package gay.pizza.pork.tool
|
package gay.pizza.pork.minimal
|
||||||
|
|
||||||
import gay.pizza.dough.fs.FsPath
|
import gay.pizza.dough.fs.FsPath
|
||||||
import gay.pizza.dough.fs.readString
|
import gay.pizza.dough.fs.readString
|
@ -1,13 +1,12 @@
|
|||||||
package gay.pizza.pork.tool
|
package gay.pizza.pork.minimal
|
||||||
|
|
||||||
import gay.pizza.pork.ast.CompilationUnit
|
import gay.pizza.pork.ast.CompilationUnit
|
||||||
import gay.pizza.pork.ast.NodeVisitor
|
import gay.pizza.pork.ast.NodeVisitor
|
||||||
import gay.pizza.pork.ast.visit
|
import gay.pizza.pork.ast.visit
|
||||||
import gay.pizza.pork.evaluator.CallableFunction
|
import gay.pizza.pork.evaluator.*
|
||||||
import gay.pizza.pork.evaluator.Evaluator
|
|
||||||
import gay.pizza.pork.evaluator.InternalNativeProvider
|
|
||||||
import gay.pizza.pork.evaluator.Scope
|
|
||||||
import gay.pizza.pork.ffi.JavaAutogenContentSource
|
import gay.pizza.pork.ffi.JavaAutogenContentSource
|
||||||
|
import gay.pizza.pork.ffi.JavaNativeProvider
|
||||||
|
import gay.pizza.pork.ffi.JnaNativeProvider
|
||||||
import gay.pizza.pork.frontend.ContentSource
|
import gay.pizza.pork.frontend.ContentSource
|
||||||
import gay.pizza.pork.frontend.ImportLocator
|
import gay.pizza.pork.frontend.ImportLocator
|
||||||
import gay.pizza.pork.frontend.DynamicImportSource
|
import gay.pizza.pork.frontend.DynamicImportSource
|
||||||
@ -45,4 +44,13 @@ abstract class Tool {
|
|||||||
val resultingScope = evaluator.evaluate(ImportLocator("local", rootFilePath()))
|
val resultingScope = evaluator.evaluate(ImportLocator("local", rootFilePath()))
|
||||||
return resultingScope.value("main") as CallableFunction
|
return resultingScope.value("main") as CallableFunction
|
||||||
}
|
}
|
||||||
|
|
||||||
|
fun run(scope: Scope, quiet: Boolean = false) {
|
||||||
|
val main = loadMainFunction(scope, setupEvaluator = {
|
||||||
|
addNativeProvider("internal", InternalNativeProvider(quiet = quiet))
|
||||||
|
addNativeProvider("ffi", JnaNativeProvider())
|
||||||
|
addNativeProvider("java", JavaNativeProvider())
|
||||||
|
})
|
||||||
|
main.call(Arguments(emptyList()))
|
||||||
|
}
|
||||||
}
|
}
|
16
minimal/src/main/kotlin/gay/pizza/pork/minimal/main.kt
Normal file
16
minimal/src/main/kotlin/gay/pizza/pork/minimal/main.kt
Normal file
@ -0,0 +1,16 @@
|
|||||||
|
package gay.pizza.pork.minimal
|
||||||
|
|
||||||
|
import gay.pizza.dough.fs.PlatformFsProvider
|
||||||
|
import gay.pizza.pork.evaluator.Scope
|
||||||
|
import kotlin.system.exitProcess
|
||||||
|
|
||||||
|
fun main(args: Array<String>) {
|
||||||
|
if (args.size != 1) {
|
||||||
|
System.err.println("Usage: pork-rt <file>")
|
||||||
|
exitProcess(1)
|
||||||
|
}
|
||||||
|
val path = PlatformFsProvider.resolve(args[0])
|
||||||
|
val tool = FileTool(path)
|
||||||
|
val scope = Scope()
|
||||||
|
tool.run(scope)
|
||||||
|
}
|
@ -11,5 +11,6 @@ include(
|
|||||||
":stdlib",
|
":stdlib",
|
||||||
":ffi",
|
":ffi",
|
||||||
":tool",
|
":tool",
|
||||||
|
":minimal",
|
||||||
":support:pork-idea"
|
":support:pork-idea"
|
||||||
)
|
)
|
||||||
|
@ -6,14 +6,8 @@ plugins {
|
|||||||
}
|
}
|
||||||
|
|
||||||
dependencies {
|
dependencies {
|
||||||
api(project(":ast"))
|
api(project(":minimal"))
|
||||||
api(project(":parser"))
|
|
||||||
api(project(":frontend"))
|
|
||||||
api(project(":evaluator"))
|
|
||||||
api(project(":stdlib"))
|
|
||||||
api(project(":ffi"))
|
|
||||||
api("com.github.ajalt.clikt:clikt:4.2.0")
|
api("com.github.ajalt.clikt:clikt:4.2.0")
|
||||||
implementation(project(":common"))
|
|
||||||
}
|
}
|
||||||
|
|
||||||
application {
|
application {
|
||||||
|
@ -4,6 +4,7 @@ import com.github.ajalt.clikt.core.CliktCommand
|
|||||||
import com.github.ajalt.clikt.parameters.arguments.argument
|
import com.github.ajalt.clikt.parameters.arguments.argument
|
||||||
import gay.pizza.dough.fs.PlatformFsProvider
|
import gay.pizza.dough.fs.PlatformFsProvider
|
||||||
import gay.pizza.pork.ast.Node
|
import gay.pizza.pork.ast.Node
|
||||||
|
import gay.pizza.pork.minimal.FileTool
|
||||||
import kotlinx.serialization.ExperimentalSerializationApi
|
import kotlinx.serialization.ExperimentalSerializationApi
|
||||||
import kotlinx.serialization.json.Json
|
import kotlinx.serialization.json.Json
|
||||||
|
|
||||||
|
@ -5,6 +5,7 @@ import com.github.ajalt.clikt.parameters.arguments.argument
|
|||||||
import gay.pizza.dough.fs.PlatformFsProvider
|
import gay.pizza.dough.fs.PlatformFsProvider
|
||||||
import gay.pizza.pork.ast.NodeCoalescer
|
import gay.pizza.pork.ast.NodeCoalescer
|
||||||
import gay.pizza.pork.ast.visit
|
import gay.pizza.pork.ast.visit
|
||||||
|
import gay.pizza.pork.minimal.FileTool
|
||||||
import gay.pizza.pork.parser.TokenNodeAttribution
|
import gay.pizza.pork.parser.TokenNodeAttribution
|
||||||
|
|
||||||
class AttributeCommand : CliktCommand(help = "Attribute AST", name = "attribute") {
|
class AttributeCommand : CliktCommand(help = "Attribute AST", name = "attribute") {
|
||||||
|
@ -3,6 +3,7 @@ package gay.pizza.pork.tool
|
|||||||
import com.github.ajalt.clikt.core.CliktCommand
|
import com.github.ajalt.clikt.core.CliktCommand
|
||||||
import com.github.ajalt.clikt.parameters.arguments.argument
|
import com.github.ajalt.clikt.parameters.arguments.argument
|
||||||
import gay.pizza.dough.fs.PlatformFsProvider
|
import gay.pizza.dough.fs.PlatformFsProvider
|
||||||
|
import gay.pizza.pork.minimal.FileTool
|
||||||
import gay.pizza.pork.parser.AnsiHighlightScheme
|
import gay.pizza.pork.parser.AnsiHighlightScheme
|
||||||
|
|
||||||
class HighlightCommand : CliktCommand(help = "Syntax Highlighter", name = "highlight") {
|
class HighlightCommand : CliktCommand(help = "Syntax Highlighter", name = "highlight") {
|
||||||
|
@ -5,6 +5,7 @@ import com.github.ajalt.clikt.parameters.arguments.argument
|
|||||||
import com.github.ajalt.clikt.parameters.options.flag
|
import com.github.ajalt.clikt.parameters.options.flag
|
||||||
import com.github.ajalt.clikt.parameters.options.option
|
import com.github.ajalt.clikt.parameters.options.option
|
||||||
import gay.pizza.dough.fs.PlatformFsProvider
|
import gay.pizza.dough.fs.PlatformFsProvider
|
||||||
|
import gay.pizza.pork.minimal.FileTool
|
||||||
|
|
||||||
class ParseCommand : CliktCommand(help = "Parse Compilation Unit", name = "parse") {
|
class ParseCommand : CliktCommand(help = "Parse Compilation Unit", name = "parse") {
|
||||||
val loop by option("--loop", help = "Loop Parsing").flag()
|
val loop by option("--loop", help = "Loop Parsing").flag()
|
||||||
|
@ -3,6 +3,7 @@ package gay.pizza.pork.tool
|
|||||||
import com.github.ajalt.clikt.core.CliktCommand
|
import com.github.ajalt.clikt.core.CliktCommand
|
||||||
import com.github.ajalt.clikt.parameters.arguments.argument
|
import com.github.ajalt.clikt.parameters.arguments.argument
|
||||||
import gay.pizza.dough.fs.PlatformFsProvider
|
import gay.pizza.dough.fs.PlatformFsProvider
|
||||||
|
import gay.pizza.pork.minimal.FileTool
|
||||||
|
|
||||||
class ReprintCommand : CliktCommand(help = "Reprint Parsed Compilation Unit", name = "reprint") {
|
class ReprintCommand : CliktCommand(help = "Reprint Parsed Compilation Unit", name = "reprint") {
|
||||||
val path by argument("file")
|
val path by argument("file")
|
||||||
|
@ -8,6 +8,7 @@ import gay.pizza.dough.fs.PlatformFsProvider
|
|||||||
import gay.pizza.pork.evaluator.*
|
import gay.pizza.pork.evaluator.*
|
||||||
import gay.pizza.pork.ffi.JavaNativeProvider
|
import gay.pizza.pork.ffi.JavaNativeProvider
|
||||||
import gay.pizza.pork.ffi.JnaNativeProvider
|
import gay.pizza.pork.ffi.JnaNativeProvider
|
||||||
|
import gay.pizza.pork.minimal.FileTool
|
||||||
|
|
||||||
class RunCommand : CliktCommand(help = "Run Program", name = "run") {
|
class RunCommand : CliktCommand(help = "Run Program", name = "run") {
|
||||||
val loop by option("--loop", help = "Loop Program").flag()
|
val loop by option("--loop", help = "Loop Program").flag()
|
||||||
|
@ -3,6 +3,7 @@ package gay.pizza.pork.tool
|
|||||||
import com.github.ajalt.clikt.core.CliktCommand
|
import com.github.ajalt.clikt.core.CliktCommand
|
||||||
import com.github.ajalt.clikt.parameters.arguments.argument
|
import com.github.ajalt.clikt.parameters.arguments.argument
|
||||||
import gay.pizza.dough.fs.PlatformFsProvider
|
import gay.pizza.dough.fs.PlatformFsProvider
|
||||||
|
import gay.pizza.pork.minimal.FileTool
|
||||||
|
|
||||||
class TokenizeCommand : CliktCommand(help = "Tokenize Compilation Unit", name = "tokenize") {
|
class TokenizeCommand : CliktCommand(help = "Tokenize Compilation Unit", name = "tokenize") {
|
||||||
val path by argument("file")
|
val path by argument("file")
|
||||||
|
Loading…
Reference in New Issue
Block a user