mirror of
https://github.com/mamoe/mirai.git
synced 2025-01-08 17:20:11 +08:00
397d824d33
* enhance(ECDH): reconstruct ECDH common: 移动特定于 QQ 平台的实现到 OicqECDH,重新设计 ECDH,使 ECDH 类只针对算法本身,而不过多包括 QQ 协议的使用细节 jvm: 尝试优先使用平台加密实现,可能改善性能 jvm & android: 使用 curveName `secp256r1` 代替 `prime256v1`,前者在 Java 中更常用,可以被更多的 JCE 实现所识别(虽然都是指同一条曲线) android: 使用系统自带的实现以减少依赖,并尝试兼容 Android P+ 版本 native: 中间储存时保留OpenSSL内部结构而不反复 new & free,提高性能 (为了实现智能指针,需要用到 `@ExperimentalStdlibApi` 的 `createCleaner`,但这种风险应该可以接受) native: 直接使用 point/bignum 到 bytes 的转换,避免了 hex string 作为中间层,提高效率 * test(ECDH): fix AndroidTest * style(Ecdh): obey official Kotlin coding conventions > When using an acronym as part of a declaration name, capitalize it if it consists of two letters (IOStream); capitalize only the first letter if it is longer (XmlFormatter, HttpInputStream). > [View origin](https://kotlinlang.org/docs/coding-conventions.html) Co-authored-by: ArcticLampyrid <arcticlampyrid@outlook.com>
214 lines
7.0 KiB
Plaintext
214 lines
7.0 KiB
Plaintext
/*
|
|
* Copyright 2019-2022 Mamoe Technologies and contributors.
|
|
*
|
|
* 此源代码的使用受 GNU AFFERO GENERAL PUBLIC LICENSE version 3 许可证的约束, 可以在以下链接找到该许可证.
|
|
* Use of this source code is governed by the GNU AGPLv3 license that can be found through the following link.
|
|
*
|
|
* https://github.com/mamoe/mirai/blob/dev/LICENSE
|
|
*/
|
|
|
|
@file:Suppress("UNUSED_VARIABLE")
|
|
|
|
import BinaryCompatibilityConfigurator.configureBinaryValidators
|
|
import org.jetbrains.kotlin.gradle.plugin.mpp.AbstractNativeLibrary
|
|
import org.jetbrains.kotlin.gradle.plugin.mpp.KotlinNativeTarget
|
|
|
|
plugins {
|
|
kotlin("multiplatform")
|
|
// id("kotlinx-atomicfu")
|
|
kotlin("plugin.serialization")
|
|
id("me.him188.kotlin-jvm-blocking-bridge")
|
|
id("me.him188.kotlin-dynamic-delegation")
|
|
// id("me.him188.maven-central-publish")
|
|
`maven-publish`
|
|
}
|
|
|
|
description = "Mirai Protocol implementation for QQ Android"
|
|
|
|
kotlin {
|
|
explicitApi()
|
|
|
|
configureJvmTargetsHierarchical()
|
|
configureNativeTargetsHierarchical(project)
|
|
|
|
sourceSets.apply {
|
|
|
|
val commonMain by getting {
|
|
dependencies {
|
|
api(project(":mirai-core-api"))
|
|
api(`kotlinx-serialization-core`)
|
|
api(`kotlinx-serialization-json`)
|
|
api(`kotlinx-coroutines-core`)
|
|
|
|
implementation(project(":mirai-core-utils"))
|
|
implementation(`kotlinx-serialization-protobuf`)
|
|
implementation(`kotlinx-atomicfu`)
|
|
implementation(`ktor-io`)
|
|
implementation(`ktor-client-core`)
|
|
}
|
|
}
|
|
|
|
commonTest {
|
|
dependencies {
|
|
implementation(kotlin("script-runtime"))
|
|
implementation(`kotlinx-coroutines-test`)
|
|
api(yamlkt)
|
|
}
|
|
}
|
|
|
|
findByName("jvmBaseMain")?.apply {
|
|
dependencies {
|
|
implementation(`log4j-api`)
|
|
implementation(`netty-all`)
|
|
implementation(`ktor-client-okhttp`)
|
|
api(`kotlinx-coroutines-jdk8`) // use -jvm modules for this magic target 'jvmBase'
|
|
}
|
|
}
|
|
|
|
findByName("jvmBaseTest")?.apply {
|
|
dependencies {
|
|
implementation(`kotlinx-coroutines-debug`)
|
|
}
|
|
}
|
|
|
|
findByName("androidMain")?.apply {
|
|
dependsOn(commonMain)
|
|
dependencies {
|
|
compileOnly(`android-runtime`)
|
|
}
|
|
}
|
|
findByName("androidTest")?.apply {
|
|
dependencies {
|
|
implementation(kotlin("test", Versions.kotlinCompiler))
|
|
implementation(kotlin("test-junit5", Versions.kotlinCompiler))
|
|
implementation(kotlin("test-annotations-common"))
|
|
implementation(kotlin("test-common"))
|
|
implementation(bouncycastle)
|
|
}
|
|
}
|
|
|
|
findByName("jvmMain")?.apply {
|
|
dependencies {
|
|
implementation(bouncycastle)
|
|
// api(kotlinx("coroutines-debug", Versions.coroutines))
|
|
}
|
|
}
|
|
|
|
findByName("jvmTest")?.apply {
|
|
dependencies {
|
|
api(`kotlinx-coroutines-debug`)
|
|
// implementation("net.mamoe:mirai-login-solver-selenium:1.0-dev-14")
|
|
}
|
|
}
|
|
|
|
findByName("nativeMain")?.apply {
|
|
dependencies {
|
|
}
|
|
}
|
|
|
|
NATIVE_TARGETS.forEach { targetName ->
|
|
val defFile = projectDir.resolve("src/nativeMain/cinterop/OpenSSL.def")
|
|
val target = targets.getByName(targetName) as KotlinNativeTarget
|
|
target.compilations.getByName("main").cinterops.create("OpenSSL")
|
|
.apply {
|
|
this.defFile = defFile
|
|
packageName("openssl")
|
|
}
|
|
|
|
configure(target.binaries.filterIsInstance<AbstractNativeLibrary>()) {
|
|
export(project(":mirai-core-api"))
|
|
export(project(":mirai-core-utils"))
|
|
}
|
|
}
|
|
|
|
UNIX_LIKE_TARGETS.forEach { target ->
|
|
(targets.getByName(target) as KotlinNativeTarget).compilations.getByName("main").cinterops.create("Socket")
|
|
.apply {
|
|
defFile = projectDir.resolve("src/unixMain/cinterop/Socket.def")
|
|
packageName("sockets")
|
|
}
|
|
}
|
|
|
|
WIN_TARGETS.forEach { target ->
|
|
(targets.getByName(target) as KotlinNativeTarget).compilations.getByName("main").cinterops.create("Socket")
|
|
.apply {
|
|
defFile = projectDir.resolve("src/mingwX64Main/cinterop/Socket.def")
|
|
packageName("sockets")
|
|
}
|
|
}
|
|
|
|
configure(WIN_TARGETS.map { getByName(it + "Main") }) {
|
|
dependencies {
|
|
implementation(`ktor-client-curl`)
|
|
}
|
|
}
|
|
|
|
configure(LINUX_TARGETS.map { getByName(it + "Main") }) {
|
|
dependencies {
|
|
implementation(`ktor-client-cio`)
|
|
}
|
|
}
|
|
|
|
findByName("darwinMain")?.apply {
|
|
dependencies {
|
|
implementation(`ktor-client-darwin`)
|
|
}
|
|
}
|
|
|
|
disableCrossCompile()
|
|
// val unixMain by getting {
|
|
// dependencies {
|
|
// implementation(`ktor-client-cio`)
|
|
// }
|
|
// }
|
|
}
|
|
}
|
|
|
|
afterEvaluate {
|
|
val main = projectDir.resolve("src/nativeTest/kotlin/local/TestMain.kt")
|
|
if (!main.exists()) {
|
|
main.writeText(
|
|
"""
|
|
/*
|
|
* Copyright 2019-2022 Mamoe Technologies and contributors.
|
|
*
|
|
* 此源代码的使用受 GNU AFFERO GENERAL PUBLIC LICENSE version 3 许可证的约束, 可以在以下链接找到该许可证.
|
|
* Use of this source code is governed by the GNU AGPLv3 license that can be found through the following link.
|
|
*
|
|
* https://github.com/mamoe/mirai/blob/dev/LICENSE
|
|
*/
|
|
|
|
package net.mamoe.mirai.internal.local
|
|
|
|
fun main() {}
|
|
""".trimIndent()
|
|
)
|
|
}
|
|
}
|
|
|
|
if (tasks.findByName("androidMainClasses") != null) {
|
|
tasks.register("checkAndroidApiLevel") {
|
|
doFirst {
|
|
analyzes.AndroidApiLevelCheck.check(
|
|
buildDir.resolve("classes/kotlin/android/main"),
|
|
project.property("mirai.android.target.api.level")!!.toString().toInt(),
|
|
project
|
|
)
|
|
}
|
|
group = "verification"
|
|
this.mustRunAfter("androidMainClasses")
|
|
}
|
|
tasks.getByName("androidTest").dependsOn("checkAndroidApiLevel")
|
|
}
|
|
|
|
configureMppPublishing()
|
|
configureBinaryValidators(setOf("jvm", "android").filterTargets())
|
|
configureRelocationForCore()
|
|
|
|
//mavenCentralPublish {
|
|
// artifactId = "mirai-core"
|
|
// githubProject("mamoe", "mirai")
|
|
// developer("Mamoe Technologies", email = "support@mamoe.net", url = "https://github.com/mamoe")
|
|
// licenseFromGitHubProject("AGPLv3", "dev")
|
|
// publishPlatformArtifactsInRootModule = "jvm"
|
|
//} |