diff --git a/.github/workflows/core.yml b/.github/workflows/core.yml index 1136e338..578c0975 100644 --- a/.github/workflows/core.yml +++ b/.github/workflows/core.yml @@ -52,9 +52,12 @@ jobs: key: ccache-cache-${{ github.sha }} restore-keys: ccache-cache- - name: Install ccache - run: sudo apt-get install -y ccache + run: | + sudo apt-get install -y ccache + ccache -o max_size=2G + ccache -o hash_dir=false - name: Build with Gradle - run: | + run: | echo 'org.gradle.caching=true' >> gradle.properties echo 'org.gradle.parallel=true' >> gradle.properties echo 'org.gradle.vfs.watch=true' >> gradle.properties diff --git a/.gitmodules b/.gitmodules index 4b8b9b27..3759e774 100644 --- a/.gitmodules +++ b/.gitmodules @@ -9,4 +9,4 @@ 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/jmpews/Dobby.git + url = https://github.com/LSPosed/Dobby.git diff --git a/core/build.gradle.kts b/core/build.gradle.kts index 2757ce4b..3df84f98 100644 --- a/core/build.gradle.kts +++ b/core/build.gradle.kts @@ -99,16 +99,20 @@ android { "-fomit-frame-pointer", "-fpie", "-fPIC", "-Wno-builtin-macro-redefined", + "-D__FILE__=__FILE_NAME__", "-DRIRU_MODULE", "-DRIRU_MODULE_API_VERSION=$moduleMaxRiruApiVersion", - "-DRIRU_MODULE_VERSION=$verCode", - "-D__FILE__=__FILE_NAME__", - """-DRIRU_MODULE_VERSION_NAME=\"$verName\"""", """-DMODULE_NAME=\"$riruModuleId\"""" +// "-DRIRU_MODULE_VERSION=$verCode", // this will stop ccache from hitting +// """-DRIRU_MODULE_VERSION_NAME=\"$verName\"""", ) cppFlags("-std=c++20", *flags) cFlags("-std=c18", *flags) - arguments("-DANDROID_STL=none") + arguments( + "-DANDROID_STL=none", + "-DVERSION_CODE=$verCode", + "-DVERSION_NAME=$verName" + ) targets("lspd") } } diff --git a/core/src/main/cpp/external/Dobby b/core/src/main/cpp/external/Dobby index 1e3acde3..2da2c218 160000 --- a/core/src/main/cpp/external/Dobby +++ b/core/src/main/cpp/external/Dobby @@ -1 +1 @@ -Subproject commit 1e3acde39590f365c1fe489ecbd43f7ee8a5e20d +Subproject commit 2da2c218b0ae824b3a0e5ef1474223636f7f32a9 diff --git a/core/src/main/cpp/main/CMakeLists.txt b/core/src/main/cpp/main/CMakeLists.txt index f1f2a19e..eebc9821 100644 --- a/core/src/main/cpp/main/CMakeLists.txt +++ b/core/src/main/cpp/main/CMakeLists.txt @@ -20,10 +20,13 @@ cmake_minimum_required(VERSION 3.4.1) +configure_file(template/config.cpp src/config.cpp) + aux_source_directory(src SRC_LIST) aux_source_directory(src/jni SRC_JNI_LIST) include_directories(include src) -add_executable(lspd ${SRC_LIST} ${SRC_JNI_LIST}) + +add_executable(lspd ${SRC_LIST} ${SRC_JNI_LIST} ${CMAKE_CURRENT_BINARY_DIR}/src/config.cpp) SET(CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} -Wl,--dynamic-list=${CMAKE_SOURCE_DIR}/dynamic_list") diff --git a/core/src/main/cpp/main/include/config.h b/core/src/main/cpp/main/include/config.h index c32c6cfb..b66ab3bc 100644 --- a/core/src/main/cpp/main/include/config.h +++ b/core/src/main/cpp/main/include/config.h @@ -58,29 +58,32 @@ namespace lspd { # define LP_SELECT(lp32, lp64) lp32 #endif - static constexpr auto kEntryClassName = "org.lsposed.lspd.core.Main"_tstr; - static constexpr auto kClassLinkerClassName = "org.lsposed.lspd.nativebridge.ClassLinker"_tstr; - static constexpr auto kBridgeServiceClassName = "org.lsposed.lspd.service.BridgeService"_tstr; - static constexpr auto kDexPath = "framework/lspd.dex"_tstr; + inline static constexpr auto kEntryClassName = "org.lsposed.lspd.core.Main"_tstr; + inline static constexpr auto kClassLinkerClassName = "org.lsposed.lspd.nativebridge.ClassLinker"_tstr; + inline static constexpr auto kBridgeServiceClassName = "org.lsposed.lspd.service.BridgeService"_tstr; + inline static constexpr auto kDexPath = "framework/lspd.dex"_tstr; - static constexpr auto kLibArtName = "libart.so"_tstr; - static constexpr auto kLibFwName = "libandroidfw.so"_tstr; - static constexpr auto kLinkerName = LP_SELECT("linker"_tstr, "linker64"_tstr); - static constexpr auto kLibcName = "libc.so"_tstr; - static constexpr auto kLibbaseName = "libbase.so"_tstr; + inline static constexpr auto kLibArtName = "libart.so"_tstr; + inline static constexpr auto kLibFwName = "libandroidfw.so"_tstr; + inline static constexpr auto kLinkerName = LP_SELECT("linker"_tstr, "linker64"_tstr); + inline static constexpr auto kLibcName = "libc.so"_tstr; + inline static constexpr auto kLibbaseName = "libbase.so"_tstr; - static constexpr auto kLibBasePath = + inline static constexpr auto kLibBasePath = LP_SELECT("/system/lib/"_tstr, "/system/lib64/"_tstr); - static constexpr auto kBinBasePath = "/system/bin/"_tstr; + inline static constexpr auto kBinBasePath = "/system/bin/"_tstr; - static constexpr auto kLibFwPath = kLibBasePath + kLibFwName; - static constexpr auto kLinkerPath = kBinBasePath + kLinkerName; - static constexpr auto kLibcPath = kLibBasePath + kLibcName; - static constexpr auto kLibbasePath = kLibBasePath + kLibbaseName; + inline static constexpr auto kLibFwPath = kLibBasePath + kLibFwName; + inline static constexpr auto kLinkerPath = kBinBasePath + kLinkerName; + inline static constexpr auto kLibcPath = kLibBasePath + kLibcName; + inline static constexpr auto kLibbasePath = kLibBasePath + kLibbaseName; - inline constexpr const char *const BoolToString(bool b) { + inline constexpr const char *BoolToString(bool b) { return b ? "true" : "false"; } + + extern const int versionCode; + extern const char* const versionName; } diff --git a/core/src/main/cpp/main/src/main.cpp b/core/src/main/cpp/main/src/main.cpp index c411b846..83f79908 100644 --- a/core/src/main/cpp/main/src/main.cpp +++ b/core/src/main/cpp/main/src/main.cpp @@ -36,7 +36,7 @@ namespace lspd { void onModuleLoaded() { LOGI("onModuleLoaded: welcome to LSPosed!"); - LOGI("onModuleLoaded: version %s (%d)", RIRU_MODULE_VERSION_NAME, RIRU_MODULE_VERSION); + LOGI("onModuleLoaded: version %s (%d)", versionName, versionCode); // rirud must be used in onModuleLoaded Context::GetInstance()->PreLoadDex(magiskPath + '/' + kDexPath); InitSymbolCache(); @@ -99,8 +99,8 @@ namespace lspd { .moduleApiVersion = RIRU_MODULE_API_VERSION, .moduleInfo = RiruModuleInfo{ .supportHide = !isDebug, - .version = RIRU_MODULE_VERSION, - .versionName = RIRU_MODULE_VERSION_NAME, + .version = versionCode, + .versionName = versionName, .onModuleLoaded = lspd::onModuleLoaded, .forkAndSpecializePre = lspd::nativeForkAndSpecializePre, .forkAndSpecializePost = lspd::nativeForkAndSpecializePost, diff --git a/core/src/main/cpp/main/template/config.cpp b/core/src/main/cpp/main/template/config.cpp new file mode 100644 index 00000000..c5d06c72 --- /dev/null +++ b/core/src/main/cpp/main/template/config.cpp @@ -0,0 +1,6 @@ +#include "config.h" + +namespace lspd { + const int versionCode = ${VERSION_CODE}; + extern const char* const versionName = "${VERSION_NAME}"; +} diff --git a/settings.gradle.kts b/settings.gradle.kts index 2c6f0fb4..5e621e2c 100644 --- a/settings.gradle.kts +++ b/settings.gradle.kts @@ -1,6 +1,16 @@ rootProject.name = "LSPosed" -include(":core", ":hiddenapi-stubs", ":app", ":service", ":interface", ":hiddenapi-bridge", ":manager-service") +include( + ":core", + ":hiddenapi-stubs", + ":app", + ":service", + ":interface", + ":hiddenapi-bridge", + ":manager-service" +) val serviceRoot = "service" project(":interface").projectDir = file("$serviceRoot${File.separator}interface") project(":service").projectDir = file("$serviceRoot${File.separator}service") + +buildCache { local { removeUnusedEntriesAfterDays = 1 } }