Use libcxx prefab (#502)

This commit is contained in:
vvb2060 2021-04-24 03:27:19 +08:00 committed by GitHub
parent 02b3bbf1e3
commit 12c2876384
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
6 changed files with 4 additions and 45 deletions

3
.gitmodules vendored
View File

@ -4,9 +4,6 @@
[submodule "core/src/main/cpp/external/DexBuilder"]
path = core/src/main/cpp/external/DexBuilder
url = https://github.com/LSPosed/DexBuilder.git
[submodule "core/src/main/cpp/external/libcxx"]
path = core/src/main/cpp/external/libcxx
url = https://github.com/topjohnwu/libcxx.git
[submodule "core/src/main/cpp/external/Dobby"]
path = core/src/main/cpp/external/Dobby
url = https://github.com/LSPosed/Dobby.git

View File

@ -23,7 +23,6 @@ import org.apache.tools.ant.filters.FixCrLfFilter
import org.gradle.internal.os.OperatingSystem
import org.jetbrains.kotlin.daemon.common.toHexString
import java.io.PrintStream
import java.nio.file.Paths
import java.security.MessageDigest
plugins {
@ -65,6 +64,7 @@ val verName: String by rootProject.extra
dependencies {
implementation("dev.rikka.ndk:riru:${moduleMinRiruVersionName}")
implementation("dev.rikka.ndk.thirdparty:cxx:1.1.0")
implementation("com.android.tools.build:apksig:4.1.3")
implementation("org.apache.commons:commons-lang3:3.12.0")
implementation("de.upb.cs.swt:axml:2.1.1")
@ -186,41 +186,6 @@ android {
}
}
fun findInPath(executable: String): String? {
val pathEnv = System.getenv("PATH")
return pathEnv.split(File.pathSeparator).map { folder ->
Paths.get("${folder}${File.separator}${executable}${if (isWindows) ".exe" else ""}")
.toFile()
}.firstOrNull { path ->
path.exists()
}?.absolutePath
}
task("buildLibcxx", Exec::class) {
val ndkDir = android.ndkDirectory
executable = "$ndkDir/${if (isWindows) "ndk-build.cmd" else "ndk-build"}"
workingDir = projectDir
findInPath("ccache")?.let {
println("using ccache $it")
environment("NDK_CCACHE", it)
environment("USE_CCACHE", "1")
} ?: run {
println("not using ccache")
}
setArgs(
arrayListOf(
"NDK_PROJECT_PATH=build/intermediates/ndk",
"APP_BUILD_SCRIPT=$projectDir/src/main/cpp/external/libcxx/Android.mk",
"APP_CPPFLAGS=-std=c++20",
"APP_STL=none",
"-j${Runtime.getRuntime().availableProcessors()}"
)
)
}
tasks.getByName("preBuild").dependsOn("buildLibcxx")
android.applicationVariants.all {
val variantCapped = name.capitalize()
val variantLowered = name.toLowerCase()

View File

@ -27,7 +27,8 @@ if (CCACHE)
set(CMAKE_C_COMPILER_LAUNCHER ${CCACHE})
endif ()
include_directories(external/libcxx/include)
find_package(cxx REQUIRED CONFIG)
link_libraries(cxx::cxx)
add_subdirectory(main)
add_subdirectory(external)

View File

@ -15,6 +15,3 @@ if (NOT CMAKE_BUILD_TYPE STREQUAL "Debug")
endif (NOT CMAKE_BUILD_TYPE STREQUAL "Debug")
add_subdirectory(Dobby)
target_include_directories(dobby PUBLIC Dobby/include)
add_library(libcxx STATIC IMPORTED GLOBAL)
set_property(TARGET libcxx PROPERTY IMPORTED_LOCATION ${CMAKE_CURRENT_SOURCE_DIR}/../../../../build/intermediates/ndk/obj/local/${CMAKE_ANDROID_ARCH_ABI}/libcxx.a)

@ -1 +0,0 @@
Subproject commit f61fcee091736dd0ae38670876157e9862ac6ff8

View File

@ -30,7 +30,7 @@ add_library(lspd SHARED ${SRC_LIST} ${SRC_JNI_LIST} ${CMAKE_CURRENT_BINARY_DIR}/
find_package(riru REQUIRED CONFIG)
find_library(log-lib log)
target_link_libraries(lspd yahfa riru::riru android dobby dex_builder libcxx ${log-lib})
target_link_libraries(lspd yahfa riru::riru android dobby dex_builder ${log-lib})
add_custom_command(TARGET lspd POST_BUILD
COMMAND ${CMAKE_STRIP} --remove-section=.comment -g "${CMAKE_LIBRARY_OUTPUT_DIRECTORY}/liblspd.so")