Skip to content

Commit

Permalink
[STB] Prepare generator
Browse files Browse the repository at this point in the history
  • Loading branch information
squid233 committed Aug 23, 2023
1 parent cf6b687 commit 343b205
Show file tree
Hide file tree
Showing 4 changed files with 82 additions and 1 deletion.
6 changes: 6 additions & 0 deletions build.gradle.kts
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import org.gradle.plugins.ide.idea.model.IdeaModel
import org.jetbrains.kotlin.gradle.dsl.KotlinJvmProjectExtension
import java.nio.file.Files
import kotlin.io.path.Path

Expand All @@ -7,6 +8,7 @@ plugins {
`maven-publish`
signing
id("me.champeau.jmh") version "0.7.1" apply false
embeddedKotlin("jvm") apply false
}

val projGroupId: String by project
Expand All @@ -22,6 +24,7 @@ val developers: String by project
val jdkEABuildDoc: String? = "jdk21"
val targetJavaVersion = 21
val enablePreview = true
rootProject.ext["enablePreview"] = enablePreview

group = projGroupId
version = projVersion
Expand Down Expand Up @@ -118,6 +121,7 @@ enum class Artifact(
}

subprojects {
apply(plugin = "org.jetbrains.kotlin.jvm")
apply(plugin = "java-library")
apply(plugin = "idea")
apply(plugin = "me.champeau.jmh")
Expand Down Expand Up @@ -198,6 +202,8 @@ subprojects {
}

the<IdeaModel>().module.inheritOutputDirs = true

the<KotlinJvmProjectExtension>().jvmToolchain(20)
}

tasks.register("assembleJavadocArgs") {
Expand Down
10 changes: 9 additions & 1 deletion modules/overrungl.opengl/build.gradle.kts
Original file line number Diff line number Diff line change
@@ -1,10 +1,18 @@
val enablePreview: Boolean by rootProject.ext

sourceSets {
create("generator")
}

tasks.named<JavaCompile>("compileGeneratorJava") {
javaCompiler.set(javaToolchains.compilerFor {
languageVersion.set(JavaLanguageVersion.of(20))
})
}

tasks.register<JavaExec>("generate") {
classpath(sourceSets["generator"].runtimeClasspath)
jvmArgs("--enable-preview")
if (enablePreview) jvmArgs("--enable-preview")
mainClass.set("overrungl.opengl.OpenGLGenerator")
workingDir = File("src/main/java/overrungl/opengl")
}
18 changes: 18 additions & 0 deletions modules/overrungl.stb/build.gradle.kts
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
val enablePreview: Boolean by rootProject.ext

sourceSets {
create("generator")
}

tasks.named<JavaCompile>("compileGeneratorJava") {
javaCompiler.set(javaToolchains.compilerFor {
targetCompatibility = "20"
})
}

tasks.register<JavaExec>("generate") {
classpath(sourceSets["generator"].runtimeClasspath)
if (enablePreview) jvmArgs("--enable-preview")
mainClass.set("overrungl.stb.STBGeneratorKt")
workingDir = File("src/main/java/overrungl/stb")
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,49 @@
/*
* MIT License
*
* Copyright (c) 2023 Overrun Organization
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal
* in the Software without restriction, including without limitation the rights
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
* copies of the Software, and to permit persons to whom the Software is
* furnished to do so, subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included in all
* copies or substantial portions of the Software.
*/

package overrungl.stb

class Function {
}

class STBClass {
private val functions = ArrayList<Function>()

operator fun String.invoke(name: String) {
}

fun generate() {
TODO()
}
}

operator fun String.invoke(block: STBClass.() -> Unit) {
STBClass().also(block).generate()
}

fun vorbis() {
"STBVorbis" {
"stb_vorbis_get_info"("getInfo")
}
}

/**
* @author squid233
* @since 0.1.0
*/
fun main() {
vorbis()
}

0 comments on commit 343b205

Please sign in to comment.