Commit bfebf9c4 authored by dsq's avatar dsq

更新kotlin版本

parent 220501f3
...@@ -72,6 +72,12 @@ kotlin { ...@@ -72,6 +72,12 @@ kotlin {
// 动态库 (isStatic = false) - 运行时加载的库 // 动态库 (isStatic = false) - 运行时加载的库
isStatic = true // 设置framework为静态库 isStatic = true // 设置framework为静态库
} }
iosTarget.compilations.getByName("main") {
compilerOptions.configure {
freeCompilerArgs.add("-Xbinary=sanitizer=address")
freeCompilerArgs.add("-Xbinary=splitBCfile=1")
}
}
} }
// 配置OHOS(华为鸿蒙)arm64目标 // 配置OHOS(华为鸿蒙)arm64目标
...@@ -81,19 +87,22 @@ kotlin { ...@@ -81,19 +87,22 @@ kotlin {
export(libs.compose.multiplatform.export) // 导出compose多平台库的接口 export(libs.compose.multiplatform.export) // 导出compose多平台库的接口
} }
val main by compilations.getting // 获取主编译内容 val main by compilations.getting // 获取主编译内容
main.compilerOptions.configure {
freeCompilerArgs.add("-Xbinary=sanitizer=address")
freeCompilerArgs.add("-Xbinary=splitBCfile=1")
}
val resource by main.cinterops.creating { val resource by main.cinterops.creating {
//配置C interop(cinterop)资源 //配置C interop(cinterop)资源
defFile(file("src/ohosArm64Main/cinterop/resource.def")) // cinterop定义文件 defFile(file("src/ohosArm64Main/cinterop/resource.def")) // cinterop定义文件
includeDirs(file("src/ohosArm64Main/cinterop/include")) // cinterop包含目录 includeDirs(file("src/ohosArm64Main/cinterop/include")) // cinterop包含目录
compilerOpts("-fno-modules") // 禁用模块以避免平台库依赖
} }
} }
// 配置各平台的依赖关系 // 配置各平台的依赖关系
sourceSets { sourceSets {
androidMain.dependencies { androidMain.dependencies {
implementation(libs.androidx.activity.compose) implementation(libs.androidx.activity.compose)
implementation(libs.androidx.collection)
implementation(libs.androidx.lifecycle.viewmodelCompose) implementation(libs.androidx.lifecycle.viewmodelCompose)
implementation(libs.androidx.lifecycle.runtimeCompose) implementation(libs.androidx.lifecycle.runtimeCompose)
} }
...@@ -107,21 +116,9 @@ kotlin { ...@@ -107,21 +116,9 @@ kotlin {
implementation(libs.kotlinx.coroutines.core) // 官方协程核心库 implementation(libs.kotlinx.coroutines.core) // 官方协程核心库
implementation(libs.atomicFu) // Kotlin AtomicFu原子库 implementation(libs.atomicFu) // Kotlin AtomicFu原子库
} }
commonTest.dependencies {
implementation(libs.kotlin.test) // 添加Kotlin通用测试依赖
}
val ohosArm64Main by getting { val ohosArm64Main by getting {
dependencies { dependencies {
api(libs.compose.multiplatform.export) // 导出compose多平台接口给依赖消费者 api(libs.compose.multiplatform.export) // 导出compose多平台接口给依赖消费者
// 添加OHOS平台特定依赖
implementation("org.jetbrains.kotlin:kotlin-stdlib")
}
}
// iOS平台配置
iosMain {
dependencies {
implementation(libs.kotlinx.coroutines.core) // iOS也需要协程支持
} }
} }
} }
...@@ -138,11 +135,11 @@ Android 构建工具 → 打包成 APK ...@@ -138,11 +135,11 @@ Android 构建工具 → 打包成 APK
控制 APK 生成、打包、签名等 控制 APK 生成、打包、签名等
*/ */
android { android {
namespace = "com.dong.demo013" // 设置包名 namespace = "com.dong.n4.n4test010" // 设置包名
compileSdk = libs.versions.android.compileSdk.get().toInt() // 指定编译SDK版本 compileSdk = libs.versions.android.compileSdk.get().toInt() // 指定编译SDK版本
defaultConfig { defaultConfig {
applicationId = "com.dong.demo013" // 应用ID applicationId = "com.dong.n4.n4test010" // 应用ID
minSdk = libs.versions.android.minSdk.get().toInt() // 最低SDK版本 minSdk = libs.versions.android.minSdk.get().toInt() // 最低SDK版本
targetSdk = libs.versions.android.targetSdk.get().toInt()// 目标SDK版本 targetSdk = libs.versions.android.targetSdk.get().toInt()// 目标SDK版本
versionCode = 1 // 应用版本号 versionCode = 1 // 应用版本号
...@@ -168,47 +165,28 @@ dependencies { ...@@ -168,47 +165,28 @@ dependencies {
debugImplementation(libs.compose.ui.tooling) // debug模式下依赖compose调试工具 debugImplementation(libs.compose.ui.tooling) // debug模式下依赖compose调试工具
} }
compose{
ohos{
skia("0.9.22.2-ez-001")
// ohrender(" 0.9.22.2-ohrende")
}
}
// 为 ohosArm64 目标配置依赖处理 // 为 ohosArm64 目标配置依赖处理
val versionCatalog = extensions.getByType<VersionCatalogsExtension>().named("libs") val versionCatalog = extensions.getByType<VersionCatalogsExtension>().named("libs")
val cmpVersion = versionCatalog.findVersion("composeMultiplatform") val cmpVersion = versionCatalog.findVersion("composeMultiplatform")
.orElseThrow { IllegalStateException("Missing version composeMultiplatform in version catalog") } .orElseThrow { IllegalStateException("Missing version composeMultiplatform in version catalog") }
.requiredVersion .requiredVersion
val skikoOverrideByCmpVersion = mapOf(
"1.9.2-ez-001" to "0.9.22.2-ez-001",
// 仅在需要强制的 CMP 版本这里新增
)
val skikoOhosOverride = skikoOverrideByCmpVersion[cmpVersion]
configurations.all { configurations.all {
val configName = name
if (configName.contains("ohos", ignoreCase = true)) {
incoming.afterResolve {
val resolvedSkiko = resolutionResult.allComponents
.mapNotNull { it.moduleVersion }
.firstOrNull { it.group == "org.jetbrains.skiko" && it.name == "skiko" }
logger.lifecycle(
"Resolved skiko for $configName: " +
(resolvedSkiko?.let { "${it.group}:${it.name}:${it.version}" } ?: "not found")
)
}
// exclude(group = "org.jetbrains.androidx.lifecycle")
// exclude(group = "org.jetbrains.androidx.savedstate")
}
resolutionStrategy { resolutionStrategy {
eachDependency { // TODO: 强制刷新 compose ui ohosarm64 依赖
// 如果是 skiko 依赖,检查配置名称是否包含 ohos force("org.jetbrains.compose.export:export-ohosarm64:${cmpVersion}")
if (requested.group == "org.jetbrains.skiko" && requested.name == "skiko") { force("org.jetbrains.compose.ui:ui-ohosarm64:${cmpVersion}")
if (configName.contains("ohos", ignoreCase = true)) { force("org.jetbrains.compose.ui:ui-arkui-ohosarm64:${cmpVersion}")
skikoOhosOverride?.let { useVersion(it) } force("org.jetbrains.compose.foundation:foundation-ohosarm64:${cmpVersion}")
}
}
// 强制指定 androidx.collection 版本,避免冲突
if (requested.group == "androidx.collection" && requested.name == "collection") {
useVersion(libs.versions.androidx.collection.get())
}
}
} }
exclude(group = "androidx.collection", module = "collection-jvm")
} }
// Harmony App 输出目录(支持命令行 --harmonyAppPath) // Harmony App 输出目录(支持命令行 --harmonyAppPath)
......
...@@ -11,11 +11,10 @@ androidx-espresso = "3.7.0" ...@@ -11,11 +11,10 @@ androidx-espresso = "3.7.0"
androidx-lifecycle = "2.9.6" androidx-lifecycle = "2.9.6"
androidx-material = "1.12.0" androidx-material = "1.12.0"
androidx-testExt = "1.3.0" androidx-testExt = "1.3.0"
androidx-collection = "1.4.5"
compose = "1.9.4" compose = "1.9.4"
composeMultiplatform = "1.9.2-ez-001" composeMultiplatform = "1.9.2-OH.0.1.0-01"
junit = "4.13.2" junit = "4.13.2"
kotlin = "2.2.21-ez-001" kotlin = "2.2.21-OH.0.1.0-01"
kotlinx-coroutines = "1.8.0-KBA-001" kotlinx-coroutines = "1.8.0-KBA-001"
atomicFu = "0.23.2-KBA-001" atomicFu = "0.23.2-KBA-001"
...@@ -30,7 +29,6 @@ androidx-appcompat = { module = "androidx.appcompat:appcompat", version.ref = "a ...@@ -30,7 +29,6 @@ androidx-appcompat = { module = "androidx.appcompat:appcompat", version.ref = "a
androidx-activity-compose = { module = "androidx.activity:activity-compose", version.ref = "androidx-activity" } androidx-activity-compose = { module = "androidx.activity:activity-compose", version.ref = "androidx-activity" }
androidx-lifecycle-viewmodelCompose = { module = "org.jetbrains.androidx.lifecycle:lifecycle-viewmodel-compose", version.ref = "androidx-lifecycle" } androidx-lifecycle-viewmodelCompose = { module = "org.jetbrains.androidx.lifecycle:lifecycle-viewmodel-compose", version.ref = "androidx-lifecycle" }
androidx-lifecycle-runtimeCompose = { module = "org.jetbrains.androidx.lifecycle:lifecycle-runtime-compose", version.ref = "androidx-lifecycle" } androidx-lifecycle-runtimeCompose = { module = "org.jetbrains.androidx.lifecycle:lifecycle-runtime-compose", version.ref = "androidx-lifecycle" }
androidx-collection = { module = "androidx.collection:collection", version.ref = "androidx-collection" }
compose-multiplatform-export = { module = "org.jetbrains.compose.export:export", version.ref = "composeMultiplatform" } compose-multiplatform-export = { module = "org.jetbrains.compose.export:export", version.ref = "composeMultiplatform" }
androidx-constraintlayout = { group = "androidx.constraintlayout", name = "constraintlayout", version.ref = "androidx-constraintlayout" } androidx-constraintlayout = { group = "androidx.constraintlayout", name = "constraintlayout", version.ref = "androidx-constraintlayout" }
androidx-material = { group = "com.google.android.material", name = "material", version.ref = "androidx-material" } androidx-material = { group = "com.google.android.material", name = "material", version.ref = "androidx-material" }
......
...@@ -126,6 +126,7 @@ typedef struct { ...@@ -126,6 +126,7 @@ typedef struct {
extern void* MainArkUIViewController(void* env); extern void* MainArkUIViewController(void* env);
extern libkn_KInt hiLogPrintMsg(libkn_KUInt type, libkn_KUInt level, libkn_KUInt domain, const char* tag, const char* message); extern libkn_KInt hiLogPrintMsg(libkn_KUInt type, libkn_KUInt level, libkn_KUInt domain, const char* tag, const char* message);
extern libkn_KInt kn_get_render_backend_id();
extern void androidx_compose_ui_arkui_ArkUIViewController_aboutToAppear(void* controllerRef); extern void androidx_compose_ui_arkui_ArkUIViewController_aboutToAppear(void* controllerRef);
extern void androidx_compose_ui_arkui_ArkUIViewController_aboutToDisappear(void* controllerRef); extern void androidx_compose_ui_arkui_ArkUIViewController_aboutToDisappear(void* controllerRef);
extern void androidx_compose_ui_arkui_ArkUIViewController_cancelSyncRefresh(void* controllerRef, libkn_KInt refreshId); extern void androidx_compose_ui_arkui_ArkUIViewController_cancelSyncRefresh(void* controllerRef, libkn_KInt refreshId);
...@@ -154,9 +155,16 @@ extern void androidx_compose_ui_arkui_ArkUIViewController_setContext(void* contr ...@@ -154,9 +155,16 @@ extern void androidx_compose_ui_arkui_ArkUIViewController_setContext(void* contr
extern void androidx_compose_ui_arkui_ArkUIViewController_setEnv(void* controllerRef, void* env); extern void androidx_compose_ui_arkui_ArkUIViewController_setEnv(void* controllerRef, void* env);
extern void androidx_compose_ui_arkui_ArkUIViewController_setId(void* controllerRef, const char* id); extern void androidx_compose_ui_arkui_ArkUIViewController_setId(void* controllerRef, const char* id);
extern void androidx_compose_ui_arkui_ArkUIViewController_setMessenger(void* controllerRef, void* messenger); extern void androidx_compose_ui_arkui_ArkUIViewController_setMessenger(void* controllerRef, void* messenger);
extern void androidx_compose_ui_arkui_ArkUIViewController_setRenderBackendId(void* controllerRef, libkn_KInt backendId);
extern void androidx_compose_ui_arkui_ArkUIViewController_setRootView(void* controllerRef, void* backRootView, void* foreRootView, void* touchableRootView); extern void androidx_compose_ui_arkui_ArkUIViewController_setRootView(void* controllerRef, void* backRootView, void* foreRootView, void* touchableRootView);
extern void androidx_compose_ui_arkui_ArkUIViewController_setUIContext(void* controllerRef, void* uiContext); extern void androidx_compose_ui_arkui_ArkUIViewController_setUIContext(void* controllerRef, void* uiContext);
extern void androidx_compose_ui_arkui_ArkUIViewController_setXComponentRender(void* controllerRef, void* render); extern void androidx_compose_ui_arkui_ArkUIViewController_setXComponentRender(void* controllerRef, void* render);
extern void buildInstance(void* env, void* func);
extern void* createRootRenderNode();
extern void renderNodeDraw(void* env, void* jsCanvas, void* jsNode);
extern void renderNodeNotifyRedraw(void* env, void* jsNode);
extern void setNodeConstructor(void* env, void* func);
extern void setPixelRatio(libkn_KDouble ratio);
extern void androidx_compose_ui_arkui_init(void* env, void* exports); extern void androidx_compose_ui_arkui_init(void* env, void* exports);
typedef struct { typedef struct {
...@@ -379,6 +387,18 @@ typedef struct { ...@@ -379,6 +387,18 @@ typedef struct {
struct { struct {
struct { struct {
struct { struct {
libkn_KInt (*kn_get_render_backend_id_)();
} internal;
} ohos;
} compose;
} jetbrains;
} org;
struct {
struct {
struct {
struct {
struct {
void* (*get_NodeDrawCallback)();
void (*_Export_ArkUIViewController_aboutToAppear)(void* controllerRef); void (*_Export_ArkUIViewController_aboutToAppear)(void* controllerRef);
void (*_Export_ArkUIViewController_aboutToDisappear)(void* controllerRef); void (*_Export_ArkUIViewController_aboutToDisappear)(void* controllerRef);
void (*_Export_ArkUIViewController_cancelSyncRefresh)(void* controllerRef, libkn_KInt refreshId); void (*_Export_ArkUIViewController_cancelSyncRefresh)(void* controllerRef, libkn_KInt refreshId);
...@@ -407,9 +427,17 @@ typedef struct { ...@@ -407,9 +427,17 @@ typedef struct {
void (*_Export_ArkUIViewController_setEnv)(void* controllerRef, void* env); void (*_Export_ArkUIViewController_setEnv)(void* controllerRef, void* env);
void (*_Export_ArkUIViewController_setId)(void* controllerRef, const char* id); void (*_Export_ArkUIViewController_setId)(void* controllerRef, const char* id);
void (*_Export_ArkUIViewController_setMessenger)(void* controllerRef, void* messenger); void (*_Export_ArkUIViewController_setMessenger)(void* controllerRef, void* messenger);
void (*_Export_ArkUIViewController_setRenderBackendId)(void* controllerRef, libkn_KInt backendId);
void (*_Export_ArkUIViewController_setRootView)(void* controllerRef, void* backRootView, void* foreRootView, void* touchableRootView); void (*_Export_ArkUIViewController_setRootView)(void* controllerRef, void* backRootView, void* foreRootView, void* touchableRootView);
void (*_Export_ArkUIViewController_setUIContext)(void* controllerRef, void* uiContext); void (*_Export_ArkUIViewController_setUIContext)(void* controllerRef, void* uiContext);
void (*_Export_ArkUIViewController_setXComponentRender)(void* controllerRef, void* render); void (*_Export_ArkUIViewController_setXComponentRender)(void* controllerRef, void* render);
void (*buildInstance_)(void* env, void* func);
void* (*createRootRenderNode_)();
libkn_KLong (*getCurrentTimeNanos)();
void (*renderNodeDraw_)(void* env, void* jsCanvas, void* jsNode);
void (*renderNodeNotifyRedraw_)(void* env, void* jsNode);
void (*setNodeConstructor_)(void* env, void* func);
void (*setPixelRatio_)(libkn_KDouble ratio);
void (*_Export_ArkUIViewInitializer_init)(void* env, void* exports); void (*_Export_ArkUIViewInitializer_init)(void* env, void* exports);
} arkui; } arkui;
} ui; } ui;
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment