mirror of
https://github.com/chiteroman/TrickyStore.git
synced 2025-07-17 15:29:32 +00:00
Switch to lsplugin cmaker
Reduce binary size by configuring right flags with it. Signed-off-by: GarfieldHan <2652609017@qq.com>
This commit is contained in:
@@ -11,5 +11,6 @@ cxx = { module = "org.lsposed.libcxx:libcxx", version = "27.0.12077973" }
|
|||||||
|
|
||||||
[plugins]
|
[plugins]
|
||||||
agp-app = { id = "com.android.application", version.ref = "agp" }
|
agp-app = { id = "com.android.application", version.ref = "agp" }
|
||||||
jetbrains-kotlin-android = { id = "org.jetbrains.kotlin.android", version.ref = "kotlin" }
|
|
||||||
android-library = { id = "com.android.library", version.ref = "agp" }
|
android-library = { id = "com.android.library", version.ref = "agp" }
|
||||||
|
jetbrains-kotlin-android = { id = "org.jetbrains.kotlin.android", version.ref = "kotlin" }
|
||||||
|
lsplugin-cmaker = { id = "org.lsposed.lsplugin.cmaker", version = "1.2" }
|
||||||
|
|||||||
@@ -5,6 +5,7 @@ import java.security.MessageDigest
|
|||||||
|
|
||||||
plugins {
|
plugins {
|
||||||
alias(libs.plugins.agp.app)
|
alias(libs.plugins.agp.app)
|
||||||
|
alias(libs.plugins.lsplugin.cmaker)
|
||||||
}
|
}
|
||||||
|
|
||||||
val moduleId: String by rootProject.extra
|
val moduleId: String by rootProject.extra
|
||||||
@@ -16,9 +17,9 @@ val abiList: List<String> by rootProject.extra
|
|||||||
val androidMinSdkVersion: Int by rootProject.extra
|
val androidMinSdkVersion: Int by rootProject.extra
|
||||||
|
|
||||||
val releaseFlags = arrayOf(
|
val releaseFlags = arrayOf(
|
||||||
"-Oz", "-flto",
|
"-O3", "-flto",
|
||||||
"-Wno-unused", "-Wno-unused-parameter",
|
"-Wno-unused", "-Wno-unused-parameter",
|
||||||
"-Wl,--exclude-libs,ALL", "-Wl,--gc-sections",
|
"-Wl,--exclude-libs,ALL", "-Wl,-icf=all,--lto-O3", "-Wl,-s,-x,--gc-sections"
|
||||||
)
|
)
|
||||||
|
|
||||||
android {
|
android {
|
||||||
@@ -26,15 +27,6 @@ android {
|
|||||||
ndk {
|
ndk {
|
||||||
abiFilters.addAll(abiList)
|
abiFilters.addAll(abiList)
|
||||||
}
|
}
|
||||||
externalNativeBuild {
|
|
||||||
cmake {
|
|
||||||
cppFlags("-std=c++23")
|
|
||||||
arguments(
|
|
||||||
"-DANDROID_STL=none",
|
|
||||||
"-DMODULE_NAME=$moduleId"
|
|
||||||
)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
buildFeatures {
|
buildFeatures {
|
||||||
@@ -47,13 +39,25 @@ android {
|
|||||||
path("src/main/cpp/CMakeLists.txt")
|
path("src/main/cpp/CMakeLists.txt")
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
cmaker {
|
||||||
|
default {
|
||||||
|
val cmakeArgs = arrayOf(
|
||||||
|
"-DANDROID_STL=none",
|
||||||
|
"-DMODULE_NAME=$moduleId",
|
||||||
|
)
|
||||||
|
arguments += cmakeArgs
|
||||||
|
abiFilters("arm64-v8a", "x86_64")
|
||||||
|
}
|
||||||
buildTypes {
|
buildTypes {
|
||||||
release {
|
when (it.name) {
|
||||||
externalNativeBuild.cmake {
|
"release" -> {
|
||||||
cFlags += releaseFlags
|
|
||||||
cppFlags += releaseFlags
|
cppFlags += releaseFlags
|
||||||
|
cFlags += releaseFlags
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
cppFlags += "--std=c++23"
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -26,21 +26,21 @@ target_link_libraries(elf_util lsplt my_logging)
|
|||||||
|
|
||||||
# libutils stub
|
# libutils stub
|
||||||
add_library(utils SHARED binder/stub_utils.cpp)
|
add_library(utils SHARED binder/stub_utils.cpp)
|
||||||
|
target_compile_options(utils PRIVATE -fvisibility=default -fno-visibility-inlines-hidden)
|
||||||
target_include_directories(utils PUBLIC binder/include)
|
target_include_directories(utils PUBLIC binder/include)
|
||||||
|
|
||||||
# libbinder stub
|
# libbinder stub
|
||||||
add_library(binder SHARED binder/stub_binder.cpp)
|
add_library(binder SHARED binder/stub_binder.cpp)
|
||||||
target_include_directories(binder PUBLIC binder/include)
|
target_include_directories(binder PUBLIC binder/include)
|
||||||
target_link_libraries(binder utils)
|
target_link_libraries(binder PRIVATE utils)
|
||||||
|
|
||||||
add_executable(libinject.so inject/main.cpp inject/utils.cpp)
|
add_executable(libinject.so inject/main.cpp inject/utils.cpp)
|
||||||
target_link_libraries(libinject.so lsplt my_logging)
|
target_link_libraries(libinject.so PRIVATE lsplt my_logging)
|
||||||
target_compile_options(libinject.so PRIVATE -fvisibility=hidden -fvisibility-inlines-hidden)
|
target_compile_options(libinject.so PRIVATE -fvisibility=hidden -fvisibility-inlines-hidden)
|
||||||
|
|
||||||
add_library(${MODULE_NAME} SHARED binder_interceptor.cpp)
|
add_library(${MODULE_NAME} SHARED binder_interceptor.cpp)
|
||||||
target_link_libraries(${MODULE_NAME} log binder utils elf_util my_logging)
|
target_link_libraries(${MODULE_NAME} PRIVATE log binder utils elf_util my_logging)
|
||||||
target_compile_options(${MODULE_NAME} PRIVATE -fvisibility=hidden -fvisibility-inlines-hidden)
|
target_compile_options(${MODULE_NAME} PRIVATE -fvisibility=hidden -fvisibility-inlines-hidden)
|
||||||
|
|
||||||
add_library(tszygisk SHARED zygisk/main.cpp)
|
add_library(tszygisk SHARED zygisk/main.cpp)
|
||||||
target_link_libraries(tszygisk log my_logging glaze::glaze)
|
target_link_libraries(tszygisk PRIVATE log my_logging glaze::glaze)
|
||||||
target_compile_options(tszygisk PRIVATE -fvisibility=hidden -fvisibility-inlines-hidden)
|
|
||||||
|
|||||||
Reference in New Issue
Block a user