Skip to content

Commit

Permalink
Merge branch 'main' into fix/support.configuration.cache.with.runJs
Browse files Browse the repository at this point in the history
  • Loading branch information
soywiz authored Oct 5, 2023
2 parents 2f4e40d + ea68fd2 commit 3f667fa
Show file tree
Hide file tree
Showing 28 changed files with 182 additions and 130 deletions.
1 change: 1 addition & 0 deletions .github/workflows/TEST.yml
Original file line number Diff line number Diff line change
Expand Up @@ -145,6 +145,7 @@ jobs:
- { name: e2e test, working-directory: e2e/e2e-test, run: ./gradlew checkReferencesJvm --stacktrace }
- { name: Archive E2E Test Results, if: failure(), uses: actions/upload-artifact@v3, with: { name: e2e-test-results-linux-jvm, retention-days: 21, path: "**/e2e/e2e-test/build/screenshots", if-no-files-found: ignore } }
- { name: e2e multi test and hotreload, working-directory: e2e/e2e-test-multi, run: "./gradlew --watch-fs --warn --configuration-cache --configuration-cache-problems=warn compileKotlinJvm" }
- { name: e2e multi test runJvmAutoreload, working-directory: e2e/e2e-test-multi, run: "./gradlew --configuration-cache :client:runJvmAutoreload" }
- { name: Check publication includes iOS, run: ./gradlew checkModulePublication }

test-jvm-macos:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ import org.gradle.api.artifacts.*
import org.gradle.api.file.*
import org.gradle.api.tasks.*
import org.gradle.jvm.tasks.*
import org.gradle.process.CommandLineArgumentProvider
import java.io.*

fun Project.findAllProjectDependencies(visited: MutableSet<Project> = mutableSetOf()): Set<Project> {
Expand All @@ -32,24 +33,17 @@ open class KorgeJavaExecWithAutoreload : KorgeJavaExec() {
private var rootDir: File = project.rootProject.rootDir
@get:InputFiles
lateinit var rootJars: List<File>
@get:InputFile

//@get:InputFile
//private var reloadAgentConfiguration: Configuration = project.configurations.getByName(KORGE_RELOAD_AGENT_CONFIGURATION_NAME)//.resolve().first()
lateinit var reloadAgentJar: File
//lateinit var reloadAgentJar: File


init {
//val reloadAgent = project.findProject(":korge-reload-agent")
//if (reloadAgent != null)
//project.dependencies.add()
project.afterEvaluate {
val allProjects = project.findAllProjectDependencies()
//projectPaths = allProjects.map { it.path }
projectPaths = listOf(project.path)
rootJars = allProjects.map { File(it.buildDir, "classes/kotlin/jvm/main") }
//println("allProjects=${allProjects.map { it.name }}")
//println("projectPaths=$projectPaths")
//println("rootJars=\n${rootJars.toList().joinToString("\n")}")
}

/*
project.afterEvaluate {
project.afterEvaluate {
Expand All @@ -71,51 +65,57 @@ open class KorgeJavaExecWithAutoreload : KorgeJavaExec() {
}
*/
val reloadAgent = project.findProject(":korge-reload-agent")
reloadAgentJar = when {
val reloadAgentJar = when {
reloadAgent != null -> (project.rootProject.tasks.getByPath(":korge-reload-agent:jar") as Jar).outputs.files.files.first()
else -> project.configurations.getByName(KORGE_RELOAD_AGENT_CONFIGURATION_NAME).resolve().first()
}
}

override fun exec() {
//val gradlewCommand = if (isWindows) "gradlew.bat" else "gradlew"

println("runJvmAutoreload:reloadAgentJar=$reloadAgentJar")
//val outputJar = JvmTools.findPathJar(Class.forName("korlibs.korge.reloadagent.KorgeReloadAgent"))

//val agentJarTask: org.gradle.api.tasks.bundling.Jar = project(":korge-reload-agent").tasks.findByName("jar") as org.gradle.api.tasks.bundling.Jar
//val outputJar = agentJarTask.outputs.files.files.first()
//println("agentJarTask=$outputJar")

jvmArgs(
"-javaagent:$reloadAgentJar=${listOf(
"$httpPort",
ArrayList<String>().apply {
add("-classpath")
add("${rootDir}/gradle/wrapper/gradle-wrapper.jar")
add("org.gradle.wrapper.GradleWrapperMain")
//add("--no-daemon") // This causes: Continuous build does not work when file system watching is disabled
add("--watch-fs")
add("--warn")
add("--project-dir=${rootDir}")
if (doConfigurationCache) {
add("--configuration-cache")
add("--configuration-cache-problems=warn")
}
add("-t")
add("compileKotlinJvm")
//add("compileKotlinJvmAndNotify")
for (projectPath in projectPaths) {
add("${projectPath.trimEnd(':')}:compileKotlinJvmAndNotify")
}
}.joinToString(CMD_SEPARATOR),
"$enableRedefinition",
rootJars.joinToString(CMD_SEPARATOR) { it.absolutePath }
).joinToString(ARGS_SEPARATOR)}"
)
environment("KORGE_AUTORELOAD", "true")
project.afterEvaluate {
val allProjects = project.findAllProjectDependencies()
//projectPaths = allProjects.map { it.path }
projectPaths = listOf(project.path)
rootJars = allProjects.map { File(it.buildDir, "classes/kotlin/jvm/main") }
//println("allProjects=${allProjects.map { it.name }}")
//println("projectPaths=$projectPaths")
//println("rootJars=\n${rootJars.toList().joinToString("\n")}")

super.exec()
//println("runJvmAutoreload:reloadAgentJar=$reloadAgentJar")
//val outputJar = JvmTools.findPathJar(Class.forName("korlibs.korge.reloadagent.KorgeReloadAgent"))

//val agentJarTask: org.gradle.api.tasks.bundling.Jar = project(":korge-reload-agent").tasks.findByName("jar") as org.gradle.api.tasks.bundling.Jar
//val outputJar = agentJarTask.outputs.files.files.first()
//println("agentJarTask=$outputJar")

jvmArgs(
"-javaagent:$reloadAgentJar=${listOf(
"$httpPort",
ArrayList<String>().apply {
add("-classpath")
add("${rootDir}/gradle/wrapper/gradle-wrapper.jar")
add("org.gradle.wrapper.GradleWrapperMain")
//add("--no-daemon") // This causes: Continuous build does not work when file system watching is disabled
add("--watch-fs")
add("--warn")
add("--project-dir=${rootDir}")
if (doConfigurationCache) {
add("--configuration-cache")
add("--configuration-cache-problems=warn")
}
add("-t")
add("compileKotlinJvm")
//add("compileKotlinJvmAndNotify")
for (projectPath in projectPaths) {
add("${projectPath.trimEnd(':')}:compileKotlinJvmAndNotify")
}
}.joinToString(CMD_SEPARATOR),
"$enableRedefinition",
rootJars.joinToString(CMD_SEPARATOR) { it.absolutePath }
).joinToString(ARGS_SEPARATOR)}"
)

environment("KORGE_AUTORELOAD", "true")

}
}
}

