Skip to content

Commit

Permalink
Support running and packaging using Deno
Browse files Browse the repository at this point in the history
  • Loading branch information
soywiz committed Jul 4, 2024
1 parent 0bc1ee7 commit 0da047b
Showing 1 changed file with 31 additions and 13 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -59,28 +59,25 @@ open class RunJsServer : DefaultTask() {
}
}

fun Project.fullPathName(): String {
if (this.parent == null) return this.name
return this.parent!!.fullPathName() + ":" + this.name
}

fun Project.configureDenoTest() {
afterEvaluate {
if (tasks.findByName("compileTestDevelopmentExecutableKotlinJs") == null) return@afterEvaluate

val jsDenoTest = project.tasks.createThis<Exec>("jsDenoTest") {
fun fullPathName(project: Project): String {
if (project.parent == null) return project.name
return fullPathName(project.parent!!) + ":" + project.name
}
val baseTestFileNameBase = fullPathName(project).trim(':').replace(':', '-') + "-test"
val baseTestFileName = "$baseTestFileNameBase.mjs"
group = "verification"

//build\js\packages\korge-root-korge-test\kotlin
dependsOn("compileTestDevelopmentExecutableKotlinJs")

//val runFile = file("build/compileSync/js/test/testDevelopmentExecutable/kotlin/$baseTestFileName.deno.mjs")
val runFile = File(rootProject.rootDir, "build/js/packages/$baseTestFileNameBase/kotlin/$baseTestFileName.deno.mjs")
val baseTestFileNameBase = project.fullPathName().trim(':').replace(':', '-') + "-test"
val baseTestFileName = "$baseTestFileNameBase.mjs"

// compileTestDevelopmentExecutableKotlinJs
dependsOn("compileTestDevelopmentExecutableKotlinJs")
//commandLine("deno", "test", "--unstable-ffi", "-A", "src/test/kotlin")
val runFile = File(rootProject.rootDir, "build/js/packages/$baseTestFileNameBase/kotlin/$baseTestFileName.deno.mjs")

//rootProject.
commandLine("deno", "test", "--unstable-ffi", "--unstable-webgpu", "-A", runFile)
workingDir(runFile.parentFile.absolutePath)

Expand All @@ -105,6 +102,27 @@ fun Project.configureDenoTest() {
}

fun Project.configureDenoRun() {
afterEvaluate {
if (tasks.findByName("compileDevelopmentExecutableKotlinJs") == null) return@afterEvaluate

val baseRunFileNameBase = project.fullPathName().trim(':').replace(':', '-')
val baseRunFileName = "$baseRunFileNameBase.mjs"
val runFile = File(rootProject.rootDir, "build/js/packages/$baseRunFileNameBase/kotlin/$baseRunFileName")

val runDeno = project.tasks.createThis<Exec>("runDeno") {
group = GROUP_KORGE_RUN
dependsOn("compileDevelopmentExecutableKotlinJs")
commandLine("deno", "run", "--unstable-ffi", "--unstable-webgpu", "-A", runFile)
workingDir(runFile.parentFile.absolutePath)
}

val packageDeno = project.tasks.createThis<Exec>("packageDeno") {
group = GROUP_KORGE_PACKAGE
dependsOn("compileDevelopmentExecutableKotlinJs")
commandLine("deno", "compile", "--unstable-ffi", "--unstable-webgpu", "-A", runFile)
workingDir(runFile.parentFile.absolutePath)
}
}
}

fun Project.configureJavascriptRun() {
Expand Down

0 comments on commit 0da047b

Please sign in to comment.