Skip to content

Commit

Permalink
minor update
Browse files Browse the repository at this point in the history
  • Loading branch information
rendiix committed Dec 16, 2019
1 parent 462c9ab commit d4e20dd
Showing 1 changed file with 131 additions and 37 deletions.
168 changes: 131 additions & 37 deletions build.sh
Original file line number Diff line number Diff line change
@@ -1,42 +1,136 @@
#!/data/data/com.termux/files/usr/bin/env bash
#!/data/data/com.termux/files/usr/bin/bash
# File : build.sh
# Author : rendiix <vanzdobz@gmail.com>
# Create date: 28-Jun-2019 19:10
# package/lolcat/build.sh
# Copyright (c) 2019 rendiix <vanzdobz@gmail.com>
#
# DO WHAT THE FUCK YOU WANT TO PUBLIC LICENSE
# Version 2, December 2004
#
# Everyone is permitted to copy and distribute verbatim or
# modified copies of this license document,and changing it
# is allowed as long as the name is changed.
#
# DO WHAT THE FUCK YOU WANT TO PUBLIC LICENSE
# TERMS AND CONDITIONS FOR COPYING,
# DISTRIBUTION AND MODIFICATION
#
# 0. You just DO WHAT THE FUCK YOU WANT TO.

VAR_PKG_NAME="ext4fs-tools"
VAR_PKG_VERSION="8.1.0"
VAR_PKG_URL="https://github.com/rendiix/make_ext4fs/archive/8.1.0.tar.gz"
VAR_PKG_DEPEND=""
VAR_PKG_HOMEPAGE="https://github.com/rendiix/make_ext4fs"
VAR_PKG_DESCRIPTION="Android img tools: make_ext4fs img2simg simg2img sefcontext_decompile."
VAR_ABI="arm aarch64"

function BUILD_PACKAGE() {
cd $SOURCE_DIR
if [ "$BUILD_ARCH" = "aarch64" ]; then
lib_dir=libs/arm64-v8a
target=arm64
# Create date: 4-Jul-2019 09:51

if [[ $(which ndk-build) != "" ]]; then
NDK=$(which ndk-build)
else
lib_dir=libs/armeabi-v7a
target=arm
echo -e "$1: Could not find Android NDK directory !\nMake sure you have installed android NDK!"
exit 1
fi

function build() {
JOBS=$(grep -c ^processor /proc/cpuinfo)
if [ "$OPT_DEBUG" = "true" ]; then
DEBUGFLAGS="NDK_DEBUG=1 APP_OPTIM=debug"
fi
TOOLCHAINS=${COMPILER} BUILD=${OPT_TARGET_ARCH} STATIC=${OPT_STATIC} $NDK ${DEBUGFLAGS} V=${OPT_VERBOSE} -j${JOBS}

if [ "$?" = 0 ]; then
find libs -mindepth 1 -maxdepth 1 -type d | while read -r meki
do
DIR_ABI=$(basename "$meki")
if [ ! -d "bin" ]; then
mkdir bin
fi
bash ./build.sh -t $target -n
mkdir -p ${PKG_PREFIX}/usr/bin
mv $lib_dir/* ${PKG_PREFIX}/usr/bin/
rm -rf libs obj
if [ "$OPT_NO_COPY" = "0" ]; then
for binary in "make_ext4fs" "img2simg" "simg2img" "sefcontext_decompile"; do
cp -f "libs/${DIR_ABI}/${binary}" "bin/${binary}_android_${DIR_ABI}"
done
rm -rf libs
fi
done
fi
rm -rf obj
}

function HELP() {
echo -e "Usage $0 <options>
Options:
-t, --target <arm|arm64|x86|x86_64>
build single target executable i.e: <arm|aarch64|x86|x86_64>.
-c, --compiler <clang|gcc>
select compiler gcc or clang.
-s, --static compile static executable binary.
-n, --no-copy dont copy compiled binary to bin folder.
-d, --debug compile with debugable binary.
-v, --verbose verbose compilation.
-h, --help show this help message and exit.
-q, --quiet build with silent stdout"
}

OPTS=`busybox getopt -o t:c:vsndhq \
--long target:,compiler:verbose,static,no-copy,debug,quiet,help \
-n "$0" -- "$@"`

if [ "$?" -ne "0" ]; then
HELP
exit 1
fi
eval set -- "$OPTS"

OPT_DEBUG="0"
OPT_TARGET_ARCH="all"
OPT_VERBOSE="0"
OPT_STATIC="0"
OPT_HELP="false"
OPT_QUIET="0"
OPT_NO_COPY="0"
COMPILER=clang

if [ -z "$1" ]; then
echo -e "No options was given, building with default options.
To see more options:
$0 --help\n"
fi

while true; do
case "$1" in
-t | --target ) OPT_TARGET_ARCH="$2"; shift;;
-c | --compiler )
if [[ "$2" -ne "clang" || "$2" -ne "gcc" ]]; then
echo "$2 is not valid compiler, use gcc or clang"
HELP
exit 1
fi
COMPILER="$2"; shift;;
-h | --help ) OPT_HELP=true;;
-d | --debug ) OPT_DEBUG=true;;
-v | --verbose ) OPT_VERBOSE=1;;
-n | --no-copy ) OPT_NO_COPY=1;;
-s | --static ) OPT_STATIC=1;;
-q | --quiet ) OPT_QUIET=1;;
-- ) shift; break ;;
*) break ;;
esac
shift
done

function info() {
echo -e "\nBuild start with cofiguration:\n"
echo -e "BUILD TARGET ARCH: $OPT_TARGET_ARCH"
echo -e "EXE TYPE : $(if [ "$OPT_STATIC" = 1 ]; then echo STATIC; else echo SHARED;fi)"
echo -e "VERBOSE : $(if [ "$OPT_VERBOSE" = 1 ]; then echo YES; else echo NO;fi)"
echo -e "BUILD TYPE : $(if [ "$OPT_DEBUG" = 1 ]; then echo DEBUG; else echo RELEASE;fi)"
echo -e "COMPILER : $COMPILER"
echo -e "\n$0 --help\nto show more options"
sleep 2
echo -e "\nPlease wait... \c"
}

case "$OPT_TARGET_ARCH" in
arm|arm64|x86|x86_64|all);;
*)
echo "unknown arch $OPT_TARGET_ARCH";
exit 1 ;;
esac

if [ "$OPT_HELP" = "true" ]; then
HELP;
exit 1
fi

if [ "$OPT_QUIET" = 0 ]; then
info
build
else
info
build &>/dev/null
fi
if [ "$?" = 0 ]; then
echo "done"
else
echo "someting went wrong!"
fi

0 comments on commit d4e20dd

Please sign in to comment.