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

View File

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

View File

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