You've already forked TrickyStore
mirror of
https://github.com/5ec1cff/TrickyStore.git
synced 2025-09-06 06:37:07 +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]
|
||||
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" }
|
||||
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 {
|
||||
alias(libs.plugins.agp.app)
|
||||
alias(libs.plugins.lsplugin.cmaker)
|
||||
}
|
||||
|
||||
val moduleId: String by rootProject.extra
|
||||
@@ -16,9 +17,9 @@ val abiList: List<String> by rootProject.extra
|
||||
val androidMinSdkVersion: Int by rootProject.extra
|
||||
|
||||
val releaseFlags = arrayOf(
|
||||
"-Oz", "-flto",
|
||||
"-O3", "-flto",
|
||||
"-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 {
|
||||
@@ -26,15 +27,6 @@ android {
|
||||
ndk {
|
||||
abiFilters.addAll(abiList)
|
||||
}
|
||||
externalNativeBuild {
|
||||
cmake {
|
||||
cppFlags("-std=c++23")
|
||||
arguments(
|
||||
"-DANDROID_STL=none",
|
||||
"-DMODULE_NAME=$moduleId"
|
||||
)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
buildFeatures {
|
||||
@@ -47,13 +39,25 @@ android {
|
||||
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 {
|
||||
release {
|
||||
externalNativeBuild.cmake {
|
||||
cFlags += releaseFlags
|
||||
when (it.name) {
|
||||
"release" -> {
|
||||
cppFlags += releaseFlags
|
||||
cFlags += releaseFlags
|
||||
}
|
||||
}
|
||||
cppFlags += "--std=c++23"
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -26,21 +26,21 @@ target_link_libraries(elf_util lsplt my_logging)
|
||||
|
||||
# libutils stub
|
||||
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)
|
||||
|
||||
# libbinder stub
|
||||
add_library(binder SHARED binder/stub_binder.cpp)
|
||||
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)
|
||||
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)
|
||||
|
||||
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)
|
||||
|
||||
add_library(tszygisk SHARED zygisk/main.cpp)
|
||||
target_link_libraries(tszygisk log my_logging glaze::glaze)
|
||||
target_compile_options(tszygisk PRIVATE -fvisibility=hidden -fvisibility-inlines-hidden)
|
||||
target_link_libraries(tszygisk PRIVATE log my_logging glaze::glaze)
|
||||
|
||||
Reference in New Issue
Block a user