Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
T
TestToolChainDemo
Project
Project
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Commits
Issue Boards
Open sidebar
dsq
TestToolChainDemo
Commits
8d0a7e49
Commit
8d0a7e49
authored
Oct 20, 2026
by
dsq
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
fix:修改runtime配置
parent
01d96d88
Changes
5
Hide whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
90 additions
and
21 deletions
+90
-21
build.gradle.kts
build.gradle.kts
+12
-0
build.gradle.kts
composeApp/build.gradle.kts
+56
-14
gradle.properties
gradle.properties
+3
-6
kotlinLine.gradle.kts
gradle/kotlinLine.gradle.kts
+16
-0
libs.versions.toml
gradle/libs.versions.toml
+3
-1
No files found.
build.gradle.kts
View file @
8d0a7e49
...
...
@@ -6,4 +6,16 @@ plugins {
alias
(
libs
.
plugins
.
composeMultiplatform
)
apply
false
alias
(
libs
.
plugins
.
composeCompiler
)
apply
false
alias
(
libs
.
plugins
.
kotlinMultiplatform
)
apply
false
}
// K/N link 会在 destinationDirectory 里短暂留下 lib*.so.tmp*;Gradle build cache 打包时
// 取不到 file mode 会失败(常见于 linkDebugSharedOhosX64)。这些任务不写 build cache。
subprojects
{
tasks
.
configureEach
{
if
(
name
.
startsWith
(
"link"
)
&&
name
.
contains
(
"Shared"
))
{
outputs
.
doNotCacheIf
(
"Kotlin/Native link leaves .so.tmp* that race Gradle cache packing"
)
{
true
}
}
}
}
\ No newline at end of file
composeApp/build.gradle.kts
View file @
8d0a7e49
import
java.io.File
import
java.net.URI
import
android.databinding.tool.ext.capitalizeUS
import
org.gradle.api.file.DuplicatesStrategy
...
...
@@ -12,6 +13,45 @@ plugins {
alias
(
libs
.
plugins
.
composeCompiler
)
}
apply
(
from
=
rootProject
.
file
(
"gradle/kotlinLine.gradle.kts"
))
val
kotlinVer
:
String
=
extra
[
"kotlinVer"
]
as
String
val
kotlinLine
:
String
=
extra
[
"kotlinLine"
]
as
String
/**
* 仅 2.4:cacheKind=none 已失效,需 disableNativeCache。
* 2.2 KGP 没有这些类,反射调用;2.2 仍走 gradle.properties 的 cacheKind=none。
*/
fun
Any
.
disableNativeCacheOnKotlin24
()
{
if
(
kotlinLine
!=
"2.4"
)
return
val
token
=
when
{
kotlinVer
.
startsWith
(
"2.4.20"
)
->
"2_4_20"
else
->
"2_4_0"
}
try
{
val
objClass
=
Class
.
forName
(
"org.jetbrains.kotlin.gradle.plugin.mpp.DisableCacheInKotlinVersion\$$token"
)
val
version
=
objClass
.
getField
(
"INSTANCE"
).
get
(
null
)
val
method
=
javaClass
.
methods
.
first
{
it
.
name
==
"disableNativeCache"
&&
it
.
parameterCount
>=
2
}
when
(
method
.
parameterCount
)
{
3
->
method
.
invoke
(
this
,
version
,
"cacheKind=none ignored on 2.4; disable native cache for self-contained libkn"
,
URI
(
"https://youtrack.jetbrains.com/issue/KT-75928"
),
)
else
->
method
.
invoke
(
this
,
version
,
"cacheKind=none ignored on 2.4; disable native cache for self-contained libkn"
,
)
}
}
catch
(
e
:
ReflectiveOperationException
)
{
logger
.
warn
(
"disableNativeCache skipped on $kotlinVer: ${e.message}"
)
}
}
kotlin
{
androidTarget
{
@OptIn
(
ExperimentalKotlinGradlePluginApi
::
class
)
...
...
@@ -44,6 +84,7 @@ kotlin {
linkerOpts
(
"-lz"
)
// 避免 release 优化在模拟器上触发 SIGILL(非法指令)
optimized
=
false
disableNativeCacheOnKotlin24
()
// 渲染模式
// 背景:当 libkn.so 为旧编译产物时,其 DT_NEEDED 可能缺少以下库(正确构建时
// NativeTasksConfiguration.kt 已通过 -l 选项将它们写入 DT_NEEDED)。
...
...
@@ -101,22 +142,14 @@ kotlin {
}
}
val
ohosArm64Main
by
getting
{
dependencies
{
api
(
libs
.
compose
.
multiplatform
.
export
)
//导出skiko api 用于demo中测试
// implementation("org.jetbrains.skiko:skiko-ohosarm64")
}
val
ohosMain
=
sourceSets
.
create
(
"ohosMain"
).
apply
{
dependsOn
(
commonMain
.
get
())
}
val
ohosX64Main
by
getting
{
dependencies
{
api
(
libs
.
compose
.
multiplatform
.
export
)
// implementation("org.jetbrains.skiko:skiko-ohosx64")
}
ohosMain
.
dependencies
{
api
(
libs
.
compose
.
multiplatform
.
export
)
}
sourceSets
.
getByName
(
"ohosArm64Main"
).
dependsOn
(
ohosMain
)
sourceSets
.
getByName
(
"ohosX64Main"
).
dependsOn
(
ohosMain
)
}
}
...
...
@@ -189,6 +222,15 @@ configurations.all {
}
}
tasks
.
withType
<
org
.
jetbrains
.
kotlin
.
gradle
.
tasks
.
KotlinNativeLink
>().
configureEach
{
doFirst
{
file
(
"build/bin/ohosArm64/debugShared"
).
mkdirs
()
file
(
"build/bin/ohosArm64/releaseShared"
).
mkdirs
()
file
(
"build/bin/ohosX64/debugShared"
).
mkdirs
()
file
(
"build/bin/ohosX64/releaseShared"
).
mkdirs
()
}
}
/** 仅清理 harmonyApp 下 entry 的中间目录,与 publish 无关时可单独执行:`:composeApp:cleanHarmonyAppEntryBuildsAndNativeLibs` */
tasks
.
register
(
"cleanHarmonyAppEntryBuildsAndNativeLibs"
)
{
group
=
"harmony"
...
...
gradle.properties
View file @
8d0a7e49
...
...
@@ -9,16 +9,14 @@ org.gradle.jvmargs=-Xmx8192m -XX:MaxMetaspaceSize=1024m -Dfile.encoding=UTF-8
#Android
android.nonTransitiveRClass
=
true
android.useAndroidX
=
true
# AGP 9 默认的新 DSL / 内置 Kotlin 不能和 KMP 的 com.android.application 放在同一个模块。
# 这两个开关保留旧行为,到 AGP 10 之前可用。
android.builtInKotlin
=
false
android.newDsl
=
false
kotlin.native.cacheKind
=
none
kotlin.native.cacheKind.ohosArm64
=
none
kotlin.native.cacheKind.ohosX64
=
none
org.gradle.configuration-cache
=
false
org.gradle.internal.http.connectionTimeout
=
100000
org.gradle.internal.http.socketTimeout
=
100000
# kotlin.mpp.applyDefaultHierarchyTemplate=false
#?????????
...
...
@@ -34,7 +32,6 @@ rendererBackend=skia
#Enable all of the following switches to improve debug incremental compilation performance.
org.gradle.caching
=
false
org.gradle.configuration-cache
=
true
org.gradle.parallel
=
true
kotlin.incremental.native
=
true
kotlin.incremental.useClasspathSnapshot
=
true
...
...
gradle/kotlinLine.gradle.kts
0 → 100644
View file @
8d0a7e49
import
org.gradle.api.artifacts.VersionCatalogsExtension
/** 读 gradle/libs.versions.toml 的 kotlin,按开头分流:2.2* → 2.2,2.4* → 2.4。 */
val
kotlinVer
=
extensions
.
getByType
<
VersionCatalogsExtension
>()
.
named
(
"libs"
)
.
findVersion
(
"kotlin"
)
.
orElseThrow
{
IllegalStateException
(
"libs.versions.toml missing [versions] kotlin"
)
}
.
requiredVersion
val
kotlinLine
=
when
{
kotlinVer
.
startsWith
(
"2.2"
)
->
"2.2"
kotlinVer
.
startsWith
(
"2.4"
)
->
"2.4"
else
->
error
(
"kotlin=$kotlinVer 只支持 2.2* / 2.4*(改 gradle/libs.versions.toml 的 kotlin)"
)
}
extra
[
"kotlinVer"
]
=
kotlinVer
extra
[
"kotlinLine"
]
=
kotlinLine
logger
.
lifecycle
(
"kotlinLine=$kotlinLine (kotlin=$kotlinVer)"
)
gradle/libs.versions.toml
View file @
8d0a7e49
[versions]
# 与 kmp-cmp-test-demo-2.4-single 的 2.4 线对齐:
# kotlin / compose / coroutines / atomicFu,以及 gradle.properties 的 ohosSkikoVersion、Gradle 9.4.1。
# Build & Android
agp
=
"8.
11.1
"
agp
=
"8.
6.0
"
android-compileSdk
=
"36"
android-minSdk
=
"24"
android-targetSdk
=
"36"
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment