Skip to content

Commit

Permalink
use webidl-util gradle plugin to generate physx js bindings
Browse files Browse the repository at this point in the history
  • Loading branch information
fabmax committed Oct 11, 2024
1 parent eac3e90 commit 009f762
Show file tree
Hide file tree
Showing 4 changed files with 22 additions and 4 deletions.
6 changes: 5 additions & 1 deletion buildSrc/src/main/kotlin/de/fabmax/kool/LocalProperties.kt
Original file line number Diff line number Diff line change
Expand Up @@ -13,9 +13,13 @@ class LocalProperties private constructor(file: File) : Properties() {

operator fun get(key: String): String? = getProperty(key, System.getenv(key))

fun getOrElse(key: String, default: String) = get(key) ?: default

companion object {
fun get(project: Project): LocalProperties {
return LocalProperties(project.rootProject.file("local.properties"))
}
}
}
}

val Project.localProperties: LocalProperties get() = LocalProperties.get(this)
4 changes: 2 additions & 2 deletions buildSrc/src/main/kotlin/de/fabmax/kool/VersionNameUpdate.kt
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
package de.fabmax.kool

import LocalProperties
import localProperties
import org.gradle.api.DefaultTask
import org.gradle.api.tasks.Input
import org.gradle.api.tasks.TaskAction
Expand All @@ -22,7 +22,7 @@ open class VersionNameUpdate : DefaultTask() {
val text = file.readText()
val lineSep = if ("\r\n" in text) "\r\n" else "\n"

if (LocalProperties.get(project).isRelease) {
if (project.localProperties.isRelease) {
var updated = false
val lines = text.lines().toMutableList()
for (i in lines.indices) {
Expand Down
2 changes: 1 addition & 1 deletion kool-demo/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ kotlin {
outputDirectory.set(File("${rootDir}/dist/kool-demo"))
}
commonWebpackConfig {
mode = if (LocalProperties.get(project).isRelease) {
mode = if (localProperties.isRelease) {
KotlinWebpackConfig.Mode.PRODUCTION
} else {
KotlinWebpackConfig.Mode.DEVELOPMENT
Expand Down
14 changes: 14 additions & 0 deletions kool-physics/build.gradle.kts
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
plugins {
id("kool.lib-conventions")
id("kool.publish-conventions")

id("de.fabmax.webidl-util") version "0.9.0"
}

kotlin {
Expand All @@ -23,3 +25,15 @@ kotlin {
}
}
}

webidl {
localProperties["physx-js.webidldir"]?.let { modelPath = file(it) }
modelName = "PhysXJs"

generateKotlinJsInterfaces {
outputDirectory = file("${projectDir}/src/jsMain/kotlin/physx")
packagePrefix = "physx"
moduleName = "physx-js-webidl"
modulePromiseName = "PhysX"
}
}

0 comments on commit 009f762

Please sign in to comment.