From e4f3fb36f3ea0421aca1d1ff428ca2770ec439ea Mon Sep 17 00:00:00 2001 From: topjohnwu Date: Thu, 20 Apr 2017 05:07:52 +0800 Subject: [PATCH] Update build scripts --- build.cmd | 18 ++++++------------ build.sh | 23 +++++++++++++---------- 2 files changed, 19 insertions(+), 22 deletions(-) diff --git a/build.cmd b/build.cmd index d3a85c54a..5350d4ab6 100644 --- a/build.cmd +++ b/build.cmd @@ -31,16 +31,6 @@ EXIT /B %ERRORLEVEL% :all SET OK=y - IF [%~1] == [] ( - CALL :error "Missing version info" - CALL :usage - EXIT /B %ERRORLEVEL% - ) - IF [%~2] == [] ( - CALL :error "Missing version info" - CALL :usage - EXIT /B %ERRORLEVEL% - ) CALL :build "%~1" "%~2" CALL :zip "%~1" EXIT /B %ERRORLEVEL% @@ -48,7 +38,7 @@ EXIT /B %ERRORLEVEL% :debug SET OK=y SET DEBUG=-DDEBUG - CALL :build "VER_DEBUG" "99999" + CALL :build "%~1" "%~2" EXIT /B %ERRORLEVEL% :build @@ -63,8 +53,12 @@ EXIT /B %ERRORLEVEL% CALL :usage EXIT /B %ERRORLEVEL% ) + SET BUILD=Build + IF NOT [%DEBUG%] == [] ( + SET BUILD=Debug + ) ECHO ************************ - ECHO * Building: VERSION=%~1 CODE=%~2 + ECHO * %BUILD%: VERSION=%~1 CODE=%~2 ECHO ************************ FOR /F "tokens=* USEBACKQ" %%F IN (`where ndk-build`) DO ( IF [%%F] == [] ( diff --git a/build.sh b/build.sh index 19ab723f6..b9c4c4c38 100755 --- a/build.sh +++ b/build.sh @@ -1,18 +1,18 @@ #!/bin/bash usage() { - echo "$0 all " + echo "$ME all " echo -e "\tBuild binaries, zip, and sign Magisk" echo -e "\tThis is equlivant to first , then " - echo "$0 clean" + echo "$ME clean" echo -e "\tCleanup compiled / generated files" - echo "$0 build " + echo "$ME build " echo -e "\tBuild the binaries with ndk" - echo "$0 debug" + echo "$ME debug " echo -e "\tBuild the binaries with the debug flag on\n\tCall afterwards if you want to flash on device" - echo "$0 zip " + echo "$ME zip " echo -e "\tZip and sign Magisk" - echo "$0 uninstaller" + echo "$ME uninstaller" echo -e "\tZip and sign the uninstaller" exit 1 } @@ -49,8 +49,11 @@ error() { } build_bin() { + [ -z "$1" -o -z "$2" ] && echo -e "! Missing version info\n" && usage + BUILD="Build" + [ -z "DEBUG" ] || BUILD="Debug" echo "************************" - echo "* Building: VERSION=$1 CODE=$2" + echo "* $BUILD: VERSION=$1 CODE=$2" echo "************************" [ -z `which ndk-build` ] && error "Please add ndk-build to PATH!" ndk-build APP_CFLAGS="-DMAGISK_VERSION=$1 -DMAGISK_VER_CODE=$2 $DEBUG" -j${CPUNUM} || error "Magisk binary tools build failed...." @@ -72,6 +75,7 @@ build_bin() { } zip_package() { + [ -z "$1" ] && echo -e "! Missing version info\n" && usage [ ! -f "zip_static/arm/magiskboot" ] && error "Missing binaries!! Please run '$0 build' before zipping" echo "************************" echo "* Adding version info" @@ -154,10 +158,10 @@ DIR="$(cd "$(dirname "$0")"; pwd)" cd "$DIR" DEBUG= CPUNUM=`getconf _NPROCESSORS_ONLN` +ME=$0 case $1 in "all" ) - [ -z "$2" -o -z "$3" ] && echo -e "! Missing version info\n" && usage build_bin $2 $3 zip_package $2 ;; @@ -165,12 +169,11 @@ case $1 in cleanup ;; "build" ) - [ -z "$2" -o -z "$3" ] && echo -e "! Missing version info\n" && usage build_bin $2 $3 ;; "debug" ) DEBUG="-DDEBUG" - build_bin "VER_DEBUG" "99999" + build_bin $2 $3 ;; "zip" ) [ -z "$2" ] && echo -e "! Missing version info\n" && usage