Commit 811b28a4 authored by jiangyh's avatar jiangyh

win支持ohosArm64

parent aab96f8a
...@@ -185,9 +185,10 @@ val buildSampleStaticLib by tasks.registering { ...@@ -185,9 +185,10 @@ val buildSampleStaticLib by tasks.registering {
objFileFile.delete() objFileFile.delete()
} }
println("Compiling ${srcFile.name}...") println("Compiling ${srcFile.name}...")
// Windows 上若用的是 host 的 clang(x64),必须显式指定 -target 为 aarch64,否则 .S 会被当 x86 汇编
val targetArg = if (clangExecutable.name.startsWith("aarch64-")) listOf<String>() else listOf("-target", "aarch64-unknown-linux-gnu")
execOps.exec { execOps.exec {
// 使用 OHOS SDK clang 编译,它会自动处理 target 和 sysroot commandLine(clangExecutable.absolutePath, "-c", "-fPIC", "-O2", *targetArg.toTypedArray(), "-I", includeDir, srcFile.absolutePath, "-o", objFile)
commandLine(clangExecutable.absolutePath, "-c", "-fPIC", "-O2", "-I", includeDir, srcFile.absolutePath, "-o", objFile)
} }
objectFiles.add(objFile) objectFiles.add(objFile)
} }
...@@ -220,6 +221,9 @@ arrayOf("debug", "release").forEach { type -> ...@@ -220,6 +221,9 @@ arrayOf("debug", "release").forEach { type ->
from("native-libs/ohosArm64/libsample.a") { from("native-libs/ohosArm64/libsample.a") {
into("entry/src/main/cpp/libs/") into("entry/src/main/cpp/libs/")
} }
from("native-libs/ohosArm64/libsample.a") {
into("entry/src/main/cpp/libs/arm64-v8a/")
}
doFirst { doFirst {
if (!binaryDir.exists()) { if (!binaryDir.exists()) {
throw GradleException("未找到产物目录: ${binaryDir.absolutePath}") throw GradleException("未找到产物目录: ${binaryDir.absolutePath}")
......
...@@ -10,6 +10,7 @@ ...@@ -10,6 +10,7 @@
"path": "./src/main/cpp/CMakeLists.txt", "path": "./src/main/cpp/CMakeLists.txt",
"arguments": "-DOHOS_ENABLE_ASAN=ON", "arguments": "-DOHOS_ENABLE_ASAN=ON",
"cppFlags": "", "cppFlags": "",
"abiFilters": [ "arm64-v8a" ]
} }
}, },
"buildOptionSet": [ "buildOptionSet": [
......
rootProject.name = "kmptcp_kotlin_sample" rootProject.name = "kotlin_sample"
enableFeaturePreview("TYPESAFE_PROJECT_ACCESSORS") enableFeaturePreview("TYPESAFE_PROJECT_ACCESSORS")
pluginManagement { pluginManagement {
repositories { repositories {
// maven { // maven {
// url = uri("/Users/jiangyuhuan/AndroidStudioProjects/kmptpc_kotlin/build/repo") // url = uri("/Users/jiangyuhuan/AndroidStudioProjects/kmptpc_kotlin/build/repo")
// } // }
// mavenLocal() // 备用:脚本中也执行了
maven {
url = java.io.File("D:/repo").toURI()
}
mavenLocal() // 备用:脚本中也执行了
google() google()
mavenCentral()
maven("https://maven.eazytec-cloud.com/nexus/repository/maven-public/") maven("https://maven.eazytec-cloud.com/nexus/repository/maven-public/")
// 引入 Gradle 插件门户(主要用于查找 Gradle 插件) // 引入 Gradle 插件门户(主要用于查找 Gradle 插件)
gradlePluginPortal() gradlePluginPortal()
...@@ -16,13 +19,16 @@ pluginManagement { ...@@ -16,13 +19,16 @@ pluginManagement {
} }
dependencyResolutionManagement { dependencyResolutionManagement {
repositories { repositories {
// maven { // maven {
// url = uri("/Users/jiangyuhuan/AndroidStudioProjects/kmptpc_kotlin/build/repo") // url = uri("/Users/jiangyuhuan/AndroidStudioProjects/kmptpc_kotlin/build/repo")
// } // }
// mavenLocal()
maven {
url = java.io.File("D:/repo").toURI()
}
mavenLocal()
google() google()
mavenCentral()
maven("https://maven.eazytec-cloud.com/nexus/repository/maven-public/") maven("https://maven.eazytec-cloud.com/nexus/repository/maven-public/")
} }
} }
...@@ -30,4 +36,4 @@ dependencyResolutionManagement { ...@@ -30,4 +36,4 @@ dependencyResolutionManagement {
include(":composeApp") include(":composeApp")
include(":lib-arith") include(":lib-arith")
include(":lib-analytics") include(":lib-analytics")
include(":lib-base") include(":lib-base")
\ 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