2019-05-15 01:37:52 +02:00
|
|
|
TERMUX_PKG_HOMEPAGE=https://elinux.org/Android_aapt
|
2015-06-13 01:03:31 +02:00
|
|
|
TERMUX_PKG_DESCRIPTION="Android Asset Packaging Tool"
|
2019-01-20 22:39:59 +01:00
|
|
|
TERMUX_PKG_LICENSE="Apache-2.0"
|
2020-12-20 14:16:34 +01:00
|
|
|
TERMUX_PKG_MAINTAINER="@termux"
|
2022-02-05 06:17:26 +01:00
|
|
|
_TAG_VERSION=8.1.0
|
|
|
|
_TAG_REVISION=81
|
2016-09-10 17:01:10 +02:00
|
|
|
TERMUX_PKG_VERSION=${_TAG_VERSION}.${_TAG_REVISION}
|
2022-02-05 06:17:26 +01:00
|
|
|
TERMUX_PKG_SRCURL=(https://android.googlesource.com/platform/frameworks/base
|
|
|
|
https://android.googlesource.com/platform/system/core
|
|
|
|
https://android.googlesource.com/platform/build
|
|
|
|
https://android.googlesource.com/platform/external/safe-iop)
|
|
|
|
TERMUX_PKG_GIT_BRANCH=android-${_TAG_VERSION}_r${_TAG_REVISION}
|
|
|
|
TERMUX_PKG_SHA256=(SKIP_CHECKSUM
|
|
|
|
SKIP_CHECKSUM
|
|
|
|
SKIP_CHECKSUM
|
|
|
|
SKIP_CHECKSUM)
|
2019-08-14 13:27:16 +02:00
|
|
|
TERMUX_PKG_SKIP_SRC_EXTRACT=true
|
2019-08-12 17:28:41 +02:00
|
|
|
TERMUX_PKG_BUILD_IN_SRC=true
|
2019-06-19 20:12:28 +02:00
|
|
|
TERMUX_PKG_DEPENDS="libc++, libexpat, libpng, libzopfli, zlib"
|
2015-06-13 01:03:31 +02:00
|
|
|
|
2022-02-05 06:17:26 +01:00
|
|
|
termux_step_post_get_source() {
|
|
|
|
# FIXME: We would like to enable checksums when downloading
|
|
|
|
# tar files, but they change each time as the tar metadata
|
|
|
|
# differs: https://github.com/google/gitiles/issues/84
|
|
|
|
|
|
|
|
for i in $(seq 0 $(( ${#TERMUX_PKG_SRCURL[@]}-1 ))); do
|
|
|
|
git clone --depth 1 --single-branch \
|
|
|
|
--branch $TERMUX_PKG_GIT_BRANCH \
|
|
|
|
${TERMUX_PKG_SRCURL[$i]}
|
|
|
|
done
|
|
|
|
|
|
|
|
# Get zopfli source:
|
|
|
|
local ZOPFLI_VER=$(bash -c ". $TERMUX_SCRIPTDIR/packages/libzopfli/build.sh; echo \$TERMUX_PKG_VERSION")
|
|
|
|
local ZOPFLI_SHA256=$(bash -c ". $TERMUX_SCRIPTDIR/packages/libzopfli/build.sh; echo \$TERMUX_PKG_SHA256")
|
|
|
|
local ZOPFLI_TARFILE=$TERMUX_PKG_CACHEDIR/zopfli-${ZOPFLI_VER}.tar.gz
|
|
|
|
termux_download \
|
|
|
|
"https://github.com/google/zopfli/archive/zopfli-${ZOPFLI_VER}.tar.gz" \
|
|
|
|
$ZOPFLI_TARFILE \
|
|
|
|
$ZOPFLI_SHA256
|
|
|
|
tar xf $ZOPFLI_TARFILE
|
|
|
|
mv zopfli-zopfli-$ZOPFLI_VER zopfli
|
|
|
|
}
|
|
|
|
|
2019-08-08 14:25:54 +02:00
|
|
|
termux_step_pre_configure() {
|
|
|
|
# Certain packages are not safe to build on device because their
|
|
|
|
# build.sh script deletes specific files in $TERMUX_PREFIX.
|
2019-08-12 17:28:41 +02:00
|
|
|
if $TERMUX_ON_DEVICE_BUILD; then
|
2019-08-08 14:25:54 +02:00
|
|
|
termux_error_exit "Package '$TERMUX_PKG_NAME' is not safe for on-device builds."
|
|
|
|
fi
|
2022-02-02 21:40:04 +01:00
|
|
|
|
|
|
|
termux_setup_protobuf
|
2019-08-08 14:25:54 +02:00
|
|
|
|
2022-02-05 06:17:26 +01:00
|
|
|
CFLAGS+=" -fPIC"
|
|
|
|
CXXFLAGS+=" -fPIC"
|
2016-09-04 17:07:13 +02:00
|
|
|
|
2022-02-05 06:17:26 +01:00
|
|
|
_TMP_LIBDIR=$TERMUX_PKG_SRCDIR/_lib
|
|
|
|
rm -rf $_TMP_LIBDIR
|
|
|
|
mkdir -p $_TMP_LIBDIR
|
|
|
|
_TMP_BINDIR=$TERMUX_PKG_SRCDIR/_bin
|
|
|
|
rm -rf $_TMP_BINDIR
|
|
|
|
mkdir -p $_TMP_BINDIR
|
2016-09-04 17:07:13 +02:00
|
|
|
|
2022-02-05 06:17:26 +01:00
|
|
|
LDFLAGS+=" -L$_TMP_LIBDIR"
|
|
|
|
}
|
2016-09-04 17:07:13 +02:00
|
|
|
|
2022-02-05 06:17:26 +01:00
|
|
|
termux_step_make() {
|
|
|
|
. $TERMUX_PKG_BUILDER_DIR/sources.sh
|
2016-09-04 17:07:13 +02:00
|
|
|
|
2022-02-05 06:17:26 +01:00
|
|
|
local CORE_INCDIR=$TERMUX_PKG_SRCDIR/core/include
|
|
|
|
local LIBBASE_SRCDIR=$TERMUX_PKG_SRCDIR/core/base
|
|
|
|
local LIBCUTILS_SRCDIR=$TERMUX_PKG_SRCDIR/core/libcutils
|
|
|
|
local SAFE_IOP_SRCDIR=$TERMUX_PKG_SRCDIR/safe-iop
|
|
|
|
local LIBUTILS_SRCDIR=$TERMUX_PKG_SRCDIR/core/libutils
|
|
|
|
local LIBZIPARCHIVE_SRCDIR=$TERMUX_PKG_SRCDIR/core/libziparchive
|
|
|
|
local ANDROIDFW_SRCDIR=$TERMUX_PKG_SRCDIR/base/libs/androidfw
|
|
|
|
local AAPT_SRCDIR=$TERMUX_PKG_SRCDIR/base/tools/aapt
|
|
|
|
local AAPT2_SRCDIR=$TERMUX_PKG_SRCDIR/base/tools/aapt2
|
|
|
|
local ZIPALIGN_SRCDIR=$TERMUX_PKG_SRCDIR/build/tools/zipalign
|
2018-09-20 22:46:51 +02:00
|
|
|
|
2016-09-04 17:07:13 +02:00
|
|
|
# Build libcutils:
|
2022-02-05 06:17:26 +01:00
|
|
|
cd $LIBCUTILS_SRCDIR
|
|
|
|
local LIBCUTILS_CPPFLAGS="$CPPFLAGS \
|
|
|
|
-I. \
|
|
|
|
-I./include \
|
|
|
|
-I$CORE_INCDIR"
|
|
|
|
for f in $libcutils_sources_cpp; do
|
|
|
|
$CXX $CXXFLAGS $LIBCUTILS_CPPFLAGS $f -c
|
|
|
|
done
|
|
|
|
for f in $libcutils_sources_c; do
|
|
|
|
$CC $CFLAGS $LIBCUTILS_CPPFLAGS -Dchar16_t=uint16_t $f -c
|
|
|
|
done
|
|
|
|
$CC $CFLAGS *.o -shared $LDFLAGS \
|
2016-09-10 17:01:10 +02:00
|
|
|
-llog \
|
2022-02-05 06:17:26 +01:00
|
|
|
-o $_TMP_LIBDIR/libandroid-cutils.so
|
2016-09-04 17:07:13 +02:00
|
|
|
|
2022-02-05 06:17:26 +01:00
|
|
|
# Build libutils:
|
|
|
|
cd $LIBUTILS_SRCDIR
|
|
|
|
$CC $CFLAGS $CPPFLAGS -I$SAFE_IOP_SRCDIR/include \
|
|
|
|
$SAFE_IOP_SRCDIR/src/safe_iop.c -c -o safe_iop.o
|
|
|
|
local LIBUTILS_CPPFLAGS="$CPPFLAGS \
|
|
|
|
-I. \
|
|
|
|
-I$SAFE_IOP_SRCDIR/include \
|
|
|
|
-I$CORE_INCDIR"
|
|
|
|
for f in $libutils_sources; do
|
|
|
|
$CXX $CXXFLAGS $LIBUTILS_CPPFLAGS $f -c
|
|
|
|
done
|
|
|
|
$CXX $CXXFLAGS *.o -shared $LDFLAGS \
|
2016-09-04 17:07:13 +02:00
|
|
|
-landroid-cutils \
|
2016-09-10 17:01:10 +02:00
|
|
|
-llog \
|
2022-02-05 06:17:26 +01:00
|
|
|
-o $_TMP_LIBDIR/libandroid-utils.so
|
2016-09-04 17:07:13 +02:00
|
|
|
|
|
|
|
# Build libbase:
|
2022-02-05 06:17:26 +01:00
|
|
|
cd $LIBBASE_SRCDIR
|
|
|
|
local LIBBASE_CPPFLAGS="$CPPFLAGS \
|
|
|
|
-I./include \
|
|
|
|
-I$CORE_INCDIR"
|
|
|
|
for f in $libbase_sources; do
|
|
|
|
$CXX $CXXFLAGS $LIBBASE_CPPFLAGS $f -c
|
|
|
|
done
|
|
|
|
$CXX $CXXFLAGS *.o -shared $LDFLAGS \
|
2016-09-10 17:01:10 +02:00
|
|
|
-llog \
|
2022-02-05 06:17:26 +01:00
|
|
|
-o $_TMP_LIBDIR/libandroid-base.so
|
2016-09-04 17:07:13 +02:00
|
|
|
|
|
|
|
# Build libziparchive:
|
2022-02-05 06:17:26 +01:00
|
|
|
cd $LIBZIPARCHIVE_SRCDIR
|
|
|
|
local LIBZIPARCHIVE_CPPFLAGS="$CPPFLAGS \
|
|
|
|
-I./include \
|
|
|
|
-I$LIBBASE_SRCDIR/include \
|
|
|
|
-I$CORE_INCDIR"
|
|
|
|
for f in $libziparchive_sources; do
|
|
|
|
$CXX $CXXFLAGS $LIBZIPARCHIVE_CPPFLAGS $f -c
|
|
|
|
done
|
|
|
|
$CXX $CXXFLAGS *.o -shared $LDFLAGS \
|
2016-09-04 17:07:13 +02:00
|
|
|
-landroid-base \
|
2016-09-10 17:01:10 +02:00
|
|
|
-llog \
|
2022-02-05 06:17:26 +01:00
|
|
|
-o $_TMP_LIBDIR/libandroid-ziparchive.so
|
2016-09-04 17:07:13 +02:00
|
|
|
|
|
|
|
# Build libandroidfw:
|
2022-02-05 06:17:26 +01:00
|
|
|
cd $ANDROIDFW_SRCDIR
|
|
|
|
local ANDROIDFW_CPPFLAGS="$CPPFLAGS \
|
|
|
|
-I./include \
|
|
|
|
-I$LIBBASE_SRCDIR/include \
|
|
|
|
-I$LIBZIPARCHIVE_SRCDIR/include \
|
|
|
|
-I$CORE_INCDIR"
|
|
|
|
for f in $androidfw_sources; do
|
|
|
|
$CXX $CXXFLAGS $ANDROIDFW_CPPFLAGS $f -c
|
|
|
|
done
|
|
|
|
$CXX $CXXFLAGS *.o -shared $LDFLAGS \
|
|
|
|
-landroid-base \
|
2016-09-11 14:34:07 +02:00
|
|
|
-landroid-ziparchive \
|
|
|
|
-llog \
|
2022-02-05 06:17:26 +01:00
|
|
|
-o $_TMP_LIBDIR/libandroid-fw.so
|
2016-09-04 17:07:13 +02:00
|
|
|
|
|
|
|
# Build aapt:
|
2022-02-05 06:17:26 +01:00
|
|
|
cd $AAPT_SRCDIR
|
|
|
|
local AAPT_CPPFLAGS="$CPPFLAGS \
|
|
|
|
-I./include \
|
|
|
|
-I$LIBBASE_SRCDIR/include \
|
|
|
|
-I$ANDROIDFW_SRCDIR/include \
|
|
|
|
-I$CORE_INCDIR"
|
|
|
|
for f in *.cpp; do
|
|
|
|
$CXX $CXXFLAGS $AAPT_CPPFLAGS $f -c
|
|
|
|
done
|
|
|
|
$CXX $CXXFLAGS *.o $LDFLAGS \
|
|
|
|
-landroid-fw \
|
|
|
|
-landroid-utils \
|
2016-09-04 17:07:13 +02:00
|
|
|
-llog \
|
2022-02-05 06:17:26 +01:00
|
|
|
-lexpat \
|
|
|
|
-lpng \
|
|
|
|
-lz \
|
|
|
|
-o $_TMP_BINDIR/aapt
|
2016-09-04 17:07:13 +02:00
|
|
|
|
2022-02-02 21:40:04 +01:00
|
|
|
# Build aapt2:
|
2022-02-05 06:17:26 +01:00
|
|
|
cd $AAPT2_SRCDIR
|
|
|
|
local AAPT2_CPPFLAGS="$CPPFLAGS \
|
2022-02-02 21:40:04 +01:00
|
|
|
-I. \
|
2022-02-05 06:17:26 +01:00
|
|
|
-I./include \
|
|
|
|
-I$LIBBASE_SRCDIR/include \
|
|
|
|
-I$LIBZIPARCHIVE_SRCDIR/include \
|
|
|
|
-I$ANDROIDFW_SRCDIR/include \
|
|
|
|
-I$CORE_INCDIR"
|
|
|
|
for f in $libaapt2_sources_proto; do
|
|
|
|
protoc --cpp_out=. $f
|
|
|
|
done
|
|
|
|
for f in $aapt2_sources_cpp; do
|
|
|
|
$CXX $CXXFLAGS $AAPT2_CPPFLAGS $f -c -o ${f%.*}.o
|
|
|
|
done
|
|
|
|
$CXX $CXXFLAGS *.o */*.o $LDFLAGS \
|
2022-02-02 21:40:04 +01:00
|
|
|
-landroid-base \
|
|
|
|
-landroid-fw \
|
2022-02-05 06:17:26 +01:00
|
|
|
-landroid-utils \
|
2022-02-02 21:40:04 +01:00
|
|
|
-landroid-ziparchive \
|
|
|
|
-llog \
|
2022-02-05 06:17:26 +01:00
|
|
|
-lexpat \
|
|
|
|
-lpng \
|
2022-02-02 21:40:04 +01:00
|
|
|
-lprotobuf \
|
2022-02-05 06:17:26 +01:00
|
|
|
-o $_TMP_BINDIR/aapt2
|
2016-09-04 17:07:13 +02:00
|
|
|
|
|
|
|
# Build zipalign:
|
2022-02-05 06:17:26 +01:00
|
|
|
cd $ZIPALIGN_SRCDIR
|
|
|
|
local ZIPALIGN_CPPFLAGS="$CPPFLAGS \
|
|
|
|
-I$TERMUX_PKG_SRCDIR/zopfli/src \
|
|
|
|
-I$ANDROIDFW_SRCDIR/include \
|
|
|
|
-I$CORE_INCDIR"
|
|
|
|
for f in *.cpp; do
|
|
|
|
$CXX $CXXFLAGS $ZIPALIGN_CPPFLAGS $f -c
|
|
|
|
done
|
|
|
|
$CXX $CXXFLAGS *.o $LDFLAGS \
|
|
|
|
-landroid-fw \
|
|
|
|
-landroid-utils \
|
|
|
|
-llog \
|
2016-09-04 17:07:13 +02:00
|
|
|
-lzopfli \
|
2022-02-05 06:17:26 +01:00
|
|
|
-lz \
|
|
|
|
-o $_TMP_BINDIR/zipalign
|
|
|
|
}
|
2016-09-04 17:07:13 +02:00
|
|
|
|
2022-02-05 06:17:26 +01:00
|
|
|
termux_step_make_install() {
|
|
|
|
install -Dm600 -t $TERMUX_PREFIX/lib \
|
|
|
|
$_TMP_LIBDIR/libandroid-{cutils,utils,base,ziparchive,fw}.so
|
|
|
|
install -Dm700 -t $TERMUX_PREFIX/bin \
|
|
|
|
$_TMP_BINDIR/{aapt,aapt2,zipalign}
|
2016-10-07 21:36:03 +02:00
|
|
|
|
|
|
|
# Create an android.jar with AndroidManifest.xml and resources.arsc:
|
|
|
|
cd $TERMUX_PKG_TMPDIR
|
|
|
|
rm -rf android-jar
|
|
|
|
mkdir android-jar
|
|
|
|
cd android-jar
|
2019-01-27 09:02:45 +01:00
|
|
|
cp $ANDROID_HOME/platforms/android-28/android.jar .
|
2016-10-07 21:36:03 +02:00
|
|
|
unzip -q android.jar
|
|
|
|
mkdir -p $TERMUX_PREFIX/share/aapt
|
2017-11-21 05:26:30 +01:00
|
|
|
jar cfM $TERMUX_PREFIX/share/aapt/android.jar AndroidManifest.xml resources.arsc
|
2015-06-13 01:03:31 +02:00
|
|
|
}
|