Expand Down Expand Up @@ -145,19 +145,6 @@ open class KorgeJavaExec : JavaExec() {
val korgeClassPath: FileCollection = project.getKorgeClassPath()

override fun exec() {
val firstThread = firstThread
?: (
System.getenv("KORGE_START_ON_FIRST_THREAD") == "true"
|| System.getenv("KORGW_JVM_ENGINE") == "sdl"
//|| project.findProperty("korgw.jvm.engine") == "sdl"
)

if (firstThread && isMacos) {
jvmArgs("-XstartOnFirstThread")
//println("Executed jvmArgs(\"-XstartOnFirstThread\")")
} else {
//println("firstThread=$firstThread, isMacos=$isMacos")
}
classpath = korgeClassPath
for (classPath in classpath.toList()) {
logger.info("- $classPath")
Expand All @@ -174,6 +161,18 @@ open class KorgeJavaExec : JavaExec() {
systemProperties = (System.getProperties().toMutableMap() as MutableMap<String, Any>) - "java.awt.headless"
defaultCharacterEncoding = Charsets.UTF_8.toString()
// https://github.com/korlibs/korge-plugins/issues/25
project.afterEvaluate {
val firstThread = firstThread
?: (
System.getenv("KORGE_START_ON_FIRST_THREAD") == "true"
|| System.getenv("KORGW_JVM_ENGINE") == "sdl"
//|| project.findProperty("korgw.jvm.engine") == "sdl"
)
if (firstThread && isMacos) {
jvmArgs("-XstartOnFirstThread")
}
}
//jvmArgumentProviders.add(provider)
}
}

Expand Down
8 changes: 8 additions & 0 deletions docs/aliases/korge-gettingstarted.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
---
layout: default
title: KorGE
fa-icon: fa-home
permalink: /korge/gettingstarted/
useMermaid: true
redirect_to: /getting-started/
---
1 change: 1 addition & 0 deletions e2e/e2e-test-multi/client/src/commonMain/kotlin/main.kt
Original file line number Diff line number Diff line change
Expand Up @@ -12,5 +12,6 @@ suspend fun main() = Korge(windowSize = Size(512, 512), backgroundColor = Colors
class MyMainScene : Scene() {
override suspend fun SContainer.sceneMain() {
text("Text: $mySharedString")
gameWindow.close()
}
}
2 changes: 2 additions & 0 deletions e2e/e2e-test-multi/gradle.properties
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
org.gradle.configuration-cache=true
#org.gradle.configuration-cache.problems=error
5 changes: 3 additions & 2 deletions e2e/e2e-test/src/commonMain/kotlin/RefMain.kt
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ import korlibs.io.file.std.*
import korlibs.io.lang.*
import korlibs.io.serialization.json.Json
import korlibs.math.geom.*
import korlibs.math.interpolation.*

suspend fun main() = Korge(windowSize = Size(768, 512), backgroundColor = Colors["#2b2b2b"]) {
//println("StandardPaths.cwd=${korlibs.io.file.std.StandardPaths.cwd}")
Expand Down Expand Up @@ -101,8 +102,8 @@ object FiltersE2ETestCase : E2ETestCase() {
println("PREPARING VIEWS...")
image(bitmap).scale(.5).position(0, 0).addFilter(WaveFilter(time = 0.5.seconds, crestDistance = Vector2D(256, 128)))
image(bitmap).scale(.5).position(256, 0).addFilter(BlurFilter(radius = 6.0))
image(bitmap).scale(.5).position(512, 0).addFilter(TransitionFilter(TransitionFilter.Transition.SWEEP, reversed = false, spread = 1.0, ratio = 0.5))
image(bitmap2).scale(.5).position(0, 256).addFilter(PageFilter(hratio = 0.5, hamplitude1 = 20.0))
image(bitmap).scale(.5).position(512, 0).addFilter(TransitionFilter(TransitionFilter.Transition.SWEEP, reversed = false, spread = 1.0, ratio = Ratio.HALF))
image(bitmap2).scale(.5).position(0, 256).addFilter(PageFilter(hratio = Ratio.HALF, hamplitude1 = 20.0))
image(bitmap2).scale(.5).position(256, 256).addFilter(Convolute3Filter(Convolute3Filter.KERNEL_SHARPEN))
image(bitmap2).scale(.5).position(512, 256).addFilter(SwizzleColorsFilter("bgga"))
println("VIEWS PREPARED")
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ private const val HALF_PI = PI.toFloat() / 2f
fun interface Easing {
operator fun invoke(it: Float): Float
operator fun invoke(it: Double): Double = invoke(it.toFloat()).toDouble()
operator fun invoke(it: Ratio): Ratio = Ratio(invoke(it.toFloat()).toDouble())

companion object {
operator fun invoke(name: () -> String, block: (Float) -> Float): Easing {
Expand Down Expand Up @@ -418,12 +419,15 @@ inline operator fun Ratio.div(value: Double): Double = this.value / value

@Deprecated("", ReplaceWith("this")) fun Ratio.toRatio(): Ratio = this

inline fun Number.toRatio(): Ratio = Ratio(this.toDouble())
fun Float.toRatio(): Ratio = Ratio(this)
fun Double.toRatio(): Ratio = Ratio(this)

inline fun Number.toRatio(max: Number): Ratio = Ratio(this.toDouble(), max.toDouble())
fun Float.toRatio(max: Float): Ratio = Ratio(this, max)
fun Double.toRatio(max: Double): Ratio = Ratio(this, max)

inline fun Number.toRatioClamped(): Ratio = Ratio(this.toDouble().clamp01())
fun Float.toRatioClamped(): Ratio = Ratio(this.clamp01())
fun Double.toRatioClamped(): Ratio = Ratio(this.clamp01())

Expand Down
9 changes: 5 additions & 4 deletions korge-sandbox/src/commonMain/kotlin/samples/MainBlur.kt
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ import korlibs.korge.view.*
import korlibs.korge.view.filter.*
import korlibs.math.geom.Anchor
import korlibs.math.geom.degrees
import korlibs.math.interpolation.*
import korlibs.time.*
import kotlin.reflect.*

Expand Down Expand Up @@ -73,7 +74,7 @@ class MainBlur : Scene() {
val colorMatrixFilter = ColorMatrixFilter(ColorMatrixFilter.SEPIA_MATRIX, blendRatio = 0.5)
image(bitmap).xy(500, 250).filters(colorMatrixFilter).bindScale()

val transitionFilter = TransitionFilter(TransitionFilter.Transition.CIRCULAR, reversed = false, ratio = 0.5, spread = 0.2)
val transitionFilter = TransitionFilter(TransitionFilter.Transition.CIRCULAR, reversed = false, ratio = Ratio.HALF, spread = 0.2)
image(bitmap).xy(370, 250).filters(transitionFilter).bindScale()

val pageFilter = PageFilter()
Expand Down Expand Up @@ -129,11 +130,11 @@ class MainBlur : Scene() {
}
uiHorizontalFill {
uiText("Blend").styles { textColor = Colors.BLACK }
uiSlider(value = transitionFilter.ratio, min = 0.0, max = 1.0, step = 0.0, decimalPlaces = 2).changed {
uiSlider(value = transitionFilter.ratio.toDouble(), min = 0.0, max = 1.0, step = 0.0, decimalPlaces = 2).changed {
colorMatrixFilter.blendRatio = it
pageFilter.hamplitude0 = it
transitionFilter.ratio = it
pageFilter.hratio = it
transitionFilter.ratio = it.toRatio()
pageFilter.hratio = it.toRatio()
waveFilter.time = it.seconds
flagFilter.time = it.seconds
}
Expand Down
3 changes: 2 additions & 1 deletion korge-sandbox/src/commonMain/kotlin/samples/MainClipping.kt
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ import korlibs.korge.view.*
import korlibs.korge.view.filter.*
import korlibs.korge.view.vector.*
import korlibs.math.geom.*
import korlibs.math.interpolation.*

class MainClipping : Scene() {
override suspend fun SContainer.sceneMain() {
Expand Down Expand Up @@ -38,7 +39,7 @@ class MainClipping : Scene() {
solidRect(512, 512, Colors.BLUE)
}
}, MaskTransition(TransitionFilter.Transition.CIRCULAR))
tv.ratio = 0.5
tv.ratio = Ratio.HALF
addChild(tv)

gpuShapeView({
Expand Down
8 changes: 4 additions & 4 deletions korge-sandbox/src/commonMain/kotlin/samples/MainFilters.kt
Original file line number Diff line number Diff line change
Expand Up @@ -73,12 +73,12 @@ class MainFilters : ScaledScene(768, 512) {
sequence(looped = true) {
//tween(color::blendRatio[0], time = 1.seconds, easing = Easing.EASE_IN_OUT)
//tween(color::blendRatio[1], time = 1.seconds, easing = Easing.EASE_IN_OUT)
tween(color::ratio[0], time = 1.seconds, easing = Easing.EASE_IN_OUT)
tween(color::ratio[1], time = 1.seconds, easing = Easing.EASE_IN_OUT)
tween(color::ratio[Ratio.ZERO], time = 1.seconds, easing = Easing.EASE_IN_OUT)
tween(color::ratio[Ratio.ONE], time = 1.seconds, easing = Easing.EASE_IN_OUT)
}
sequence(looped = true) {
tween(page::hratio[0], time = 1.seconds, easing = Easing.EASE_IN_OUT)
tween(page::hratio[1], time = 1.seconds, easing = Easing.EASE_IN_OUT)
tween(page::hratio[Ratio.ZERO], time = 1.seconds, easing = Easing.EASE_IN_OUT)
tween(page::hratio[Ratio.ONE], time = 1.seconds, easing = Easing.EASE_IN_OUT)
}
sequence(looped = true) {
block { conImg.filter = Convolute3Filter(Convolute3Filter.KERNEL_SHARPEN) }
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ import korlibs.korge.scene.*
import korlibs.korge.view.*
import korlibs.korge.view.filter.*
import korlibs.math.geom.*
import korlibs.math.interpolation.*
import korlibs.time.*

class MainFiltersRenderToBitmap : Scene() {
Expand All @@ -18,7 +19,7 @@ class MainFiltersRenderToBitmap : Scene() {
image(bitmap).scale(.5).position(0, 0).addFilter(WaveFilter(time = 0.5.seconds))
//image(bitmap).scale(.5).position(256, 0).addFilter(DirectionalBlurFilter(radius = 32.0))
image(bitmap).scale(.5).position(256, 0).addFilter(BlurFilter(radius = 32.0))
image(bitmap).scale(.5).position(512, 0).addFilter(TransitionFilter(TransitionFilter.Transition.SWEEP, reversed = false, spread = 1.0, ratio = 0.5))
image(bitmap).scale(.5).position(512, 0).addFilter(TransitionFilter(TransitionFilter.Transition.SWEEP, reversed = false, spread = 1.0, ratio = Ratio.HALF))
image(bitmap).scale(.5).position(0, 256).addFilter(PageFilter(hratio = 0.5, hamplitude1 = 20.0))
image(bitmap).scale(.5).position(256, 256).addFilter(Convolute3Filter(Convolute3Filter.KERNEL_SHARPEN))
image(bitmap).scale(.5).position(512, 256).addFilter(SwizzleColorsFilter("bgga"))
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -73,12 +73,12 @@ class MainFiltersSample : Scene() {
sequence(looped = true) {
//tween(color::blendRatio[0], time = 1.seconds, easing = Easing.EASE_IN_OUT)
//tween(color::blendRatio[1], time = 1.seconds, easing = Easing.EASE_IN_OUT)
tween(color::ratio[0], time = 1.seconds, easing = Easing.EASE_IN_OUT)
tween(color::ratio[1], time = 1.seconds, easing = Easing.EASE_IN_OUT)
tween(color::ratio[Ratio.ZERO], time = 1.seconds, easing = Easing.EASE_IN_OUT)
tween(color::ratio[Ratio.ONE], time = 1.seconds, easing = Easing.EASE_IN_OUT)
}
sequence(looped = true) {
tween(page::hratio[0], time = 1.seconds, easing = Easing.EASE_IN_OUT)
tween(page::hratio[1], time = 1.seconds, easing = Easing.EASE_IN_OUT)
tween(page::hratio[Ratio.ZERO], time = 1.seconds, easing = Easing.EASE_IN_OUT)
tween(page::hratio[Ratio.ONE], time = 1.seconds, easing = Easing.EASE_IN_OUT)
}
sequence(looped = true) {
block { conImg.filter = Convolute3Filter(Convolute3Filter.KERNEL_SHARPEN) }
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ import korlibs.korge.scene.*
import korlibs.korge.ui.*
import korlibs.korge.view.*
import korlibs.korge.view.filter.*
import korlibs.math.interpolation.*

class MainTransition : Scene() {
override suspend fun SContainer.sceneMain() {
Expand All @@ -13,7 +14,7 @@ class MainTransition : Scene() {
transition.startNewTransition(SolidRect(100, 100, Colors.BLUE), MaskTransition(
TransitionFilter.Transition.CIRCULAR
))
transition.ratio = 0.5
transition.ratio = Ratio.HALF
transition.filters(DropshadowFilter(shadowColor = Colors.PURPLE))

solidRect(100, 100, Colors.GREEN).filters(DropshadowFilter(shadowColor = Colors.PURPLE))
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,12 +7,13 @@ import korlibs.korge.scene.*
import korlibs.korge.tween.*
import korlibs.korge.view.*
import korlibs.korge.view.filter.*
import korlibs.math.interpolation.*
import korlibs.time.*

class MainTransitionFilter : ScaledScene(768, 512) {
override suspend fun SContainer.sceneMain() {
val bitmap = resourcesVfs["korge.png"].readBitmap()
val transition = TransitionFilter(TransitionFilter.Transition.SWEEP, reversed = false, spread = 1.0, ratio = 0.5)
val transition = TransitionFilter(TransitionFilter.Transition.SWEEP, reversed = false, spread = 1.0, ratio = Ratio.HALF)

image(transition.transition.bmp)

Expand All @@ -24,8 +25,8 @@ class MainTransitionFilter : ScaledScene(768, 512) {

launchImmediately {
while (true) {
tween(transition::ratio[1.0], time = 0.5.seconds)
tween(transition::ratio[0.0], time = 0.5.seconds)
tween(transition::ratio[Ratio.ONE], time = 0.5.seconds)
tween(transition::ratio[Ratio.ZERO], time = 0.5.seconds)
}
}
}
Expand Down
4 changes: 2 additions & 2 deletions korge-sandbox/src/commonMain/kotlin/samples/MainUI.kt
Original file line number Diff line number Diff line change
Expand Up @@ -105,8 +105,8 @@ class MainUI : Scene() {
}
val job = launchImmediately {
while (true) {
tween(progress::ratio[1.0], time = 1.seconds, easing = Easing.EASE_IN_OUT)
tween(progress::ratio[1.0, 0.0], time = 1.seconds, easing = Easing.EASE_IN_OUT)
tween(progress::ratio[Ratio.ONE], time = 1.seconds, easing = Easing.EASE_IN_OUT)
tween(progress::ratio[Ratio.ONE, Ratio.ZERO], time = 1.seconds, easing = Easing.EASE_IN_OUT)
}
}
uiButton("Stop Progress").position(Point(64 + progress.width, 32.0)).mouse { onClick { job.cancel() } }
Expand Down
Loading

0 comments on commit 3f667fa

Please sign in to comment.