|
1 |
| -#!/data/data/com.termux/files/usr/bin/env bash |
| 1 | +#!/data/data/com.termux/files/usr/bin/bash |
2 | 2 | # File : build.sh
|
3 | 3 | # Author : rendiix <vanzdobz@gmail.com>
|
4 |
| -# Create date: 28-Jun-2019 19:10 |
5 |
| -# package/lolcat/build.sh |
6 |
| -# Copyright (c) 2019 rendiix <vanzdobz@gmail.com> |
7 |
| -# |
8 |
| -# DO WHAT THE FUCK YOU WANT TO PUBLIC LICENSE |
9 |
| -# Version 2, December 2004 |
10 |
| -# |
11 |
| -# Everyone is permitted to copy and distribute verbatim or |
12 |
| -# modified copies of this license document,and changing it |
13 |
| -# is allowed as long as the name is changed. |
14 |
| -# |
15 |
| -# DO WHAT THE FUCK YOU WANT TO PUBLIC LICENSE |
16 |
| -# TERMS AND CONDITIONS FOR COPYING, |
17 |
| -# DISTRIBUTION AND MODIFICATION |
18 |
| -# |
19 |
| -# 0. You just DO WHAT THE FUCK YOU WANT TO. |
20 |
| - |
21 |
| -VAR_PKG_NAME="ext4fs-tools" |
22 |
| -VAR_PKG_VERSION="8.1.0" |
23 |
| -VAR_PKG_URL="https://github.com/rendiix/make_ext4fs/archive/8.1.0.tar.gz" |
24 |
| -VAR_PKG_DEPEND="" |
25 |
| -VAR_PKG_HOMEPAGE="https://github.com/rendiix/make_ext4fs" |
26 |
| -VAR_PKG_DESCRIPTION="Android img tools: make_ext4fs img2simg simg2img sefcontext_decompile." |
27 |
| -VAR_ABI="arm aarch64" |
28 |
| - |
29 |
| -function BUILD_PACKAGE() { |
30 |
| - cd $SOURCE_DIR |
31 |
| - if [ "$BUILD_ARCH" = "aarch64" ]; then |
32 |
| - lib_dir=libs/arm64-v8a |
33 |
| - target=arm64 |
| 4 | +# Create date: 4-Jul-2019 09:51 |
| 5 | + |
| 6 | +if [[ $(which ndk-build) != "" ]]; then |
| 7 | + NDK=$(which ndk-build) |
34 | 8 | else
|
35 |
| - lib_dir=libs/armeabi-v7a |
36 |
| - target=arm |
| 9 | + echo -e "$1: Could not find Android NDK directory !\nMake sure you have installed android NDK!" |
| 10 | + exit 1 |
| 11 | + fi |
| 12 | + |
| 13 | +function build() { |
| 14 | + JOBS=$(grep -c ^processor /proc/cpuinfo) |
| 15 | + if [ "$OPT_DEBUG" = "true" ]; then |
| 16 | + DEBUGFLAGS="NDK_DEBUG=1 APP_OPTIM=debug" |
| 17 | + fi |
| 18 | +TOOLCHAINS=${COMPILER} BUILD=${OPT_TARGET_ARCH} STATIC=${OPT_STATIC} $NDK ${DEBUGFLAGS} V=${OPT_VERBOSE} -j${JOBS} |
| 19 | + |
| 20 | +if [ "$?" = 0 ]; then |
| 21 | + find libs -mindepth 1 -maxdepth 1 -type d | while read -r meki |
| 22 | +do |
| 23 | + DIR_ABI=$(basename "$meki") |
| 24 | + if [ ! -d "bin" ]; then |
| 25 | + mkdir bin |
37 | 26 | fi
|
38 |
| - bash ./build.sh -t $target -n |
39 |
| - mkdir -p ${PKG_PREFIX}/usr/bin |
40 |
| - mv $lib_dir/* ${PKG_PREFIX}/usr/bin/ |
41 |
| - rm -rf libs obj |
| 27 | + if [ "$OPT_NO_COPY" = "0" ]; then |
| 28 | + for binary in "make_ext4fs" "img2simg" "simg2img" "sefcontext_decompile"; do |
| 29 | + cp -f "libs/${DIR_ABI}/${binary}" "bin/${binary}_android_${DIR_ABI}" |
| 30 | + done |
| 31 | + rm -rf libs |
| 32 | + fi |
| 33 | +done |
| 34 | +fi |
| 35 | +rm -rf obj |
42 | 36 | }
|
| 37 | + |
| 38 | +function HELP() { |
| 39 | +echo -e "Usage $0 <options> |
| 40 | +
|
| 41 | +Options: |
| 42 | + -t, --target <arm|arm64|x86|x86_64> |
| 43 | + build single target executable i.e: <arm|aarch64|x86|x86_64>. |
| 44 | + -c, --compiler <clang|gcc> |
| 45 | + select compiler gcc or clang. |
| 46 | + -s, --static compile static executable binary. |
| 47 | + -n, --no-copy dont copy compiled binary to bin folder. |
| 48 | + -d, --debug compile with debugable binary. |
| 49 | + -v, --verbose verbose compilation. |
| 50 | + -h, --help show this help message and exit. |
| 51 | + -q, --quiet build with silent stdout" |
| 52 | +} |
| 53 | + |
| 54 | +OPTS=`busybox getopt -o t:c:vsndhq \ |
| 55 | + --long target:,compiler:verbose,static,no-copy,debug,quiet,help \ |
| 56 | + -n "$0" -- "$@"` |
| 57 | + |
| 58 | +if [ "$?" -ne "0" ]; then |
| 59 | + HELP |
| 60 | + exit 1 |
| 61 | +fi |
| 62 | +eval set -- "$OPTS" |
| 63 | + |
| 64 | +OPT_DEBUG="0" |
| 65 | +OPT_TARGET_ARCH="all" |
| 66 | +OPT_VERBOSE="0" |
| 67 | +OPT_STATIC="0" |
| 68 | +OPT_HELP="false" |
| 69 | +OPT_QUIET="0" |
| 70 | +OPT_NO_COPY="0" |
| 71 | +COMPILER=clang |
| 72 | + |
| 73 | +if [ -z "$1" ]; then |
| 74 | + echo -e "No options was given, building with default options. |
| 75 | +To see more options: |
| 76 | + $0 --help\n" |
| 77 | + fi |
| 78 | + |
| 79 | +while true; do |
| 80 | + case "$1" in |
| 81 | + -t | --target ) OPT_TARGET_ARCH="$2"; shift;; |
| 82 | + -c | --compiler ) |
| 83 | + if [[ "$2" -ne "clang" || "$2" -ne "gcc" ]]; then |
| 84 | + echo "$2 is not valid compiler, use gcc or clang" |
| 85 | + HELP |
| 86 | + exit 1 |
| 87 | + fi |
| 88 | + COMPILER="$2"; shift;; |
| 89 | + -h | --help ) OPT_HELP=true;; |
| 90 | + -d | --debug ) OPT_DEBUG=true;; |
| 91 | + -v | --verbose ) OPT_VERBOSE=1;; |
| 92 | + -n | --no-copy ) OPT_NO_COPY=1;; |
| 93 | + -s | --static ) OPT_STATIC=1;; |
| 94 | + -q | --quiet ) OPT_QUIET=1;; |
| 95 | + -- ) shift; break ;; |
| 96 | + *) break ;; |
| 97 | + esac |
| 98 | + shift |
| 99 | +done |
| 100 | + |
| 101 | +function info() { |
| 102 | + echo -e "\nBuild start with cofiguration:\n" |
| 103 | + echo -e "BUILD TARGET ARCH: $OPT_TARGET_ARCH" |
| 104 | + echo -e "EXE TYPE : $(if [ "$OPT_STATIC" = 1 ]; then echo STATIC; else echo SHARED;fi)" |
| 105 | + echo -e "VERBOSE : $(if [ "$OPT_VERBOSE" = 1 ]; then echo YES; else echo NO;fi)" |
| 106 | + echo -e "BUILD TYPE : $(if [ "$OPT_DEBUG" = 1 ]; then echo DEBUG; else echo RELEASE;fi)" |
| 107 | + echo -e "COMPILER : $COMPILER" |
| 108 | + echo -e "\n$0 --help\nto show more options" |
| 109 | + sleep 2 |
| 110 | + echo -e "\nPlease wait... \c" |
| 111 | + } |
| 112 | + |
| 113 | +case "$OPT_TARGET_ARCH" in |
| 114 | + arm|arm64|x86|x86_64|all);; |
| 115 | + *) |
| 116 | + echo "unknown arch $OPT_TARGET_ARCH"; |
| 117 | + exit 1 ;; |
| 118 | + esac |
| 119 | + |
| 120 | +if [ "$OPT_HELP" = "true" ]; then |
| 121 | + HELP; |
| 122 | + exit 1 |
| 123 | +fi |
| 124 | + |
| 125 | +if [ "$OPT_QUIET" = 0 ]; then |
| 126 | + info |
| 127 | + build |
| 128 | +else |
| 129 | + info |
| 130 | + build &>/dev/null |
| 131 | +fi |
| 132 | +if [ "$?" = 0 ]; then |
| 133 | + echo "done" |
| 134 | +else |
| 135 | + echo "someting went wrong!" |
| 136 | +fi |
0 commit comments