diff --git a/.gitmodules b/.gitmodules index 79b0d1e..0efb5be 100644 --- a/.gitmodules +++ b/.gitmodules @@ -1,4 +1,4 @@ -[submodule "library/jni/external/dex_builder"] - path = library/jni/external/dex_builder +[submodule "dex_builder"] + path = lsplant/src/main/jni/external/dex_builder url = https://github.com/LSPosed/DexBuilder.git branch = master diff --git a/build.gradle.kts b/build.gradle.kts index 32aa357..e26f429 100644 --- a/build.gradle.kts +++ b/build.gradle.kts @@ -1,41 +1,9 @@ -/* - * This file is part of LSPosed. - * - * LSPosed is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * LSPosed is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with LSPosed. If not, see . - * - * Copyright (C) 2021 LSPosed Contributors - */ -import org.eclipse.jgit.api.Git -import org.eclipse.jgit.internal.storage.file.FileRepository - -buildscript { - repositories { - google() - mavenCentral() - } - val agpVersion by extra("7.1.1") - dependencies { - classpath("com.android.tools.build:gradle:$agpVersion") - classpath("org.eclipse.jgit:org.eclipse.jgit:6.0.0.202111291000-r") - } -} - val androidTargetSdkVersion by extra(32) val androidMinSdkVersion by extra(27) val androidBuildToolsVersion by extra("32.0.0") val androidCompileSdkVersion by extra(32) -val androidCompileNdkVersion by extra("23.1.7779620") +val androidNdkVersion by extra("23.1.7779620") +val androidCmakeVersion by extra("3.22.1") tasks.register("Delete", Delete::class) { delete(rootProject.buildDir) diff --git a/gradle.properties b/gradle.properties index f798c6a..89571f5 100644 --- a/gradle.properties +++ b/gradle.properties @@ -1,13 +1,2 @@ -# Project-wide Gradle settings. -# IDE (e.g. Android Studio) users: -# Gradle settings configured through the IDE *will override* -# any settings specified in this file. -# For more details on how to configure your build environment visit -# http://www.gradle.org/docs/current/userguide/build_environment.html -# Specifies the JVM arguments used for the daemon process. -# The setting is particularly useful for tweaking memory settings. -org.gradle.jvmargs=-Xmx2048m -Dfile.encoding=UTF-8 -# When configured, Gradle will run in incubating parallel mode. -# This option should only be used with decoupled projects. More details, visit -# http://www.gradle.org/docs/current/userguide/multi_project_builds.html#sec:decoupled_projects -org.gradle.parallel=true +android.nonTransitiveRClass=true +android.useAndroidX=true diff --git a/gradle/wrapper/gradle-wrapper.jar b/gradle/wrapper/gradle-wrapper.jar index 7454180..41d9927 100644 Binary files a/gradle/wrapper/gradle-wrapper.jar and b/gradle/wrapper/gradle-wrapper.jar differ diff --git a/library/build.gradle.kts b/library/build.gradle.kts deleted file mode 100644 index bd823c2..0000000 --- a/library/build.gradle.kts +++ /dev/null @@ -1,120 +0,0 @@ -/* - * This file is part of LSPosed. - * - * LSPosed is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * LSPosed is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with LSPosed. If not, see . - * - * Copyright (C) 2021 LSPosed Contributors - */ - -plugins { - id("com.android.library") -} - -val androidTargetSdkVersion: Int by rootProject.extra -val androidMinSdkVersion: Int by rootProject.extra -val androidBuildToolsVersion: String by rootProject.extra -val androidCompileSdkVersion: Int by rootProject.extra -val androidCompileNdkVersion: String by rootProject.extra - -android { - compileSdk = androidCompileSdkVersion - ndkVersion = androidCompileNdkVersion - buildToolsVersion = androidBuildToolsVersion - - buildFeatures { - prefabPublishing = true - } - - packagingOptions { - jniLibs { - excludes += "**.so" - } - } - - prefab { - create("lsplant") { - headers = "jni/include" - libraryName = "liblsplant" - name = "lsplant" - } - - // only for unit test - create("dex_builder") { - headers = "jni/external/dex_builder/include" - libraryName = "libdex_builder" - name = "dex_builder" - } - } - - defaultConfig { - minSdk = androidMinSdkVersion - targetSdk = androidTargetSdkVersion - externalNativeBuild { - cmake { - abiFilters("arm64-v8a", "armeabi-v7a", "x86", "x86_64") - val flags = arrayOf( - "-Wall", - "-Werror", - "-Qunused-arguments", - "-Wno-gnu-string-literal-operator-template", - "-fno-rtti", - "-fvisibility=hidden", - "-fvisibility-inlines-hidden", - "-fno-exceptions", - "-fno-stack-protector", - "-fomit-frame-pointer", - "-Wno-builtin-macro-redefined", - "-ffunction-sections", - "-fdata-sections", - "-Wno-unused-value", - "-Wl,--gc-sections", - "-D__FILE__=__FILE_NAME__", - "-Wl,--exclude-libs,ALL", - ) - cppFlags("-std=c++20", *flags) - cFlags("-std=c18", *flags) - arguments += "-DANDROID_STL=c++_shared" - val configFlags = arrayOf( - "-Oz", - "-DNDEBUG" - ).joinToString(" ") - arguments.addAll( - arrayOf( - "-DCMAKE_CXX_FLAGS_RELEASE=$configFlags", - "-DCMAKE_CXX_FLAGS_RELWITHDEBINFO=$configFlags", - "-DCMAKE_C_FLAGS_RELEASE=$configFlags", - "-DCMAKE_C_FLAGS_RELWITHDEBINFO=$configFlags" - ) - ) - } - } - } - - buildTypes { - all { - externalNativeBuild.cmake.arguments += "-DDEBUG_SYMBOLS_PATH=${project.buildDir.absolutePath}/symbols/$name" - } - } - - lint { - abortOnError = true - checkReleaseBuilds = false - } - - externalNativeBuild { - cmake { - path("jni/CMakeLists.txt") - } - } -} diff --git a/library/.gitignore b/lsplant/.gitignore similarity index 100% rename from library/.gitignore rename to lsplant/.gitignore diff --git a/lsplant/build.gradle.kts b/lsplant/build.gradle.kts new file mode 100644 index 0000000..2ea46d6 --- /dev/null +++ b/lsplant/build.gradle.kts @@ -0,0 +1,92 @@ +plugins { + id("com.android.library") +} + +val androidTargetSdkVersion: Int by rootProject.extra +val androidMinSdkVersion: Int by rootProject.extra +val androidBuildToolsVersion: String by rootProject.extra +val androidCompileSdkVersion: Int by rootProject.extra +val androidNdkVersion: String by rootProject.extra +val androidCmakeVersion: String by rootProject.extra + +android { + compileSdk = androidCompileSdkVersion + ndkVersion = androidNdkVersion + buildToolsVersion = androidBuildToolsVersion + + buildFeatures { + prefabPublishing = true + } + + packagingOptions { + jniLibs { + excludes += "**.so" + } + } + + prefab { + register("lsplant") { + headers = "src/main/jni/include" + } + } + + defaultConfig { + minSdk = androidMinSdkVersion + targetSdk = androidTargetSdkVersion + } + + buildTypes { + all { + externalNativeBuild { + cmake { + abiFilters("arm64-v8a", "armeabi-v7a", "x86", "x86_64") + val flags = arrayOf( + "-Wall", + "-Werror", + "-Qunused-arguments", + "-Wno-gnu-string-literal-operator-template", + "-fno-rtti", + "-fvisibility=hidden", + "-fvisibility-inlines-hidden", + "-fno-exceptions", + "-fno-stack-protector", + "-fomit-frame-pointer", + "-Wno-builtin-macro-redefined", + "-ffunction-sections", + "-fdata-sections", + "-Wno-unused-value", + "-Wl,--gc-sections", + "-D__FILE__=__FILE_NAME__", + "-Wl,--exclude-libs,ALL", + ) + cppFlags("-std=c++20", *flags) + cFlags("-std=c18", *flags) + val configFlags = arrayOf( + "-Oz", + "-DNDEBUG" + ).joinToString(" ") + arguments( + "-DANDROID_STL=c++_shared", + "-DCMAKE_CXX_FLAGS_RELEASE=$configFlags", + "-DCMAKE_CXX_FLAGS_RELWITHDEBINFO=$configFlags", + "-DCMAKE_C_FLAGS_RELEASE=$configFlags", + "-DCMAKE_C_FLAGS_RELWITHDEBINFO=$configFlags", + "-DDEBUG_SYMBOLS_PATH=${project.buildDir.absolutePath}/symbols/$name", + ) + } + } + } + } + + lint { + abortOnError = true + checkReleaseBuilds = false + } + + externalNativeBuild { + cmake { + path = file("src/main/jni/CMakeLists.txt") + version = androidCmakeVersion + } + } +} diff --git a/library/src/main/AndroidManifest.xml b/lsplant/src/main/AndroidManifest.xml similarity index 100% rename from library/src/main/AndroidManifest.xml rename to lsplant/src/main/AndroidManifest.xml diff --git a/library/jni/.clang-format b/lsplant/src/main/jni/.clang-format similarity index 100% rename from library/jni/.clang-format rename to lsplant/src/main/jni/.clang-format diff --git a/library/jni/.clang-tidy b/lsplant/src/main/jni/.clang-tidy similarity index 100% rename from library/jni/.clang-tidy rename to lsplant/src/main/jni/.clang-tidy diff --git a/library/jni/Android.mk b/lsplant/src/main/jni/Android.mk similarity index 100% rename from library/jni/Android.mk rename to lsplant/src/main/jni/Android.mk diff --git a/library/jni/Application.mk b/lsplant/src/main/jni/Application.mk similarity index 100% rename from library/jni/Application.mk rename to lsplant/src/main/jni/Application.mk diff --git a/library/jni/CMakeLists.txt b/lsplant/src/main/jni/CMakeLists.txt similarity index 92% rename from library/jni/CMakeLists.txt rename to lsplant/src/main/jni/CMakeLists.txt index d6d06f7..cd6ce22 100644 --- a/library/jni/CMakeLists.txt +++ b/lsplant/src/main/jni/CMakeLists.txt @@ -40,6 +40,7 @@ add_custom_command(TARGET ${PROJECT_NAME} POST_BUILD ${DEBUG_SYMBOLS_PATH}/${ANDROID_ABI}/${PROJECT_NAME} COMMAND ${CMAKE_STRIP} --strip-all $) -target_link_libraries(${PROJECT_NAME} PUBLIC dex_builder log) +target_link_libraries(${PROJECT_NAME} PRIVATE dex_builder_static) +target_link_libraries(${PROJECT_NAME} PUBLIC log) target_link_libraries(${PROJECT_NAME}_static PRIVATE dex_builder_static) target_link_libraries(${PROJECT_NAME}_static PUBLIC log) diff --git a/library/jni/art/instrumentation.hpp b/lsplant/src/main/jni/art/instrumentation.hpp similarity index 100% rename from library/jni/art/instrumentation.hpp rename to lsplant/src/main/jni/art/instrumentation.hpp diff --git a/library/jni/art/mirror/class.hpp b/lsplant/src/main/jni/art/mirror/class.hpp similarity index 100% rename from library/jni/art/mirror/class.hpp rename to lsplant/src/main/jni/art/mirror/class.hpp diff --git a/library/jni/art/runtime/art_method.hpp b/lsplant/src/main/jni/art/runtime/art_method.hpp similarity index 100% rename from library/jni/art/runtime/art_method.hpp rename to lsplant/src/main/jni/art/runtime/art_method.hpp diff --git a/library/jni/art/runtime/class_linker.hpp b/lsplant/src/main/jni/art/runtime/class_linker.hpp similarity index 100% rename from library/jni/art/runtime/class_linker.hpp rename to lsplant/src/main/jni/art/runtime/class_linker.hpp diff --git a/library/jni/art/runtime/gc/collector_type.hpp b/lsplant/src/main/jni/art/runtime/gc/collector_type.hpp similarity index 100% rename from library/jni/art/runtime/gc/collector_type.hpp rename to lsplant/src/main/jni/art/runtime/gc/collector_type.hpp diff --git a/library/jni/art/runtime/gc/gc_cause.hpp b/lsplant/src/main/jni/art/runtime/gc/gc_cause.hpp similarity index 100% rename from library/jni/art/runtime/gc/gc_cause.hpp rename to lsplant/src/main/jni/art/runtime/gc/gc_cause.hpp diff --git a/library/jni/art/runtime/gc/scoped_gc_critical_section.hpp b/lsplant/src/main/jni/art/runtime/gc/scoped_gc_critical_section.hpp similarity index 100% rename from library/jni/art/runtime/gc/scoped_gc_critical_section.hpp rename to lsplant/src/main/jni/art/runtime/gc/scoped_gc_critical_section.hpp diff --git a/library/jni/art/runtime/jit/jit_code_cache.hpp b/lsplant/src/main/jni/art/runtime/jit/jit_code_cache.hpp similarity index 100% rename from library/jni/art/runtime/jit/jit_code_cache.hpp rename to lsplant/src/main/jni/art/runtime/jit/jit_code_cache.hpp diff --git a/library/jni/art/thread.hpp b/lsplant/src/main/jni/art/thread.hpp similarity index 100% rename from library/jni/art/thread.hpp rename to lsplant/src/main/jni/art/thread.hpp diff --git a/library/jni/art/thread_list.hpp b/lsplant/src/main/jni/art/thread_list.hpp similarity index 100% rename from library/jni/art/thread_list.hpp rename to lsplant/src/main/jni/art/thread_list.hpp diff --git a/library/jni/common.hpp b/lsplant/src/main/jni/common.hpp similarity index 100% rename from library/jni/common.hpp rename to lsplant/src/main/jni/common.hpp diff --git a/library/jni/external/dex_builder b/lsplant/src/main/jni/external/dex_builder similarity index 100% rename from library/jni/external/dex_builder rename to lsplant/src/main/jni/external/dex_builder diff --git a/library/jni/include/lsplant.hpp b/lsplant/src/main/jni/include/lsplant.hpp similarity index 100% rename from library/jni/include/lsplant.hpp rename to lsplant/src/main/jni/include/lsplant.hpp diff --git a/library/jni/include/utils/hook_helper.hpp b/lsplant/src/main/jni/include/utils/hook_helper.hpp similarity index 100% rename from library/jni/include/utils/hook_helper.hpp rename to lsplant/src/main/jni/include/utils/hook_helper.hpp diff --git a/library/jni/include/utils/jni_helper.hpp b/lsplant/src/main/jni/include/utils/jni_helper.hpp similarity index 100% rename from library/jni/include/utils/jni_helper.hpp rename to lsplant/src/main/jni/include/utils/jni_helper.hpp diff --git a/library/jni/logging.hpp b/lsplant/src/main/jni/logging.hpp similarity index 100% rename from library/jni/logging.hpp rename to lsplant/src/main/jni/logging.hpp diff --git a/library/jni/lsplant.cc b/lsplant/src/main/jni/lsplant.cc similarity index 100% rename from library/jni/lsplant.cc rename to lsplant/src/main/jni/lsplant.cc diff --git a/settings.gradle.kts b/settings.gradle.kts index 82f2921..3e1408e 100644 --- a/settings.gradle.kts +++ b/settings.gradle.kts @@ -1,3 +1,15 @@ +pluginManagement { + repositories { + gradlePluginPortal() + google() + mavenCentral() + } + plugins { + id("com.android.application") version "7.1.1" + id("com.android.library") version "7.1.1" + id("org.jetbrains.kotlin.android") version "1.6.10" + } +} dependencyResolutionManagement { repositoriesMode.set(RepositoriesMode.FAIL_ON_PROJECT_REPOS) repositories { @@ -8,6 +20,6 @@ dependencyResolutionManagement { rootProject.name = "LSPlant" include( - ":library", - ":test" + ":lsplant", + ":test", ) diff --git a/test/build.gradle.kts b/test/build.gradle.kts index e3c040c..dc21e90 100644 --- a/test/build.gradle.kts +++ b/test/build.gradle.kts @@ -6,12 +6,12 @@ val androidTargetSdkVersion: Int by rootProject.extra val androidMinSdkVersion: Int by rootProject.extra val androidBuildToolsVersion: String by rootProject.extra val androidCompileSdkVersion: Int by rootProject.extra -val androidCompileNdkVersion: String by rootProject.extra +val androidNdkVersion: String by rootProject.extra +val androidCmakeVersion: String by rootProject.extra android { - namespace = "org.lsposed.lsplant.test" compileSdk = androidCompileSdkVersion - ndkVersion = androidCompileNdkVersion + ndkVersion = androidNdkVersion buildToolsVersion = androidBuildToolsVersion buildFeatures { @@ -19,13 +19,12 @@ android { } defaultConfig { - applicationId = "org.lsposed.lsplant.test" + applicationId = "org.lsposed.lsplant" minSdk = androidMinSdkVersion targetSdk = androidTargetSdkVersion versionCode = 1 versionName = "1.0" - - testInstrumentationRunner = "android.support.test.runner.AndroidJUnitRunner" + testInstrumentationRunner = "androidx.test.runner.AndroidJUnitRunner" externalNativeBuild { cmake { arguments += "-DANDROID_STL=c++_shared" @@ -35,14 +34,8 @@ android { externalNativeBuild { cmake { - path("src/main/jni/CMakeLists.txt") - } - } - - buildTypes { - release { - isMinifyEnabled = true - proguardFiles(getDefaultProguardFile("proguard-android-optimize.txt"), "proguard-rules.pro") + path = file("src/main/jni/CMakeLists.txt") + version = androidCmakeVersion } } @@ -53,10 +46,10 @@ android { } dependencies { - implementation(project(":library")) + implementation(project(":lsplant")) implementation("io.github.vvb2060.ndk:dobby:1.2") - testImplementation("junit:junit:4.13.2") - androidTestImplementation("com.android.support.test:runner:1.0.2") - androidTestImplementation("com.android.support.test.espresso:espresso-core:3.0.2") + androidTestImplementation("androidx.test.ext:junit:1.1.3") + androidTestImplementation("androidx.test:runner:1.4.0") + androidTestImplementation("androidx.test.espresso:espresso-core:3.4.0") } diff --git a/test/proguard-rules.pro b/test/proguard-rules.pro deleted file mode 100644 index 481bb43..0000000 --- a/test/proguard-rules.pro +++ /dev/null @@ -1,21 +0,0 @@ -# Add project specific ProGuard rules here. -# You can control the set of applied configuration files using the -# proguardFiles setting in build.gradle. -# -# For more details, see -# http://developer.android.com/guide/developing/tools/proguard.html - -# If your project uses WebView with JS, uncomment the following -# and specify the fully qualified class name to the JavaScript interface -# class: -#-keepclassmembers class fqcn.of.javascript.interface.for.webview { -# public *; -#} - -# Uncomment this to preserve the line number information for -# debugging stack traces. -#-keepattributes SourceFile,LineNumberTable - -# If you keep the line number information, uncomment this to -# hide the original source file name. -#-renamesourcefileattribute SourceFile \ No newline at end of file diff --git a/test/src/androidTest/java/org/lsposed/lsplant/UnitTest.java b/test/src/androidTest/java/org/lsposed/lsplant/UnitTest.java index 63da357..dd86ec4 100644 --- a/test/src/androidTest/java/org/lsposed/lsplant/UnitTest.java +++ b/test/src/androidTest/java/org/lsposed/lsplant/UnitTest.java @@ -1,6 +1,6 @@ package org.lsposed.lsplant; -import android.support.test.runner.AndroidJUnit4; +import androidx.test.ext.junit.runners.AndroidJUnit4; import org.junit.Assert; import org.junit.FixMethodOrder; diff --git a/test/src/main/AndroidManifest.xml b/test/src/main/AndroidManifest.xml index b51b00f..64c2a1c 100644 --- a/test/src/main/AndroidManifest.xml +++ b/test/src/main/AndroidManifest.xml @@ -1,8 +1,2 @@ - - - - + diff --git a/test/src/main/jni/CMakeLists.txt b/test/src/main/jni/CMakeLists.txt index 9b9f5e6..27e3a6d 100644 --- a/test/src/main/jni/CMakeLists.txt +++ b/test/src/main/jni/CMakeLists.txt @@ -6,5 +6,5 @@ set(CMAKE_CXX_STANDARD_REQUIRED ON) add_library(test SHARED test.cpp elf_util.cpp) find_package(dobby REQUIRED CONFIG) -find_package(library REQUIRED CONFIG) -target_link_libraries(test log dobby::dobby library::lsplant library::dex_builder) +find_package(lsplant REQUIRED CONFIG) +target_link_libraries(test log dobby::dobby lsplant::lsplant)