diff --git a/src/commonMain/kotlin/io/github/overrun/application/Binding.kt b/src/commonMain/kotlin/io/github/overrun/application/Binding.kt deleted file mode 100644 index ef64fb2..0000000 --- a/src/commonMain/kotlin/io/github/overrun/application/Binding.kt +++ /dev/null @@ -1,56 +0,0 @@ -package io.github.overrun.application - -enum class Natives(val itemName: String, val classifier: String) { - LINUX_64("Linux x64", "natives-linux"), - LINUX_ARM64("Linux arm64", "natives-linux-arm64"), - LINUX_ARM32("Linux arm32", "natives-linux-arm32"), - MACOS("macOS x64", "natives-macos"), - MACOS_ARM64("macOS arm64", "natives-macos-arm64"), - WIN_64("Windows x64", "natives-windows"), - WIN_ARM64("Windows arm64", "natives-windows-arm64"); - - override fun toString(): String = classifier -} - -val ALL_NATIVES = Natives.entries.toTypedArray() -val NATIVES_LINUX = arrayOf(Natives.LINUX_64, Natives.LINUX_ARM64, Natives.LINUX_ARM32) -val NATIVES_MACOS = arrayOf(Natives.MACOS, Natives.MACOS_ARM64) -val NATIVES_WIN = arrayOf(Natives.WIN_64, Natives.WIN_ARM64) - -enum class Binding( - val itemName: String, - val artifactName: String, - val moduleName: String, - vararg val natives: Natives -) { - CORE("OverrunGL Core", "overrungl", "overrungl.core"), - GLFW( - "GLFW", - "overrungl-glfw", - "overrungl.glfw", - Natives.LINUX_64, - Natives.LINUX_ARM64, - Natives.MACOS, - Natives.MACOS_ARM64, - Natives.WIN_64 - ), - NFD("Native File Dialog", "overrungl-nfd", "overrungl.nfd", *ALL_NATIVES), - OPENGL("OpenGL", "overrungl-opengl", "overrungl.opengl"), - STB("stb", "overrungl-stb", "overrungl.stb", *ALL_NATIVES) -} - -enum class Type(val itemName: String) { - RELEASE("Release"), - SNAPSHOT("Snapshot"); - - override fun toString(): String = itemName -} - -fun ofType(name: String) = Type.valueOf(name.uppercase()) - -enum class Lang(val itemName: String) { - GROOVY("Groovy"), - KOTLIN("Kotlin") -} - -fun ofLang(name: String) = Lang.valueOf(name.uppercase()) diff --git a/src/commonMain/kotlin/io/github/overrun/application/Versions.kt b/src/commonMain/kotlin/io/github/overrun/application/Versions.kt deleted file mode 100644 index fd06f07..0000000 --- a/src/commonMain/kotlin/io/github/overrun/application/Versions.kt +++ /dev/null @@ -1,34 +0,0 @@ -package io.github.overrun.application - -const val VER_CUSTOMIZER = "0.2.2" -const val VER_JOML = "1.10.5" - -val VER_MAPPING = HashMap() - -val VER_0_1_0 = Version("0.1.0", arrayOf(Binding.CORE, Binding.GLFW, Binding.NFD, Binding.OPENGL, Binding.STB)) - -val VER_LATEST = VER_0_1_0 - -data class Version(val num: String, val bindings: Array) { - init { - VER_MAPPING[num] = this - } - - override fun toString(): String = num - - override fun equals(other: Any?): Boolean { - if (this === other) return true - if (other !is Version) return false - - if (num != other.num) return false - if (!bindings.contentEquals(other.bindings)) return false - - return true - } - - override fun hashCode(): Int { - var result = num.hashCode() - result = 31 * result + bindings.contentHashCode() - return result - } -} diff --git a/src/jsMain/kotlin/Client.kt b/src/jsMain/kotlin/Client.kt deleted file mode 100644 index 29d4549..0000000 --- a/src/jsMain/kotlin/Client.kt +++ /dev/null @@ -1,19 +0,0 @@ - -import io.github.overrun.application.Lang -import io.github.overrun.application.Type -import io.github.overrun.application.VER_LATEST -import kotlinx.browser.document -import react.create -import react.dom.client.createRoot - -fun main() { - val container = document.createElement("div") - document.body!!.appendChild(container) - - val welcome = Welcome.create { - type = Type.SNAPSHOT - language = Lang.KOTLIN - version = VER_LATEST - } - createRoot(container).render(welcome) -} diff --git a/src/jsMain/kotlin/Welcome.kt b/src/jsMain/kotlin/Welcome.kt deleted file mode 100644 index 03776c6..0000000 --- a/src/jsMain/kotlin/Welcome.kt +++ /dev/null @@ -1,348 +0,0 @@ -import csstype.string -import emotion.react.css -import io.github.overrun.application.* -import org.w3c.dom.HTMLOptionElement -import react.* -import react.dom.html.InputType -import react.dom.html.ReactHTML.code -import react.dom.html.ReactHTML.div -import react.dom.html.ReactHTML.h4 -import react.dom.html.ReactHTML.input -import react.dom.html.ReactHTML.label -import react.dom.html.ReactHTML.option -import react.dom.html.ReactHTML.p -import react.dom.html.ReactHTML.pre -import react.dom.html.ReactHTML.select - -external interface WelcomeProps : Props { - var type: Type - var language: Lang - var version: Version - var jomlEnabled: Boolean -} - -val Welcome = FC { props -> - var buildType by useState(props.type) - var language by useState(props.language) - var version by useState(props.version) - var jomlEnabled by useState(props.jomlEnabled) - val chosenNatives = HashMap>().also { - Natives.entries.forEach { n -> it[n] = useState(false) } - } - val chosenBindings = HashMap>().also { - Binding.entries.forEach { b -> it[b] = useState(b == Binding.CORE) } - } - - div { - css { - fontFamily = string("DejaVu Sans, Bitstream Vera Sans, Luxi Sans, Verdana, Arial, Helvetica, sans-serif") - } - p { +"OverrunGL Artifacts Customizer v$VER_CUSTOMIZER" } - - // Release type - select { - id = "type" - option { - value = Type.SNAPSHOT.itemName - +Type.SNAPSHOT.itemName - } - value = buildType.itemName - onChange = { event -> - event.target.let { (it.selectedOptions.item(0) as HTMLOptionElement?)?.value } - ?.also { buildType = ofType(it) } - } - } - - // Dependencies manager - div { - h4 { +"Mode" } - select { - id = "mode" - option { - value = "gradle" - +"Gradle" - } - } - } - - // Native libraries - div { - h4 { +"Natives" } - fun addNatives(natives: Natives) { - label { - input { - type = InputType.checkbox - onChange = { event -> - chosenNatives[natives]?.also { - var n by it - n = event.target.checked - } - } - } - +natives.itemName - } - } - Natives.entries.forEach(::addNatives) - } - - // Gradle build script language - div { - h4 { +"Language" } - select { - fun addLang(lang: Lang) { - option { - value = lang.itemName - +lang.itemName - } - } - id = "language" - Lang.entries.forEach(::addLang) - value = language.itemName - onChange = { event -> - event.target.let { (it.selectedOptions.item(0) as HTMLOptionElement?)?.value } - ?.also { language = ofLang(it) } - } - } - } - - // Addons - div { - h4 { +"Addons" } - label { - input { - type = InputType.checkbox - onChange = { event -> - jomlEnabled = event.target.checked - } - } - +"JOML v$VER_JOML" - } - } - - // OverrunGL version - div { - h4 { +"Version" } - select { - fun addVer(ver: Version) { - option { - value = ver.num - +ver.num - } - } - id = "version" - addVer(VER_0_1_0) - value = version.num - onChange = { event -> - event.target.let { (it.selectedOptions.item(0) as HTMLOptionElement?)?.value } - ?.also { version = VER_MAPPING[it]!! } - } - } - } - - // Bindings - div { - h4 { +"Contents" } - fun addBinding(binding: Binding) { - if (binding in version.bindings) { - label { - input { - type = InputType.checkbox - onChange = { event -> - chosenBindings[binding]?.also { - var b by it - b = event.target.checked - } - } - } - +binding.itemName - } - } - } - if (Binding.CORE in version.bindings) - label { - input { - type = InputType.checkbox - checked = true - disabled = true - } - +Binding.CORE.itemName - } - Binding.entries.filterNot { it == Binding.CORE }.forEach(::addBinding) - } - - fun PropsWithClassName.preCodeCss() { - css { - fontFamily = - string("DejaVu Sans Mono, JetBrains Mono, Bitstream Vera Sans Mono, Luxi Mono, Courier New, monospace") - } - } - - // Generated code - pre { - code { - preCodeCss() - - // Gradle - // import - if (language == Lang.GROOVY) +"import org.gradle.internal.os.OperatingSystem\n\n" - +"${if (language == Lang.GROOVY) "project.ext." else "val "}overrunglVersion = \"$version${if (buildType == Type.SNAPSHOT) "-SNAPSHOT" else ""}\"\n" - if (jomlEnabled) +"${if (language == Lang.GROOVY) "project.ext." else "val "}jomlVersion = \"$VER_JOML\"\n" - // natives - Natives.entries.filter { n -> - chosenNatives[n]?.let { - val r by it - r - } == true - }.also { - if (it.size == 1) { - when (language) { - Lang.GROOVY -> +"project.ext.overrunglNatives = \"${it[0]}\"\n" - Lang.KOTLIN -> +"val overrunglNatives = \"${it[0]}\"\n" - } - } else if (it.size > 1) { - // collect os - val linux = NATIVES_LINUX.filter { n -> n in it } - val macos = NATIVES_MACOS.filter { n -> n in it } - val windows = NATIVES_WIN.filter { n -> n in it } - when (language) { - Lang.GROOVY -> { - +"\nswitch (OperatingSystem.current()) {\n" - if (linux.isNotEmpty()) { - +" case OperatingSystem.LINUX:\n" - if (linux.size == 1) { - +" project.ext.overrunglNatives = ${linux[0]}\n break\n" - } else if (linux.size > 1) { - +" def osArch = System.getProperty(\"os.arch\")\n project.ext.overrunglNatives = osArch.startsWith(\"arm\") || osArch.startsWith(\"aarch64\")\n ? \"${Natives.LINUX_64}-\${osArch.contains(\"64\") || osArch.startsWith(\"armv8\") ? \"arm64\" : \"arm32\"}\"\n : \"${Natives.LINUX_64}\"\n break\n" - } - } - if (macos.isNotEmpty()) { - +" case OperatingSystem.MAC_OS:\n" - if (macos.size == 1) { - +" project.ext.overrunglNatives = ${macos[0]}\n break\n" - } else if (macos.size > 1) { - +" project.ext.overrunglNatives = System.getProperty(\"os.arch\").startsWith(\"aarch64\") ? \"${Natives.MACOS_ARM64}\" : \"${Natives.MACOS}\"\n break\n" - } - } - if (windows.isNotEmpty()) { - +" case OperatingSystem.WINDOWS:\n" - if (windows.size == 1) { - +" project.ext.overrunglNatives = ${windows[0]}\n break\n" - } else if (windows.size > 1) { - +" def osArch = System.getProperty(\"os.arch\")\n if (osArch.contains(\"64\"))\n project.ext.overrunglNatives = \"${Natives.WIN_64}\${sArch.startsWith(\"aarch64\") ? \"-arm64\" : \"\"}\"\n break\n" - } - } - +"}\n" - } - - Lang.KOTLIN -> { - +""" - - val overrunglNatives = Pair( - System.getProperty("os.name")!!, - System.getProperty("os.arch")!! - ).let { (name, arch) -> - when { - - """.trimIndent() - if (linux.isNotEmpty()) { - +" arrayOf(\"Linux\", \"FreeBSD\", \"SunOS\", \"Unit\").any { name.startsWith(it) } ->\n" - if (linux.size == 1) { - +" \"${linux[0]}\"\n" - } else if (linux.size > 1) { - +" if (arrayOf(\"arm\", \"aarch64\").any { arch.startsWith(it) })\n \"${Natives.LINUX_64}\${if (arch.contains(\"64\") || arch.startsWith(\"armv8\")) \"-arm64\" else \"-arm32\"}\"\n else \"${Natives.LINUX_64}\"\n" - } - } - if (macos.isNotEmpty()) { - +" arrayOf(\"Mac OS X\", \"Darwin\").any { name.startsWith(it) } ->\n" - if (macos.size == 1) { - +" \"${macos[0]}\"\n" - } else if (macos.size > 1) { - +" \"${Natives.MACOS}\${if (arch.startsWith(\"aarch64\")) \"-arm64\" else \"\"}\"\n" - } - } - if (windows.isNotEmpty()) { - +" arrayOf(\"Windows\").any { name.startsWith(it) } ->\n" - if (windows.size == 1) { - +" \"${windows[0]}\"\n" - } else if (windows.size > 1) { - +" if (arch.contains(\"64\"))\n \"${Natives.WIN_64}\${if (arch.startsWith(\"aarch64\")) \"-arm64\" else \"\"}\"\n else throw Error(\"Unrecognized or unsupported architecture. Please set \\\"overrunglNatives\\\" manually\")\n" - } - } - +""" - else -> throw Error("Unrecognized or unsupported platform. Please set \"overrunglNatives\" manually") - } - } - - """.trimIndent() - } - } - } - } - // repositories - +""" - - repositories { - mavenCentral() - - """.trimIndent() - if (buildType == Type.SNAPSHOT) { - when (language) { - Lang.GROOVY -> +" maven { url \"https://s01.oss.sonatype.org/content/repositories/snapshots/\" }" - Lang.KOTLIN -> +" maven { url = uri(\"https://s01.oss.sonatype.org/content/repositories/snapshots/\") }" - } - } - // dependencies - +""" - - } - - dependencies { - implementation(platform("io.github.over-run:overrungl-bom:${"$"}overrunglVersion")) - - """.trimIndent() - Binding.entries.filter { b -> - chosenBindings[b]?.let { - val r by it - r - } == true - }.forEach { - +" implementation(\"io.github.over-run:${it.artifactName}\")\n" - if (it.natives.isNotEmpty()) { - +" runtimeOnly(\"io.github.over-run:${it.artifactName}::\$overrunglNatives\")\n" - } - } - if (jomlEnabled) { - +" implementation(\"io.github.over-run:overrungl-joml\")\n" - +" implementation(\"org.joml:joml:\$jomlVersion\")\n" - } - +"}" - } - } - - // VM options - div { - h4 { +"VM Options" } - p { +"Add this content to your VM options. You might need to add the module name of your application to it." } - pre { - code { - preCodeCss() - - +buildString { - append("--enable-native-access=") - Binding.entries.filter { b -> - chosenBindings[b]?.let { - val r by it - r - } == true - }.forEachIndexed { index, binding -> - if (index != 0) { - append(',') - } - append(binding.moduleName) - } - } - } - } - } - } -} diff --git a/src/jsMain/resources/index.html b/src/jsMain/resources/index.html deleted file mode 100644 index 377a8cb..0000000 --- a/src/jsMain/resources/index.html +++ /dev/null @@ -1,11 +0,0 @@ - - - - - OverrunGL Artifacts Customizer - - -
- - - diff --git a/src/jvmMain/kotlin/io/github/overrun/application/Server.kt b/src/jvmMain/kotlin/io/github/overrun/application/Server.kt deleted file mode 100644 index 7f610ec..0000000 --- a/src/jvmMain/kotlin/io/github/overrun/application/Server.kt +++ /dev/null @@ -1,35 +0,0 @@ -package io.github.overrun.application - -import io.ktor.http.* -import io.ktor.server.application.* -import io.ktor.server.engine.* -import io.ktor.server.html.* -import io.ktor.server.http.content.* -import io.ktor.server.netty.* -import io.ktor.server.routing.* -import kotlinx.html.* - -fun HTML.index() { - head { - title("OverrunGL Artifacts Customizer") - } - body { - div { - id = "root" - } - script(src = "/static/overrungl-gen.js") {} - } -} - -fun main() { - embeddedServer(Netty, port = 8080, host = "127.0.0.1") { - routing { - get("/") { - call.respondHtml(HttpStatusCode.OK, HTML::index) - } - static("/static") { - resources() - } - } - }.start(wait = true) -}