From 4fc020501d12f43b880966047c1966dd25384c69 Mon Sep 17 00:00:00 2001 From: solohsu Date: Tue, 22 Jan 2019 20:06:37 +0800 Subject: [PATCH] Support arch x86 and x86_64 --- .../.gitattributes => .gitattributes | 6 ++++- Core/build.gradle | 6 ++--- Core/jni/Application.mk | 2 +- Core/template_override/config.sh | 27 +++++++++++++------ build.sh | 8 +++++- 5 files changed, 35 insertions(+), 14 deletions(-) rename Core/template_override/.gitattributes => .gitattributes (65%) diff --git a/Core/template_override/.gitattributes b/.gitattributes similarity index 65% rename from Core/template_override/.gitattributes rename to .gitattributes index 8980df1a..30bc3e75 100644 --- a/Core/template_override/.gitattributes +++ b/.gitattributes @@ -1,3 +1,6 @@ +# Set the default behavior, in case people don't have core.autocrlf set. +* text=auto + # Declare files that will always have LF line endings on checkout. META-INF/** text eol=lf *.prop text eol=lf @@ -5,4 +8,5 @@ META-INF/** text eol=lf *.md text eol=lf # Denote all files that are truly binary and should not be modified. -system/** binary +*.so binary +*.dex binary diff --git a/Core/build.gradle b/Core/build.gradle index 02aa1280..e2851af8 100644 --- a/Core/build.gradle +++ b/Core/build.gradle @@ -9,7 +9,7 @@ android { externalNativeBuild { ndkBuild { - abiFilters 'arm64-v8a', 'armeabi-v7a' + abiFilters 'arm64-v8a', 'armeabi-v7a', 'x86', 'x86_64' arguments "NDK_PROJECT_PATH=jni/" } } @@ -35,7 +35,7 @@ afterEvaluate { } // def renameTask = task("build${nameCapped}", type: Copy) { -// from "release/magisk-${project.name}-arm-arm64-${project.version}.zip" +// from "release/magisk-${project.name}-${project.version}.zip" // into "release" // rename("${project.name}", "${project.extensions['module_name']}") // rename("${project.version}", "${project.version}-${nameLowered}") @@ -44,7 +44,7 @@ afterEvaluate { def pushTask = task("push${nameCapped}", type: Exec) { workingDir 'release' commandLine 'cmd', '/c', - "adb push magisk-${project.extensions['module_name']}-arm-arm64" + + "adb push magisk-${project.extensions['module_name']}" + "-${project.version}-${nameLowered}.zip /sdcard/" } diff --git a/Core/jni/Application.mk b/Core/jni/Application.mk index 7db84585..0b93aa0d 100644 --- a/Core/jni/Application.mk +++ b/Core/jni/Application.mk @@ -1,4 +1,4 @@ -APP_ABI := arm64-v8a armeabi-v7a# x86 x86_64 +APP_ABI := arm64-v8a armeabi-v7a x86 x86_64 APP_PLATFORM := android-23 APP_CFLAGS := -std=gnu99 APP_CPPFLAGS := -std=c++11 diff --git a/Core/template_override/config.sh b/Core/template_override/config.sh index 02c047cc..7e01d078 100644 --- a/Core/template_override/config.sh +++ b/Core/template_override/config.sh @@ -102,7 +102,7 @@ fail() { } check_architecture() { - if [[ "$ARCH" != "arm" && "$ARCH" != "arm64" ]]; then + if [[ "$ARCH" != "arm" && "$ARCH" != "arm64" && "$ARCH" != "x86" && "$ARCH" != "x64" ]]; then ui_print "- Unsupported platform: $ARCH" exit 1 else @@ -111,21 +111,32 @@ check_architecture() { } copy_files() { - if [ $IS64BIT = false ]; then - ui_print "- Removing unnecessary files" - rm -rf "$MODPATH/system/lib64" + if [[ "$ARCH" == "x86" || "$ARCH" == "x64" ]]; then + ui_print "- Removing arm/arm64 libraries" + rm -rf "$MODPATH/system/lib" + rm -rf "$MODPATH/system/lib64" + mv "$MODPATH/system_x86/lib" "$MODPATH/system/lib" + mv "$MODPATH/system_x86/lib64" "$MODPATH/system/lib64" + else + ui_print "- Removing x86/x64 libraries" + fi + rm -rf "$MODPATH/system_x86" + + if [[ "$IS64BIT" = false ]]; then + ui_print "- Removing 64-bit libraries" + rm -rf "$MODPATH/system/lib64" fi ui_print "- Extracting extra files" - unzip -o "$ZIP" 'data/*' -d $MODPATH >&2 + unzip -o "$ZIP" 'data/*' -d "$MODPATH" >&2 TARGET="/data/misc/riru/modules" # TODO: do not overwrite if file exists - [ -d $TARGET ] || mkdir -p $TARGET || fail "- Can't mkdir -p $TARGET" + [[ -d "$TARGET" ]] || mkdir -p "$TARGET" || fail "- Can't mkdir -p $TARGET" cp -af "$MODPATH$TARGET/." "$TARGET" || fail "- Can't cp -af $MODPATH$TARGET/. $TARGET" - - rm -rf $MODPATH/data 2>/dev/null + + rm -rf "$MODPATH/data" 2>/dev/null ui_print "- Files copied" } \ No newline at end of file diff --git a/build.sh b/build.sh index 6cbaed67..040ae7f9 100644 --- a/build.sh +++ b/build.sh @@ -39,6 +39,8 @@ if [ -f elf-cleaner.sh ]; then source elf-cleaner.sh run_elf_cleaner $LIBS_OUTPUT/arm64-v8a run_elf_cleaner $LIBS_OUTPUT/armeabi-v7a + run_elf_cleaner $LIBS_OUTPUT/x86 + run_elf_cleaner $LIBS_OUTPUT/x86-64 fi # create tmp dir @@ -51,8 +53,12 @@ mkdir -p $TMP_DIR # copy files mkdir -p $TMP_DIR_MAGISK/system/lib64 mkdir -p $TMP_DIR_MAGISK/system/lib +mkdir -p $TMP_DIR_MAGISK/system_x86/lib64 +mkdir -p $TMP_DIR_MAGISK/system_x86/lib cp -a $LIBS_OUTPUT/arm64-v8a/. $TMP_DIR_MAGISK/system/lib64 cp -a $LIBS_OUTPUT/armeabi-v7a/. $TMP_DIR_MAGISK/system/lib +[[ -d $LIBS_OUTPUT/x86_64 ]] && cp -a $LIBS_OUTPUT/x86_64/. $TMP_DIR_MAGISK/system_x86/lib64 +[[ -d $LIBS_OUTPUT/x86 ]] && cp -a $LIBS_OUTPUT/x86/. $TMP_DIR_MAGISK/system_x86/lib # run custom script if [ -f $MODULE_NAME/build-module.sh ]; then @@ -62,7 +68,7 @@ fi # zip mkdir -p $MODULE_NAME/release -ZIP_NAME=magisk-$ZIP_NAME_PREFIX-arm-arm64-"$VERSION".zip +ZIP_NAME=magisk-$ZIP_NAME_PREFIX-"$VERSION".zip rm -f $MODULE_NAME/release/$ZIP_NAME rm -f $TMP_DIR_MAGISK/$ZIP_NAME (cd $TMP_DIR_MAGISK; zip -r $ZIP_NAME * > /dev/null)