-
Notifications
You must be signed in to change notification settings - Fork 63
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Add K/Wasm support #914
Add K/Wasm support #914
Conversation
b0c4068
to
8234ac7
Compare
@@ -35,6 +35,19 @@ class AndroidXPlugin : Plugin<Project> { | |||
"from" to "$supportRoot/buildSrc/apply/applyAndroidXImplPlugin.gradle" | |||
) | |||
) | |||
|
|||
project.configurations.all { | |||
// TODO: remove these HACKS when possible |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It's not supposed to be merged into jb-main branch.
Should be removed when all required libs are properly built and published
@@ -138,10 +138,20 @@ class AndroidXComposeImplPlugin : Plugin<Project> { | |||
} | |||
|
|||
project.tasks.withType(KotlinJsCompile::class.java).configureEach { compile -> | |||
val isWasm = compile.kotlinOptions.freeCompilerArgs.contains("-Xwasm") |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Currently KotlinJsCompile task type is reused for k/wasm compilations.
For the nearest release we'll keep decoys enabled for k/js, but not for k/wasm. In the future it will be disabled for both.
project.rootProject.resolveProject(":compose:compiler:compiler") | ||
} | ||
) | ||
project.dependencies.add(COMPILER_PLUGIN_CONFIGURATION, "org.jetbrains.compose.compiler:compiler:1.5.4") |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
To build the compose-core libs with our published compose compiler plugin, rather than from the plugin built from the sources.
This way we have a single source of truth.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
let's move this version to gradle.properties
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
done
@@ -125,6 +126,7 @@ class ComposeIrGenerationExtension( | |||
|
|||
val mangler = when { | |||
pluginContext.platform.isJs() -> JsManglerIr | |||
pluginContext.platform.isWasm() -> JsManglerIr |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
In the future, the changes in compose/compiler can be ignored. When merging from upstream we can take their sources.
We have a separate branch with our patches for building and publishing the compose compiler plugin.
@@ -193,6 +193,6 @@ private fun Any?.integralValue(): Long = when (this) { | |||
|
|||
private fun Any?.toStringForAssert(): String = when { | |||
this == null -> toString() | |||
isIntegralBoxedPrimitive() -> "${this::class.qualifiedName}<$this>" | |||
isIntegralBoxedPrimitive() -> "${this::class.simpleName}<$this>" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
qualifiedName
is a reflection API not available for web targets.
@@ -112,20 +112,3 @@ apple { | |||
} | |||
} | |||
} | |||
|
|||
// TODO: Workaround, see https://youtrack.jetbrains.com/issue/KT-55751 | |||
val myAttribute = Attribute.of("myOwnAttribute", String::class.java) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Dima has checked that this workaround is not needed anymore with kotlin 1.9.2x
/** | ||
* Returns if the registry is setup to receive registrations from [SkiaRootForTest]s | ||
*/ | ||
val isSetUp: Boolean | ||
get() = SkiaRootForTest.onRootCreatedCallback == ::onRootCreated | ||
get() = SkiaRootForTest.onRootCreatedCallback == _onRootCreated |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
cc @MatkovIvan JFYI: unfortunately, not all targets reuse the same reference here.
Apparently, k/wasm creates a new instance every time and the check is always false.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Let's just store isSetUp
as a boolean flag then
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
ACK
.gitignore
Outdated
@@ -39,3 +39,5 @@ __pycache__ | |||
|
|||
# Don't ignore src files under build package | |||
!**/src/**/build | |||
/jbdeps/android-sdk/linux/* |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why do we need this? We already have jbdeps/.gitignore
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Hm. Right, for some reason it didn't ignore the files for me.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
removed the change
buildSrc/build.gradle
Outdated
@@ -32,7 +32,7 @@ allprojects { | |||
kotlinOptions { | |||
jvmTarget = "17" | |||
freeCompilerArgs += [ | |||
"-Werror", | |||
// "-Werror", // commented in JB-fork |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can we not comment this, and fix the warnings?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
done
project.rootProject.resolveProject(":compose:compiler:compiler") | ||
} | ||
) | ||
project.dependencies.add(COMPILER_PLUGIN_CONFIGURATION, "org.jetbrains.compose.compiler:compiler:1.5.4") |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
let's move this version to gradle.properties
actual fun get(): Int = delegate.value | ||
actual fun set(value: Int) { | ||
delegate.value = value | ||
} | ||
actual fun add(amount: Int): Int = delegate.addAndGet(amount) | ||
} | ||
|
||
@OptIn(ExperimentalNativeApi::class) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We should keep in mind that we can't release Compose for iOS if at that time it is still be experimental. It doesn't add binary compatibility guarantees, which we need for stable Compose targets.
|
||
@OptIn(DelicateCoroutinesApi::class) | ||
actual suspend fun testWithTimeout(timeoutMs: Long, block: suspend CoroutineScope.() -> Unit) { | ||
GlobalScope.launch { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
GlobalScope.launch { | |
coroutineScope { | |
block() | |
} |
Will this work? An async call is fragile.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This function is not implemented properly at all (I added this dumb implementation a few month ago and forgot about it). It ignores timeoutMs
. I'll update it separately.
It's used in our tests only.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
COMPOSE-662
*/ | ||
|
||
// TODO: in a browser we have only 1 thread and it's actually a UI thread. | ||
// But returning `true` here breaks `setContent` - `waitForIdle` is not called, but seems to be necessary. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Let's create an issue to investigate this. It shouldn't work this way.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Added to the comment - COMPOSE-661
languageVersion = "1.5" | ||
apiVersion = "1.5" | ||
languageVersion = "1.8" | ||
apiVersion = "1.8" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
kotlin 1.9.21 shows a warning for 1.5
* Workaround `isOnUiThread` (ui-test) for k/wasm browser target * Implement PlatformLocale and StringDelegate for k/wasm * Get rid of expect/actuals for jsWasmMain and use js(...) for a common implementation * use the list of preferred languages - `window.navigator.languages` * delete unused fun `currentLanguageTag`
reason: I guess new compiler plugin generated added stable field to CompositionScopedCoroutineScopeCanceller. Also new kotlin added getEntries method to Recomposer$State
d64d5fb
to
3e61170
Compare
This PR: - updates kotlin to 1.9.21 - removes watchosX86() target - it's not available since kotlin 1.9.20 --------- Co-authored-by: Oleksandr Karpovich <oleksandr.karpovich@jetbrains.com>
This a comanion PR to JetBrains/compose-multiplatform-core#914 Resources lib doesn't contain k/wasm target yet. It will be added in a separate PR --------- Co-authored-by: Oleksandr Karpovich <oleksandr.karpovich@jetbrains.com>
This PR: - updates kotlin to 1.9.21 - removes watchosX86() target - it's not available since kotlin 1.9.20 --------- Co-authored-by: Oleksandr Karpovich <oleksandr.karpovich@jetbrains.com>
This PR: