Add build type without c++_shared: Standalone

This commit is contained in:
LoveSy 2022-09-16 15:06:14 +08:00
parent 0365d27557
commit fb083af39c
No known key found for this signature in database
3 changed files with 50 additions and 10 deletions

View File

@ -20,6 +20,7 @@ android {
buildConfig = false
prefabPublishing = true
androidResources = false
prefab = true
}
packagingOptions {
@ -40,6 +41,14 @@ android {
}
buildTypes {
create("standalone") {
initWith(getByName("release"))
externalNativeBuild {
cmake {
arguments += "-DANDROID_STL=none"
}
}
}
all {
externalNativeBuild {
cmake {
@ -70,13 +79,15 @@ android {
"-DNDEBUG"
).joinToString(" ")
arguments(
"-DANDROID_STL=c++_shared",
"-DCMAKE_CXX_FLAGS_RELEASE=$configFlags",
"-DCMAKE_CXX_FLAGS_RELWITHDEBINFO=$configFlags",
"-DCMAKE_C_FLAGS_RELEASE=$configFlags",
"-DCMAKE_C_FLAGS_RELWITHDEBINFO=$configFlags",
"-DDEBUG_SYMBOLS_PATH=${project.buildDir.absolutePath}/symbols/$name",
)
if (name != "standalone") {
arguments += "-DANDROID_STL=c++_shared"
}
}
}
}
@ -100,25 +111,30 @@ android {
withSourcesJar()
withJavadocJar()
}
singleVariant("standalone") {
withSourcesJar()
withJavadocJar()
}
}
}
val symbolsTask = tasks.register<Jar>("generateReleaseSymbolsJar") {
val symbolsReleaseTask = tasks.register<Jar>("generateReleaseSymbolsJar") {
from("${project.buildDir.absolutePath}/symbols/release")
exclude("**/dex_builder")
archiveClassifier.set("symbols")
}
val symbolsStandaloneTask = tasks.register<Jar>("generateStandaloneSymbolsJar") {
from("${project.buildDir.absolutePath}/symbols/standalone")
exclude("**/dex_builder")
archiveClassifier.set("symbols")
}
publishing {
publications {
register<MavenPublication>("lsplant") {
fun MavenPublication.setup() {
group = "org.lsposed.lsplant"
artifactId = "lsplant"
version = "4.2"
afterEvaluate {
from(components.getByName("release"))
artifact(symbolsTask)
}
pom {
name.set("LSPlant")
description.set("A hook framework for Android Runtime (ART)")
@ -141,6 +157,22 @@ publishing {
}
}
}
register<MavenPublication>("lsplant") {
artifactId = "lsplant"
afterEvaluate {
from(components.getByName("release"))
artifact(symbolsReleaseTask)
}
setup()
}
register<MavenPublication>("lsplantStandalone") {
artifactId = "lsplant-standalone"
afterEvaluate {
from(components.getByName("standalone"))
artifact(symbolsStandaloneTask)
}
setup()
}
}
repositories {
maven {
@ -157,6 +189,9 @@ publishing {
}
}
}
dependencies {
"standaloneImplementation"("dev.rikka.ndk.thirdparty:cxx:1.2.0")
}
}
signing {

View File

@ -8,6 +8,11 @@ if (CCACHE)
set(CMAKE_C_COMPILER_LAUNCHER ${CCACHE})
endif ()
if ("${ANDROID_STL}" STREQUAL "none")
find_package(cxx REQUIRED CONFIG)
link_libraries(cxx::cxx)
endif()
add_definitions(-std=c++20)
set(SOURCES lsplant.cc)

View File

@ -5,8 +5,8 @@ pluginManagement {
mavenCentral()
}
plugins {
id("com.android.application") version "7.2.2"
id("com.android.library") version "7.2.2"
id("com.android.application") version "7.3.0"
id("com.android.library") version "7.3.0"
}
}
dependencyResolutionManagement {