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-06 13:20:18 +01:00
|
|
|
_TAG_VERSION=11.0.0
|
|
|
|
_TAG_REVISION=48
|
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
|
2022-02-05 09:38:29 +01:00
|
|
|
https://android.googlesource.com/platform/system/tools/aidl)
|
2022-02-05 06:17:26 +01:00
|
|
|
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"
|
2022-02-05 09:38:29 +01:00
|
|
|
TERMUX_PKG_HOSTBUILD=true
|
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
|
|
|
|
|
2022-02-06 13:20:18 +01:00
|
|
|
for f in base/tools/aapt2/*.proto; do
|
|
|
|
sed -i 's:frameworks/base/tools/aapt2/::' $f
|
|
|
|
done
|
|
|
|
|
2022-02-05 06:17:26 +01:00
|
|
|
# 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
|
|
|
|
}
|
|
|
|
|
2022-02-05 09:38:29 +01:00
|
|
|
termux_step_host_build() {
|
|
|
|
_PREFIX_FOR_BUILD=$TERMUX_PKG_HOSTBUILD_DIR/_prefix
|
|
|
|
|
|
|
|
# Need bison that understands --header=[FILE] option.
|
|
|
|
local BISON_BUILD_SH=$TERMUX_SCRIPTDIR/packages/bison/build.sh
|
|
|
|
local BISON_SRCURL=$(bash -c ". $BISON_BUILD_SH; echo \$TERMUX_PKG_SRCURL")
|
|
|
|
local BISON_SHA256=$(bash -c ". $BISON_BUILD_SH; echo \$TERMUX_PKG_SHA256")
|
|
|
|
local BISON_TARFILE=$TERMUX_PKG_CACHEDIR/$(basename $BISON_SRCURL)
|
|
|
|
termux_download $BISON_SRCURL $BISON_TARFILE $BISON_SHA256
|
|
|
|
mkdir -p bison
|
|
|
|
cd bison
|
|
|
|
tar xf $BISON_TARFILE --strip-components=1
|
|
|
|
./configure --prefix=$_PREFIX_FOR_BUILD
|
|
|
|
make -j $TERMUX_MAKE_PROCESSES
|
|
|
|
make install
|
|
|
|
}
|
|
|
|
|
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 09:38:29 +01:00
|
|
|
export PATH=$_PREFIX_FOR_BUILD/bin:$PATH
|
|
|
|
|
2022-02-05 06:17:26 +01:00
|
|
|
CFLAGS+=" -fPIC"
|
2022-02-06 13:20:18 +01:00
|
|
|
CXXFLAGS+=" -fPIC -std=c++17"
|
|
|
|
CPPFLAGS+=" -D__ANDROID_SDK_VERSION__=__ANDROID_API__"
|
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-06 13:20:18 +01:00
|
|
|
LDFLAGS+=" -llog -L$_TMP_LIBDIR"
|
2022-02-05 06:17:26 +01:00
|
|
|
}
|
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 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
|
2022-02-06 13:20:18 +01:00
|
|
|
local LIBIDMAP2_POLICIES_INCDIR=$TERMUX_PKG_SRCDIR/base/cmds/idmap2/libidmap2_policies/include
|
2022-02-05 06:17:26 +01:00
|
|
|
local AAPT2_SRCDIR=$TERMUX_PKG_SRCDIR/base/tools/aapt2
|
|
|
|
local ZIPALIGN_SRCDIR=$TERMUX_PKG_SRCDIR/build/tools/zipalign
|
2022-02-05 09:38:29 +01:00
|
|
|
local AIDL_SRCDIR=$TERMUX_PKG_SRCDIR/aidl
|
2018-09-20 22:46:51 +02:00
|
|
|
|
2022-02-06 13:20:18 +01:00
|
|
|
CPPFLAGS+=" -I. -I./include -I$LIBBASE_SRCDIR/include -I$CORE_INCDIR"
|
|
|
|
|
2016-09-04 17:07:13 +02:00
|
|
|
# Build libcutils:
|
2022-02-05 06:17:26 +01:00
|
|
|
cd $LIBCUTILS_SRCDIR
|
2022-02-06 13:20:18 +01:00
|
|
|
for f in $libcutils_sources; do
|
|
|
|
$CXX $CXXFLAGS $CPPFLAGS $f -c
|
2022-02-05 06:17:26 +01:00
|
|
|
done
|
|
|
|
$CC $CFLAGS *.o -shared $LDFLAGS \
|
|
|
|
-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
|
|
|
|
for f in $libutils_sources; do
|
2022-02-06 13:20:18 +01:00
|
|
|
$CXX $CXXFLAGS $CPPFLAGS $f -c
|
2022-02-05 06:17:26 +01:00
|
|
|
done
|
|
|
|
$CXX $CXXFLAGS *.o -shared $LDFLAGS \
|
2016-09-04 17:07:13 +02:00
|
|
|
-landroid-cutils \
|
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
|
|
|
|
for f in $libbase_sources; do
|
2022-02-06 13:20:18 +01:00
|
|
|
$CXX $CXXFLAGS $CPPFLAGS $f -c
|
2022-02-05 06:17:26 +01:00
|
|
|
done
|
|
|
|
$CXX $CXXFLAGS *.o -shared $LDFLAGS \
|
|
|
|
-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
|
|
|
|
for f in $libziparchive_sources; do
|
2022-02-06 13:20:18 +01:00
|
|
|
$CXX $CXXFLAGS $CPPFLAGS $f -c
|
2022-02-05 06:17:26 +01:00
|
|
|
done
|
|
|
|
$CXX $CXXFLAGS *.o -shared $LDFLAGS \
|
2016-09-04 17:07:13 +02:00
|
|
|
-landroid-base \
|
2022-02-06 13:20:18 +01:00
|
|
|
-lz \
|
2022-02-05 06:17:26 +01:00
|
|
|
-o $_TMP_LIBDIR/libandroid-ziparchive.so
|
2016-09-04 17:07:13 +02:00
|
|
|
|
2022-02-06 13:20:18 +01:00
|
|
|
CPPFLAGS+=" -I$LIBZIPARCHIVE_SRCDIR/include"
|
|
|
|
|
2016-09-04 17:07:13 +02:00
|
|
|
# Build libandroidfw:
|
2022-02-05 06:17:26 +01:00
|
|
|
cd $ANDROIDFW_SRCDIR
|
|
|
|
for f in $androidfw_sources; do
|
2022-02-06 13:20:18 +01:00
|
|
|
$CXX $CXXFLAGS $CPPFLAGS $f -c
|
2022-02-05 06:17:26 +01:00
|
|
|
done
|
|
|
|
$CXX $CXXFLAGS *.o -shared $LDFLAGS \
|
|
|
|
-landroid-base \
|
2016-09-11 14:34:07 +02:00
|
|
|
-landroid-ziparchive \
|
2022-02-05 06:17:26 +01:00
|
|
|
-o $_TMP_LIBDIR/libandroid-fw.so
|
2016-09-04 17:07:13 +02:00
|
|
|
|
2022-02-06 13:20:18 +01:00
|
|
|
CPPFLAGS+=" -I$ANDROIDFW_SRCDIR/include"
|
|
|
|
|
2016-09-04 17:07:13 +02:00
|
|
|
# Build aapt:
|
2022-02-05 06:17:26 +01:00
|
|
|
cd $AAPT_SRCDIR
|
|
|
|
for f in *.cpp; do
|
2022-02-06 13:20:18 +01:00
|
|
|
$CXX $CXXFLAGS $CPPFLAGS $f -c
|
2022-02-05 06:17:26 +01:00
|
|
|
done
|
|
|
|
$CXX $CXXFLAGS *.o $LDFLAGS \
|
|
|
|
-landroid-fw \
|
|
|
|
-landroid-utils \
|
|
|
|
-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
|
2022-02-06 13:20:18 +01:00
|
|
|
for f in $libaapt2_proto; do
|
2022-02-05 06:17:26 +01:00
|
|
|
protoc --cpp_out=. $f
|
|
|
|
done
|
2022-02-06 13:20:18 +01:00
|
|
|
for f in $aapt2_sources; do
|
|
|
|
$CXX $CXXFLAGS $CPPFLAGS -I$LIBIDMAP2_POLICIES_INCDIR \
|
|
|
|
$f -c -o ${f%.*}.o
|
2022-02-05 06:17:26 +01:00
|
|
|
done
|
2022-02-06 13:20:18 +01:00
|
|
|
$CXX $CXXFLAGS $(find . -name '*.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 \
|
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
|
|
|
|
for f in *.cpp; do
|
2022-02-06 13:20:18 +01:00
|
|
|
$CXX $CXXFLAGS $CPPFLAGS -I$TERMUX_PKG_SRCDIR/zopfli/src $f -c
|
2022-02-05 06:17:26 +01:00
|
|
|
done
|
|
|
|
$CXX $CXXFLAGS *.o $LDFLAGS \
|
|
|
|
-landroid-utils \
|
2022-02-06 13:20:18 +01:00
|
|
|
-landroid-ziparchive \
|
2016-09-04 17:07:13 +02:00
|
|
|
-lzopfli \
|
2022-02-05 06:17:26 +01:00
|
|
|
-lz \
|
|
|
|
-o $_TMP_BINDIR/zipalign
|
2022-02-05 09:38:29 +01:00
|
|
|
|
|
|
|
# Build aidl:
|
|
|
|
cd $AIDL_SRCDIR
|
|
|
|
flex aidl_language_l.ll
|
|
|
|
bison --header=aidl_language_y.h aidl_language_y.yy
|
|
|
|
cat >> aidl_language_y.h <<-EOF
|
|
|
|
typedef union yy::parser::value_type YYSTYPE;
|
|
|
|
typedef yy::parser::location_type YYLTYPE;
|
|
|
|
EOF
|
2022-02-06 13:20:18 +01:00
|
|
|
for f in $aidl_sources; do
|
|
|
|
$CXX $CXXFLAGS $CPPFLAGS $f -c
|
2022-02-05 09:38:29 +01:00
|
|
|
done
|
|
|
|
$CXX $CXXFLAGS *.o $LDFLAGS \
|
|
|
|
-landroid-base \
|
|
|
|
-o $_TMP_BINDIR/aidl
|
2022-02-05 06:17:26 +01:00
|
|
|
}
|
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 \
|
2022-02-05 09:38:29 +01:00
|
|
|
$_TMP_BINDIR/{aapt,aapt2,zipalign,aidl}
|
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
|
|
|
}
|