diff --git a/.gitmodules b/.gitmodules index 3759e774..63c33add 100644 --- a/.gitmodules +++ b/.gitmodules @@ -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 diff --git a/core/build.gradle.kts b/core/build.gradle.kts index db274383..40e10cbc 100644 --- a/core/build.gradle.kts +++ b/core/build.gradle.kts @@ -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() diff --git a/core/src/main/cpp/CMakeLists.txt b/core/src/main/cpp/CMakeLists.txt index 7e089fd2..919a5eab 100644 --- a/core/src/main/cpp/CMakeLists.txt +++ b/core/src/main/cpp/CMakeLists.txt @@ -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) diff --git a/core/src/main/cpp/external/CMakeLists.txt b/core/src/main/cpp/external/CMakeLists.txt index 32bc4cb9..1ba04678 100644 --- a/core/src/main/cpp/external/CMakeLists.txt +++ b/core/src/main/cpp/external/CMakeLists.txt @@ -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) diff --git a/core/src/main/cpp/external/libcxx b/core/src/main/cpp/external/libcxx deleted file mode 160000 index f61fcee0..00000000 --- a/core/src/main/cpp/external/libcxx +++ /dev/null @@ -1 +0,0 @@ -Subproject commit f61fcee091736dd0ae38670876157e9862ac6ff8 diff --git a/core/src/main/cpp/main/CMakeLists.txt b/core/src/main/cpp/main/CMakeLists.txt index e344da81..17178cc5 100644 --- a/core/src/main/cpp/main/CMakeLists.txt +++ b/core/src/main/cpp/main/CMakeLists.txt @@ -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")