Commit 1197111f authored by dsq's avatar dsq

无需跑完

parent 0fefb338
......@@ -650,7 +650,7 @@ code + .copy-button {
<script type="text/javascript">
function configurationCacheProblems() { return (
// begin-report-data
{"diagnostics":[{"locations":[{"pluginId":"org.jetbrains.kotlin.multiplatform"}],"problem":[{"text":"Default Kotlin Hierarchy Template Not Applied Correctly"}],"severity":"WARNING","problemDetails":[{"text":"The Default Kotlin Hierarchy Template was not applied to 'project ':shared'':\nExplicit .dependsOn() edges were configured for the following source sets:\n[ohosArm64Main, ohosX64Main]\n\nConsider removing dependsOn-calls or disabling the default template by adding\n 'kotlin.mpp.applyDefaultHierarchyTemplate=false'\nto your gradle.properties"}],"contextualLabel":"Default Kotlin Hierarchy Template Not Applied Correctly","documentationLink":"https://kotl.in/hierarchy-template","problemId":[{"name":"KGP:MISCONFIGURATION","displayName":"Kotlin Gradle Plugin Misconfiguration"},{"name":"KOTLIN","displayName":"Kotlin"},{"name":"KotlinDefaultHierarchyFallbackDependsOnUsageDetected","displayName":"Default Kotlin Hierarchy Template Not Applied Correctly"}],"solutions":[[{"text":"Please remove the dependsOn-calls or disable the default template."}]]},{"locations":[{},{"pluginId":"com.android.internal.library"}],"problem":[{"text":"The StartParameter.isConfigurationCacheRequested property has been deprecated."}],"severity":"WARNING","problemDetails":[{"text":"This is scheduled to be removed in Gradle 10.0."}],"contextualLabel":"The StartParameter.isConfigurationCacheRequested property has been deprecated.","documentationLink":"https://docs.gradle.org/8.14.3/userguide/upgrading_version_8.html#deprecated_startparameter_is_configuration_cache_requested","problemId":[{"name":"deprecation","displayName":"Deprecation"},{"name":"the-startparameter-isconfigurationcacherequested-property-has-been-deprecated","displayName":"The StartParameter.isConfigurationCacheRequested property has been deprecated."}],"solutions":[[{"text":"Please use 'configurationCache.requested' property on 'BuildFeatures' service instead."}]]}],"problemsReport":{"totalProblemCount":2,"buildName":"NoComposeDemo","requestedTasks":":shared:publishDebugBinariesToHarmonyApp","documentationLink":"https://docs.gradle.org/8.14.3/userguide/reporting_problems.html","documentationLinkCaption":"Problem report","summaries":[]}}
{"diagnostics":[{"locations":[{"pluginId":"org.jetbrains.kotlin.multiplatform"}],"problem":[{"text":"Default Kotlin Hierarchy Template Not Applied Correctly"}],"severity":"WARNING","problemDetails":[{"text":"The Default Kotlin Hierarchy Template was not applied to 'project ':shared'':\nExplicit .dependsOn() edges were configured for the following source sets:\n[ohosArm64Main]\n\nConsider removing dependsOn-calls or disabling the default template by adding\n 'kotlin.mpp.applyDefaultHierarchyTemplate=false'\nto your gradle.properties"}],"contextualLabel":"Default Kotlin Hierarchy Template Not Applied Correctly","documentationLink":"https://kotl.in/hierarchy-template","problemId":[{"name":"KGP:MISCONFIGURATION","displayName":"Kotlin Gradle Plugin Misconfiguration"},{"name":"KOTLIN","displayName":"Kotlin"},{"name":"KotlinDefaultHierarchyFallbackDependsOnUsageDetected","displayName":"Default Kotlin Hierarchy Template Not Applied Correctly"}],"solutions":[[{"text":"Please remove the dependsOn-calls or disable the default template."}]]},{"locations":[{},{"pluginId":"com.android.internal.library"}],"problem":[{"text":"The StartParameter.isConfigurationCacheRequested property has been deprecated."}],"severity":"WARNING","problemDetails":[{"text":"This is scheduled to be removed in Gradle 10.0."}],"contextualLabel":"The StartParameter.isConfigurationCacheRequested property has been deprecated.","documentationLink":"https://docs.gradle.org/8.14.3/userguide/upgrading_version_8.html#deprecated_startparameter_is_configuration_cache_requested","problemId":[{"name":"deprecation","displayName":"Deprecation"},{"name":"the-startparameter-isconfigurationcacherequested-property-has-been-deprecated","displayName":"The StartParameter.isConfigurationCacheRequested property has been deprecated."}],"solutions":[[{"text":"Please use 'configurationCache.requested' property on 'BuildFeatures' service instead."}]]}],"problemsReport":{"totalProblemCount":2,"buildName":"NoComposeDemo","requestedTasks":":shared:publishDebugBinariesToHarmonyApp","documentationLink":"https://docs.gradle.org/8.14.3/userguide/reporting_problems.html","documentationLinkCaption":"Problem report","summaries":[]}}
// end-report-data
);}
</script>
......
......@@ -36,19 +36,7 @@ kotlin {
}
ohosX64 {
binaries {
sharedLib {
baseName = "kn"
// 链接静态库目录和库名,使用 --whole-archive 强制包含静态库所有符号
freeCompilerArgs += listOf("-Xbinary=sanitizer=address")
}
staticLib {
baseName = "kn"
}
}
}
sourceSets {
commonMain.dependencies {
......@@ -64,11 +52,7 @@ kotlin {
dependencies {
}
}
val ohosX64Main by getting{
dependsOn(commonMain)
dependencies {
}
}
}
}
......@@ -171,32 +155,6 @@ arrayOf("debug", "release").forEach { type ->
}
// 发布 ohosX64 产物到 harmonyapp,供模拟器(x86_64)使用
arrayOf("debug", "release").forEach { type ->
val capitalizedType = type.replaceFirstChar { it.uppercase() }
tasks.register<Copy>("publish${capitalizedType}BinariesToHarmonyAppX64") {
group = "harmony"
description = "Publish ohosX64 libkn.so to harmonyapp/entry/libs/x86_64 for emulator"
dependsOn("link${capitalizedType}SharedOhosX64")
into(rootProject.file("harmonyapp"))
val binaryPath = "build/bin/ohosX64/${type}Shared"
from("$binaryPath/libkn_api.h") {
into("entry/src/main/cpp/include/")
}
from("$binaryPath/libkn.so") {
into("entry/libs/x86_64/")
}
from("native-libs/ohosX64/libsample.a") {
into("entry/src/main/cpp/libs/")
}
doFirst {
if (!file(binaryPath).exists()) {
throw GradleException("未找到产物目录: $binaryPath")
}
}
}
}
......
package com.dong.nocomposedemo
class OhosPlatform: Platform {
override val name: String = "1"
}
actual fun getPlatform(): Platform {
return OhosPlatform()
}
\ No newline at end of file
package com.dong.nocomposedemo
import platform.PerformanceAnalysisKit.HiLog.OH_LOG_PrintMsg
import kotlin.experimental.ExperimentalNativeApi
@OptIn(kotlinx.cinterop.ExperimentalForeignApi::class, kotlin.experimental.ExperimentalNativeApi::class)
@CName("hiLogPrintMsg")
fun hiLogPrintMsg(type: UInt, level: UInt, domain: UInt, tag: String, message: String): Int {
return try {
OH_LOG_PrintMsg(type, level, domain, tag, message)
} catch (_: Throwable) {
-1
}
}
@OptIn(ExperimentalNativeApi::class)
@CName("pirntSingleHiLog")
actual fun pirntSingleHiLog(){
OH_LOG_PrintMsg(0u, 3u, 4660u, "TestTag", "单次日志打印");
}
@OptIn(ExperimentalNativeApi::class)
@CName("pirntAllLevelHiLog")
actual fun pirntAllLevelHiLog(){
// 输出 DEBUG 级别
// LOG_APP = 0 (应用日志类型)
// LOG_DEBUG = 3 (调试级别)
// domain = 0x1234 (任意自定义值,范围0x0000-0xFFFF)
// tag = "TestTag" (自定义标签)
OH_LOG_PrintMsg(0u, 3u, 4660u, "TestTag", "This is a DEBUG log from PrintMsg");
// 输出 INFO 级别
// LOG_INFO = 4 (信息级别)
OH_LOG_PrintMsg(0u, 4u, 4660u, "TestTag", "This is an INFO log from PrintMsg");
// 输出 WARN 级别
// LOG_WARN = 5 (警告级别)
OH_LOG_PrintMsg(0u, 5u, 4660u, "TestTag", "This is a WARN log from PrintMsg");
// 输出 ERROR 级别
// LOG_ERROR = 6 (错误级别)
OH_LOG_PrintMsg(0u, 6u, 4660u, "TestTag", "This is an ERROR log from PrintMsg");
// 输出 FATAL 级别
// LOG_FATAL = 7 (致命级别)
OH_LOG_PrintMsg(0u, 7u, 4660u, "TestTag", "This is a FATAL log from PrintMsg");
}
@OptIn(ExperimentalNativeApi::class)
@CName("pirntRandomHiLog")
actual fun pirntRandomHiLog() {
val levels = listOf(3u, 4u, 5u, 6u, 7u) // DEBUG, INFO, WARN, ERROR, FATAL
val randomLevel = levels.random()
OH_LOG_PrintMsg(0u, randomLevel, 4660u, "TestTag", "随机日志:级别=$randomLevel")
}
@OptIn(ExperimentalNativeApi::class)
@CName("FaultOut")
actual fun FaultOut() {
val array = intArrayOf(1, 2, 3)
// 故意访问越界索引,触发崩溃
println(array[5])
// 备用崩溃方式:空指针异常
val nullStr: String? = null
println(nullStr!!.length)
}
\ No newline at end of file
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