Skip to content

Commit

Permalink
add: register a runInstancingBenchmark task in build.gradle.kts
Browse files Browse the repository at this point in the history
  • Loading branch information
smlpt committed Apr 22, 2024
1 parent 8d500a3 commit a323a1d
Showing 1 changed file with 30 additions and 13 deletions.
43 changes: 30 additions & 13 deletions build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -380,6 +380,21 @@ tasks {
}
}

register("runInstancingBenchmark", JavaExec::class.java) {
classpath = sourceSets.main.get().runtimeClasspath

mainClass.set("sc.iview.commands.demo.advanced.InstancingBenchmark")

val props = System.getProperties().filter { (k, _) -> k.toString().startsWith("sciview.benchmark.") }

val additionalArgs = System.getenv("SCENERY_JVM_ARGS")
allJvmArgs = if (additionalArgs != null) {
allJvmArgs + props.flatMap { (k, v) -> listOf("-D$k=$v") } + additionalArgs
} else {
allJvmArgs + props.flatMap { (k, v) -> listOf("-D$k=$v") }
}
}

sourceSets.main.get().allSource.files
.filter { it.path.contains("demo") && (it.name.endsWith(".kt") || it.name.endsWith(".java")) }
.map {
Expand All @@ -395,20 +410,22 @@ tasks {
val exampleType = className.substringBeforeLast(".").substringAfterLast(".")

logger.info("Registering $exampleName of $exampleType from $className")
register<JavaExec>(name = className.substringAfterLast(".")) {
classpath = sourceSets.test.get().runtimeClasspath
mainClass.set(className)
group = "demos.$exampleType"

val props = System.getProperties().filter { (k, _) -> k.toString().startsWith("scenery.") }

val additionalArgs = System.getenv("SCENERY_JVM_ARGS")
allJvmArgs = if (additionalArgs != null) {
allJvmArgs + props.flatMap { (k, v) -> listOf("-D$k=$v") } + additionalArgs
} else {
allJvmArgs + props.flatMap { (k, v) -> listOf("-D$k=$v") }
val name = className.substringAfterLast(".")
if (name != "InstancingBenchmark")
register<JavaExec>(name = className.substringAfterLast(".")) {
classpath = sourceSets.test.get().runtimeClasspath
mainClass.set(className)
group = "demos.$exampleType"

val props = System.getProperties().filter { (k, _) -> k.toString().startsWith("scenery.") }

val additionalArgs = System.getenv("SCENERY_JVM_ARGS")
allJvmArgs = if (additionalArgs != null) {
allJvmArgs + props.flatMap { (k, v) -> listOf("-D$k=$v") } + additionalArgs
} else {
allJvmArgs + props.flatMap { (k, v) -> listOf("-D$k=$v") }
}
}
}
}

register<JavaExec>(name = "run") {
Expand Down

0 comments on commit a323a1d

Please sign in to comment.