Migrate to cmake
This commit is contained in:
parent
6d1690f379
commit
be6e449fb4
|
|
@ -19,7 +19,6 @@ ext {
|
|||
whale_authors = "solohsu, asLody & MlgmXyysd"
|
||||
|
||||
riruModuleId = "edxp"
|
||||
libPathRelease = "$buildDir/ndkBuild/release/lib"
|
||||
zipPathMagiskRelease = "$buildDir/tmp/release/magisk"
|
||||
}
|
||||
|
||||
|
|
@ -30,15 +29,37 @@ android {
|
|||
targetSdkVersion rootProject.ext.targetSdkVersion
|
||||
|
||||
externalNativeBuild {
|
||||
ndkBuild {
|
||||
cmake {
|
||||
abiFilters 'arm64-v8a', 'armeabi-v7a', 'x86', 'x86_64'
|
||||
arguments "NDK_PROJECT_PATH=jni/"
|
||||
cppFlags "-std=c++11 -ffixed-x18 -Qunused-arguments -frtti"
|
||||
cFlags "-std=gnu99 -ffixed-x18 -Qunused-arguments -frtti"
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
buildTypes {
|
||||
debug {
|
||||
externalNativeBuild {
|
||||
cmake {
|
||||
cppFlags "-O0"
|
||||
cFlags "-O0"
|
||||
}
|
||||
}
|
||||
}
|
||||
release {
|
||||
externalNativeBuild {
|
||||
cmake {
|
||||
cppFlags "-fvisibility=hidden -fvisibility-inlines-hidden -O2 -s"
|
||||
cFlags "-fvisibility=hidden -fvisibility-inlines-hidden -O2 -s"
|
||||
}
|
||||
}
|
||||
minifyEnabled true
|
||||
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
|
||||
}
|
||||
}
|
||||
externalNativeBuild {
|
||||
ndkBuild {
|
||||
path 'jni/Android.mk'
|
||||
cmake {
|
||||
path "src/main/cpp/CMakeLists.txt"
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -75,57 +96,6 @@ task cleanTemplate(type: Delete) {
|
|||
delete file(templateSystemPath), file(templateSystemx86Path)
|
||||
}
|
||||
|
||||
// riru related tasks
|
||||
|
||||
task buildNativeRelease(type: Exec) {
|
||||
if (is_windows)
|
||||
commandLine 'cmd', '/c', 'ndk-build.cmd',
|
||||
'-j8',
|
||||
"NDK_LIBS_OUT=$libPathRelease",
|
||||
"NDK_OUT=$buildDir/ndkBuild/release/obj".replace("\\", "/")
|
||||
else
|
||||
commandLine 'ndk-build',
|
||||
'-j8',
|
||||
"NDK_LIBS_OUT=$libPathRelease",
|
||||
"NDK_OUT=$buildDir/ndkBuild/release/obj"
|
||||
}
|
||||
|
||||
task cleanMagiskRelease(type: Delete) {
|
||||
delete file(zipPathMagiskRelease)
|
||||
}
|
||||
|
||||
task copyFilesMagiskRelease {
|
||||
doLast {
|
||||
copy {
|
||||
from "${projectDir}/template_override"
|
||||
into zipPathMagiskRelease
|
||||
}
|
||||
copy {
|
||||
from 'template_override/riru_module.prop'
|
||||
into "$zipPathMagiskRelease/data/misc/riru/modules/${riruModuleId}"
|
||||
}
|
||||
copy {
|
||||
from "$libPathRelease/armeabi-v7a"
|
||||
into "$zipPathMagiskRelease/system/lib"
|
||||
}
|
||||
copy {
|
||||
from "$libPathRelease/arm64-v8a"
|
||||
into "$zipPathMagiskRelease/system/lib64"
|
||||
}
|
||||
copy {
|
||||
from "$libPathRelease/x86"
|
||||
into "$zipPathMagiskRelease/system_x86/lib"
|
||||
}
|
||||
copy {
|
||||
from "$libPathRelease/x86_64"
|
||||
into "$zipPathMagiskRelease/system_x86/lib64"
|
||||
}
|
||||
|
||||
file("$zipPathMagiskRelease/riru_module.prop").delete()
|
||||
file("$zipPathMagiskRelease/data/misc/riru/modules/${riruModuleId}/riru_module.prop").renameTo("$zipPathMagiskRelease/data/misc/riru/modules/${riruModuleId}/module.prop")
|
||||
}
|
||||
}
|
||||
|
||||
afterEvaluate {
|
||||
|
||||
android.libraryVariants.all { variant ->
|
||||
|
|
@ -145,13 +115,9 @@ afterEvaluate {
|
|||
dependsOn tasks.getByPath(":edxp-${backendLowered}:makeAndCopy${variantCapped}")
|
||||
}
|
||||
|
||||
def preZipTask = task("preZip${backendCapped}${variantCapped}", type: GradleBuild) {
|
||||
dependsOn prepareJarsTask
|
||||
tasks = [
|
||||
'buildNativeRelease',
|
||||
'cleanMagiskRelease',
|
||||
'copyFilesMagiskRelease'
|
||||
]
|
||||
def prepareMagiskFilesTask = task("prepareMagiskFiles${backendCapped}${variantCapped}", type: Delete) {
|
||||
dependsOn prepareJarsTask, "assemble${variantCapped}"
|
||||
delete file(zipPathMagiskRelease)
|
||||
doFirst {
|
||||
copy {
|
||||
from "${projectDir}/tpl/edconfig.tpl"
|
||||
|
|
@ -174,10 +140,40 @@ afterEvaluate {
|
|||
rename "module.prop", "riru_module.prop"
|
||||
}
|
||||
}
|
||||
def libPathRelease = "${buildDir}/intermediates/cmake/${variantLowered}/obj"
|
||||
doLast {
|
||||
copy {
|
||||
from "${projectDir}/template_override"
|
||||
into zipPathMagiskRelease
|
||||
}
|
||||
copy {
|
||||
from 'template_override/riru_module.prop'
|
||||
into "$zipPathMagiskRelease/data/misc/riru/modules/${riruModuleId}"
|
||||
}
|
||||
copy {
|
||||
from "$libPathRelease/armeabi-v7a"
|
||||
into "$zipPathMagiskRelease/system/lib"
|
||||
}
|
||||
copy {
|
||||
from "$libPathRelease/arm64-v8a"
|
||||
into "$zipPathMagiskRelease/system/lib64"
|
||||
}
|
||||
copy {
|
||||
from "$libPathRelease/x86"
|
||||
into "$zipPathMagiskRelease/system_x86/lib"
|
||||
}
|
||||
copy {
|
||||
from "$libPathRelease/x86_64"
|
||||
into "$zipPathMagiskRelease/system_x86/lib64"
|
||||
}
|
||||
|
||||
file("$zipPathMagiskRelease/riru_module.prop").delete()
|
||||
file("$zipPathMagiskRelease/data/misc/riru/modules/${riruModuleId}/riru_module.prop").renameTo("$zipPathMagiskRelease/data/misc/riru/modules/${riruModuleId}/module.prop")
|
||||
}
|
||||
}
|
||||
|
||||
def zipTask = task("zip${backendCapped}${variantCapped}", type: Zip) {
|
||||
dependsOn preZipTask
|
||||
dependsOn prepareMagiskFilesTask
|
||||
archiveName "magisk-${module_name}-${backend}-${project.version}-${variantLowered}.zip"
|
||||
destinationDir file("$projectDir/release")
|
||||
from "$zipPathMagiskRelease"
|
||||
|
|
|
|||
|
|
@ -1 +0,0 @@
|
|||
libs/** binary
|
||||
|
|
@ -1,3 +0,0 @@
|
|||
LOCAL_PATH := $(call my-dir)
|
||||
|
||||
include $(call all-makefiles-under, $(LOCAL_PATH))
|
||||
|
|
@ -1,22 +0,0 @@
|
|||
APP_ABI := arm64-v8a armeabi-v7a x86 x86_64
|
||||
APP_PLATFORM := android-23
|
||||
APP_CFLAGS := -std=gnu99
|
||||
APP_CPPFLAGS := -std=c++11
|
||||
APP_STL := c++_static
|
||||
APP_SHORT_COMMANDS := true
|
||||
|
||||
ifeq ($(NDK_DEBUG),1)
|
||||
$(info building DEBUG version...)
|
||||
APP_CFLAGS += -O0
|
||||
APP_CPPFLAGS += -O0
|
||||
else
|
||||
$(info building RELEASE version...)
|
||||
APP_CFLAGS += -fvisibility=hidden -fvisibility-inlines-hidden -O2
|
||||
APP_CPPFLAGS += -fvisibility=hidden -fvisibility-inlines-hidden -O2
|
||||
endif
|
||||
|
||||
# do not remove this, or your module will crash apps on Android Q
|
||||
SCS_FLAGS := -ffixed-x18
|
||||
APP_LDFLAGS += $(SCS_FLAGS)
|
||||
APP_CFLAGS += $(SCS_FLAGS)
|
||||
APP_CPPFLAGS += $(SCS_FLAGS)
|
||||
|
|
@ -1,16 +0,0 @@
|
|||
LOCAL_PATH := $(call my-dir)
|
||||
|
||||
include $(CLEAR_VARS)
|
||||
LOCAL_MODULE := xhook
|
||||
LOCAL_SRC_FILES := xhook/xhook.c \
|
||||
xhook/xh_core.c \
|
||||
xhook/xh_elf.c \
|
||||
xhook/xh_jni.c \
|
||||
xhook/xh_log.c \
|
||||
xhook/xh_util.c \
|
||||
xhook/xh_version.c
|
||||
LOCAL_C_INCLUDES := $(LOCAL_PATH)
|
||||
LOCAL_CFLAGS := -Wall -Wextra -Werror -fvisibility=hidden
|
||||
LOCAL_CONLYFLAGS := -std=c11
|
||||
LOCAL_LDLIBS := -llog
|
||||
include $(BUILD_STATIC_LIBRARY)
|
||||
|
|
@ -1,30 +0,0 @@
|
|||
LOCAL_PATH := $(call my-dir)
|
||||
include $(CLEAR_VARS)
|
||||
|
||||
LOCAL_MODULE := libriru_edxp
|
||||
LOCAL_C_INCLUDES := \
|
||||
$(LOCAL_PATH) \
|
||||
jni/external/include
|
||||
LOCAL_CPPFLAGS += $(CPPFLAGS)
|
||||
LOCAL_STATIC_LIBRARIES := xhook
|
||||
LOCAL_LDLIBS += -ldl -llog
|
||||
LOCAL_LDFLAGS := -Wl,--hash-style=both
|
||||
|
||||
LOCAL_SRC_FILES:= \
|
||||
main.cpp \
|
||||
native_hook/native_hook.cpp \
|
||||
native_hook/resource_hook.cpp \
|
||||
native_hook/riru_hook.cpp \
|
||||
include/misc.cpp \
|
||||
include/riru.c \
|
||||
yahfa/HookMain.c \
|
||||
yahfa/trampoline.c \
|
||||
java_hook/java_hook.cpp \
|
||||
inject/framework_hook.cpp \
|
||||
inject/config_manager.cpp \
|
||||
Substrate/SubstrateDebug.cpp \
|
||||
Substrate/SubstrateHook.cpp \
|
||||
Substrate/SubstratePosixMemory.cpp \
|
||||
Substrate/hde64.c \
|
||||
|
||||
include $(BUILD_SHARED_LIBRARY)
|
||||
|
|
@ -0,0 +1,6 @@
|
|||
cmake_minimum_required(VERSION 3.4.1)
|
||||
|
||||
link_libraries("-ffixed-x18")
|
||||
|
||||
add_subdirectory(main)
|
||||
add_subdirectory(external)
|
||||
|
|
@ -0,0 +1,6 @@
|
|||
cmake_minimum_required(VERSION 3.4.1)
|
||||
|
||||
add_subdirectory(xhook)
|
||||
add_subdirectory(riru)
|
||||
add_subdirectory(yahfa)
|
||||
add_subdirectory(substrate)
|
||||
|
|
@ -0,0 +1,6 @@
|
|||
cmake_minimum_required(VERSION 3.4.1)
|
||||
|
||||
aux_source_directory(src SRC_LIST)
|
||||
add_library(riru STATIC ${SRC_LIST})
|
||||
|
||||
target_include_directories(riru INTERFACE src)
|
||||
|
|
@ -0,0 +1,6 @@
|
|||
cmake_minimum_required(VERSION 3.4.1)
|
||||
|
||||
aux_source_directory(src SRC_LIST)
|
||||
add_library(substrate STATIC ${SRC_LIST})
|
||||
|
||||
target_include_directories(substrate INTERFACE src)
|
||||
|
|
@ -0,0 +1,10 @@
|
|||
cmake_minimum_required(VERSION 3.4.1)
|
||||
|
||||
SET(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -std=c11 -Wall -Wextra -Werror -fvisibility=hidden")
|
||||
|
||||
aux_source_directory(src SRC_LIST)
|
||||
add_library(xhook STATIC ${SRC_LIST})
|
||||
|
||||
find_library(log-lib log)
|
||||
target_link_libraries(xhook ${log-lib})
|
||||
target_include_directories(xhook INTERFACE include)
|
||||
|
|
@ -0,0 +1,10 @@
|
|||
cmake_minimum_required(VERSION 3.4.1)
|
||||
|
||||
SET(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -std=c11 -Wall -Wextra -fvisibility=hidden")
|
||||
|
||||
aux_source_directory(src SRC_LIST)
|
||||
add_library(yahfa STATIC ${SRC_LIST})
|
||||
|
||||
find_library(log-lib log)
|
||||
target_link_libraries(yahfa ${log-lib})
|
||||
target_include_directories(yahfa PUBLIC include)
|
||||
|
|
@ -0,0 +1,18 @@
|
|||
cmake_minimum_required(VERSION 3.4.1)
|
||||
|
||||
set(CMAKE_ANDROID_STL_TYPE c++_static)
|
||||
|
||||
set(SRC_LIST
|
||||
main.cpp
|
||||
native_hook/native_hook.cpp
|
||||
native_hook/resource_hook.cpp
|
||||
native_hook/riru_hook.cpp
|
||||
java_hook/java_hook.cpp
|
||||
inject/framework_hook.cpp
|
||||
inject/config_manager.cpp
|
||||
)
|
||||
include_directories(include .)
|
||||
add_library(riru_edxp SHARED ${SRC_LIST})
|
||||
|
||||
find_library(log-lib log)
|
||||
target_link_libraries(riru_edxp yahfa riru xhook substrate ${log-lib})
|
||||
|
|
@ -14,7 +14,7 @@
|
|||
|
||||
extern "C"
|
||||
{
|
||||
#include "../yahfa/HookMain.h"
|
||||
#include "HookMain.h"
|
||||
}
|
||||
|
||||
jobject gInjectDexClassLoader;
|
||||
|
|
@ -10,8 +10,8 @@
|
|||
#include <vector>
|
||||
#include <utility>
|
||||
#include <string>
|
||||
#include <inject/framework_hook.h>
|
||||
#include <native_hook/native_hook.h>
|
||||
#include "inject/framework_hook.h"
|
||||
#include "native_hook/native_hook.h"
|
||||
|
||||
#include "include/logging.h"
|
||||
#include "include/misc.h"
|
||||
|
|
@ -4,7 +4,7 @@
|
|||
#include <string>
|
||||
#include <vector>
|
||||
#include <inject/config_manager.h>
|
||||
#include <Substrate/SubstrateHook.h>
|
||||
#include <SubstrateHook.h>
|
||||
|
||||
#include "include/logging.h"
|
||||
#include "native_hook.h"
|
||||
|
|
@ -1,7 +1,7 @@
|
|||
#ifndef HOOK_H
|
||||
#define HOOK_H
|
||||
|
||||
#include <xhook/xhook.h>
|
||||
#include <xhook.h>
|
||||
|
||||
#if defined(__LP64__)
|
||||
static constexpr const char *kLibArtPath = "/system/lib64/libart.so";
|
||||
|
|
@ -4,8 +4,8 @@
|
|||
|
||||
#include <cstring>
|
||||
#include <string>
|
||||
#include <include/riru.h>
|
||||
#include <xhook/xhook.h>
|
||||
#include <riru.h>
|
||||
#include <xhook.h>
|
||||
#include <sys/system_properties.h>
|
||||
#include <include/logging.h>
|
||||
#include <include/android_build.h>
|
||||
Loading…
Reference in New Issue