From 9b0a99a4d411784a63bfb8e0cfdadf357f957134 Mon Sep 17 00:00:00 2001 From: Tee KOBAYASHI Date: Sun, 6 Feb 2022 21:20:18 +0900 Subject: [PATCH] aapt: Update to 11.0.0.48 --- packages/aapt/aapt-Main.cpp.patch | 19 ++- .../aapt/aapt2-ResourcesInternal.proto.patch | 11 -- packages/aapt/aapt2-cmd-Compile.h.patch | 19 +++ packages/aapt/aapt2-io-Util.h.patch | 12 ++ packages/aapt/aapt2-util-Util.cpp.patch | 22 +++ packages/aapt/aidl-aidl_language_y.yy.patch | 16 -- packages/aapt/aidl-options.h.patch | 33 ---- .../aapt/androidfw-ResourceTypes.cpp.patch | 2 +- ...ase-include-android-base-unique_fd.h.patch | 20 +++ packages/aapt/base-liblog_symbols.cpp.patch | 18 +++ packages/aapt/base-liblog_symbols.h.patch | 10 ++ packages/aapt/base-logging.cpp.patch | 11 ++ packages/aapt/base-properties.cpp.patch | 29 ++++ packages/aapt/build.sh | 108 ++++--------- packages/aapt/libcutils-properties.cpp.patch | 15 ++ .../aapt/libcutils-sockets_unix.cpp.patch | 11 ++ packages/aapt/libutils-Threads.cpp.patch | 56 +++++++ packages/aapt/libutils-misc.cpp.patch | 18 +-- ...hive-include-ziparchive-zip_writer.h.patch | 17 ++ .../aapt/libziparchive-zip_archive.cc.patch | 38 +++++ .../aapt/libziparchive-zip_writer.cc.patch | 2 +- packages/aapt/sources.sh | 146 ++++++++++-------- 22 files changed, 425 insertions(+), 208 deletions(-) delete mode 100644 packages/aapt/aapt2-ResourcesInternal.proto.patch create mode 100644 packages/aapt/aapt2-cmd-Compile.h.patch create mode 100644 packages/aapt/aapt2-io-Util.h.patch create mode 100644 packages/aapt/aapt2-util-Util.cpp.patch delete mode 100644 packages/aapt/aidl-aidl_language_y.yy.patch delete mode 100644 packages/aapt/aidl-options.h.patch create mode 100644 packages/aapt/base-include-android-base-unique_fd.h.patch create mode 100644 packages/aapt/base-liblog_symbols.cpp.patch create mode 100644 packages/aapt/base-liblog_symbols.h.patch create mode 100644 packages/aapt/base-logging.cpp.patch create mode 100644 packages/aapt/base-properties.cpp.patch create mode 100644 packages/aapt/libcutils-properties.cpp.patch create mode 100644 packages/aapt/libcutils-sockets_unix.cpp.patch create mode 100644 packages/aapt/libutils-Threads.cpp.patch create mode 100644 packages/aapt/libziparchive-include-ziparchive-zip_writer.h.patch create mode 100644 packages/aapt/libziparchive-zip_archive.cc.patch diff --git a/packages/aapt/aapt-Main.cpp.patch b/packages/aapt/aapt-Main.cpp.patch index 2bcbe8282..695b66d23 100644 --- a/packages/aapt/aapt-Main.cpp.patch +++ b/packages/aapt/aapt-Main.cpp.patch @@ -1,6 +1,23 @@ --- a/base/tools/aapt/Main.cpp +++ b/base/tools/aapt/Main.cpp -@@ -270,6 +270,9 @@ +@@ -6,7 +6,6 @@ + #include "Main.h" + #include "Bundle.h" + +-#include + #include + #include + #include +@@ -29,7 +28,7 @@ + if (bundle->getFileSpecCount() != 0) { + printf("(ignoring extra arguments)\n"); + } +- printf("Android Asset Packaging Tool, v0.2-%s\n", android::build::GetBuildNumber().c_str()); ++ printf("Android Asset Packaging Tool, v0.2\n"); + + return 0; + } +@@ -284,6 +283,9 @@ /* default to compression */ bundle.setCompressionMethod(ZipEntry::kCompressDeflated); diff --git a/packages/aapt/aapt2-ResourcesInternal.proto.patch b/packages/aapt/aapt2-ResourcesInternal.proto.patch deleted file mode 100644 index 143c2ceb5..000000000 --- a/packages/aapt/aapt2-ResourcesInternal.proto.patch +++ /dev/null @@ -1,11 +0,0 @@ ---- a/base/tools/aapt2/ResourcesInternal.proto -+++ b/base/tools/aapt2/ResourcesInternal.proto -@@ -19,7 +19,7 @@ - option java_package = "android.aapt.pb.internal"; - option optimize_for = LITE_RUNTIME; - --import "frameworks/base/tools/aapt2/Resources.proto"; -+import "Resources.proto"; - - package aapt.pb.internal; - diff --git a/packages/aapt/aapt2-cmd-Compile.h.patch b/packages/aapt/aapt2-cmd-Compile.h.patch new file mode 100644 index 000000000..236901c1e --- /dev/null +++ b/packages/aapt/aapt2-cmd-Compile.h.patch @@ -0,0 +1,19 @@ +--- a/base/tools/aapt2/cmd/Compile.h ++++ b/base/tools/aapt2/cmd/Compile.h +@@ -35,6 +35,7 @@ + bool pseudolocalize = false; + bool no_png_crunch = false; + bool legacy_mode = false; ++ bool source_path = false; + // See comments on aapt::ResourceParserOptions. + bool preserve_visibility_of_styleables = false; + bool verbose = false; +@@ -58,6 +59,8 @@ + AddOptionalSwitch("--no-crunch", "Disables PNG processing", &options_.no_png_crunch); + AddOptionalSwitch("--legacy", "Treat errors that used to be valid in AAPT as warnings", + &options_.legacy_mode); ++ AddOptionalSwitch("--source-path", "Ignored for compatibility", ++ &options_.source_path); + AddOptionalSwitch("--preserve-visibility-of-styleables", + "If specified, apply the same visibility rules for\n" + "styleables as are used for all other resources.\n" diff --git a/packages/aapt/aapt2-io-Util.h.patch b/packages/aapt/aapt2-io-Util.h.patch new file mode 100644 index 000000000..f3a127d58 --- /dev/null +++ b/packages/aapt/aapt2-io-Util.h.patch @@ -0,0 +1,12 @@ +--- a/base/tools/aapt2/io/Util.h ++++ b/base/tools/aapt2/io/Util.h +@@ -131,8 +131,7 @@ + template bool ReadMessage(T *message) { + ZeroCopyInputAdaptor adapter(in_); + google::protobuf::io::CodedInputStream coded_stream(&adapter); +- coded_stream.SetTotalBytesLimit(std::numeric_limits::max(), +- coded_stream.BytesUntilTotalBytesLimit()); ++ coded_stream.SetTotalBytesLimit(std::numeric_limits::max()); + return message->ParseFromCodedStream(&coded_stream); + } + diff --git a/packages/aapt/aapt2-util-Util.cpp.patch b/packages/aapt/aapt2-util-Util.cpp.patch new file mode 100644 index 000000000..e9bfd6b32 --- /dev/null +++ b/packages/aapt/aapt2-util-Util.cpp.patch @@ -0,0 +1,22 @@ +--- a/base/tools/aapt2/util/Util.cpp ++++ b/base/tools/aapt2/util/Util.cpp +@@ -23,7 +23,6 @@ + + #include "android-base/stringprintf.h" + #include "androidfw/StringPiece.h" +-#include "build/version.h" + + #include "text/Unicode.h" + #include "text/Utf8Iterator.h" +@@ -214,10 +213,7 @@ + // Update minor version whenever a feature or flag is added. + static const char* const sMinorVersion = "19"; + +- // The build id of aapt2 binary. +- static const std::string sBuildId = android::build::GetBuildNumber(); +- +- return android::base::StringPrintf("%s.%s-%s", sMajorVersion, sMinorVersion, sBuildId.c_str()); ++ return android::base::StringPrintf("%s.%s", sMajorVersion, sMinorVersion); + } + + static size_t ConsumeDigits(const char* start, const char* end) { diff --git a/packages/aapt/aidl-aidl_language_y.yy.patch b/packages/aapt/aidl-aidl_language_y.yy.patch deleted file mode 100644 index a57d5d599..000000000 --- a/packages/aapt/aidl-aidl_language_y.yy.patch +++ /dev/null @@ -1,16 +0,0 @@ ---- a/aidl/aidl_language_y.yy -+++ b/aidl/aidl_language_y.yy -@@ -1,3 +1,5 @@ -+%header "aidl_language_y.h" -+ - %{ - #include "aidl_language.h" - #include "aidl_language_y.h" -@@ -14,7 +16,6 @@ - %parse-param { Parser* ps } - %lex-param { void *lex_scanner } - --%pure-parser - %skeleton "glr.cc" - - %union { diff --git a/packages/aapt/aidl-options.h.patch b/packages/aapt/aidl-options.h.patch deleted file mode 100644 index 9cc1d80e4..000000000 --- a/packages/aapt/aidl-options.h.patch +++ /dev/null @@ -1,33 +0,0 @@ ---- a/aidl/options.h -+++ b/aidl/options.h -@@ -21,7 +21,6 @@ - #include - - #include --#include - - namespace android { - namespace aidl { -@@ -59,13 +58,6 @@ - private: - JavaOptions() = default; - -- FRIEND_TEST(EndToEndTest, IExampleInterface); -- FRIEND_TEST(AidlTest, FailOnParcelable); -- FRIEND_TEST(AidlTest, WritePreprocessedFile); -- FRIEND_TEST(AidlTest, WritesCorrectDependencyFile); -- FRIEND_TEST(AidlTest, WritesCorrectDependencyFileNinja); -- FRIEND_TEST(AidlTest, WritesTrivialDependencyFileForParcelable); -- - DISALLOW_COPY_AND_ASSIGN(JavaOptions); - }; - -@@ -97,8 +89,6 @@ - std::string dep_file_name_; - bool dep_file_ninja_{false}; - -- FRIEND_TEST(CppOptionsTests, ParsesCompileCpp); -- FRIEND_TEST(CppOptionsTests, ParsesCompileCppNinja); - DISALLOW_COPY_AND_ASSIGN(CppOptions); - }; - diff --git a/packages/aapt/androidfw-ResourceTypes.cpp.patch b/packages/aapt/androidfw-ResourceTypes.cpp.patch index 1b76b3a9b..2f1564f06 100644 --- a/packages/aapt/androidfw-ResourceTypes.cpp.patch +++ b/packages/aapt/androidfw-ResourceTypes.cpp.patch @@ -1,6 +1,6 @@ --- a/base/libs/androidfw/ResourceTypes.cpp +++ b/base/libs/androidfw/ResourceTypes.cpp -@@ -39,7 +39,7 @@ +@@ -42,7 +42,7 @@ #include #include diff --git a/packages/aapt/base-include-android-base-unique_fd.h.patch b/packages/aapt/base-include-android-base-unique_fd.h.patch new file mode 100644 index 000000000..becd70ecd --- /dev/null +++ b/packages/aapt/base-include-android-base-unique_fd.h.patch @@ -0,0 +1,20 @@ +--- a/core/base/include/android-base/unique_fd.h ++++ b/core/base/include/android-base/unique_fd.h +@@ -46,7 +46,7 @@ + // unique_fd is also known as ScopedFd/ScopedFD/scoped_fd; mentioned here to help + // you find this class if you're searching for one of those names. + +-#if defined(__BIONIC__) ++#if defined(__BIONIC__) && __ANDROID_API__ >= 29 + #include + #endif + +@@ -54,7 +54,7 @@ + namespace base { + + struct DefaultCloser { +-#if defined(__BIONIC__) ++#if defined(__BIONIC__) && __ANDROID_API__ >= 29 + static void Tag(int fd, void* old_addr, void* new_addr) { + if (android_fdsan_exchange_owner_tag) { + uint64_t old_tag = android_fdsan_create_owner_tag(ANDROID_FDSAN_OWNER_TYPE_UNIQUE_FD, diff --git a/packages/aapt/base-liblog_symbols.cpp.patch b/packages/aapt/base-liblog_symbols.cpp.patch new file mode 100644 index 000000000..1dbf09624 --- /dev/null +++ b/packages/aapt/base-liblog_symbols.cpp.patch @@ -0,0 +1,18 @@ +--- a/core/base/liblog_symbols.cpp ++++ b/core/base/liblog_symbols.cpp +@@ -55,6 +55,7 @@ + DLSYM(__android_log_set_minimum_priority); + DLSYM(__android_log_get_minimum_priority); + DLSYM(__android_log_set_default_tag); ++ DLSYM(__android_log_is_loggable); + #undef DLSYM + + return real_liblog_functions; +@@ -78,6 +79,7 @@ + .__android_log_set_minimum_priority = __android_log_set_minimum_priority, + .__android_log_get_minimum_priority = __android_log_get_minimum_priority, + .__android_log_set_default_tag = __android_log_set_default_tag, ++ .__android_log_is_loggable = __android_log_is_loggable, + }; + }(); + return liblog_functions; diff --git a/packages/aapt/base-liblog_symbols.h.patch b/packages/aapt/base-liblog_symbols.h.patch new file mode 100644 index 000000000..95363898b --- /dev/null +++ b/packages/aapt/base-liblog_symbols.h.patch @@ -0,0 +1,10 @@ +--- a/core/base/liblog_symbols.h ++++ b/core/base/liblog_symbols.h +@@ -36,6 +36,7 @@ + int32_t (*__android_log_set_minimum_priority)(int32_t priority); + int32_t (*__android_log_get_minimum_priority)(); + void (*__android_log_set_default_tag)(const char* tag); ++ int (*__android_log_is_loggable)(int prio, const char* tag, int default_prio); + }; + + const std::optional& GetLibLogFunctions(); diff --git a/packages/aapt/base-logging.cpp.patch b/packages/aapt/base-logging.cpp.patch new file mode 100644 index 000000000..bd505f2c1 --- /dev/null +++ b/packages/aapt/base-logging.cpp.patch @@ -0,0 +1,11 @@ +--- a/core/base/logging.cpp ++++ b/core/base/logging.cpp +@@ -555,7 +555,7 @@ + // take into consideration the value from SetMinimumLogSeverity(). + if (liblog_functions) { + int32_t priority = LogSeverityToPriority(severity); +- return __android_log_is_loggable(priority, tag, ANDROID_LOG_INFO); ++ return liblog_functions->__android_log_is_loggable(priority, tag, ANDROID_LOG_INFO); + } else { + return severity >= gMinimumLogSeverity; + } diff --git a/packages/aapt/base-properties.cpp.patch b/packages/aapt/base-properties.cpp.patch new file mode 100644 index 000000000..bf36df244 --- /dev/null +++ b/packages/aapt/base-properties.cpp.patch @@ -0,0 +1,29 @@ +--- a/core/base/properties.cpp ++++ b/core/base/properties.cpp +@@ -73,7 +73,7 @@ + template uint32_t GetUintProperty(const std::string&, uint32_t, uint32_t); + template uint64_t GetUintProperty(const std::string&, uint64_t, uint64_t); + +-#if !defined(__BIONIC__) ++#if !defined(__BIONIC__) || defined(__TERMUX__) + static std::map& g_properties = *new std::map; + static int __system_property_set(const char* key, const char* value) { + g_properties[key] = value; +@@ -83,7 +83,7 @@ + + std::string GetProperty(const std::string& key, const std::string& default_value) { + std::string property_value; +-#if defined(__BIONIC__) ++#if defined(__BIONIC__) && !defined(__TERMUX__) + const prop_info* pi = __system_property_find(key.c_str()); + if (pi == nullptr) return default_value; + +@@ -108,7 +108,7 @@ + return (__system_property_set(key.c_str(), value.c_str()) == 0); + } + +-#if defined(__BIONIC__) ++#if defined(__BIONIC__) && !defined(__TERMUX__) + + struct WaitForPropertyData { + bool done; diff --git a/packages/aapt/build.sh b/packages/aapt/build.sh index 4f078fcda..94a40bbfa 100644 --- a/packages/aapt/build.sh +++ b/packages/aapt/build.sh @@ -2,17 +2,15 @@ TERMUX_PKG_HOMEPAGE=https://elinux.org/Android_aapt TERMUX_PKG_DESCRIPTION="Android Asset Packaging Tool" TERMUX_PKG_LICENSE="Apache-2.0" TERMUX_PKG_MAINTAINER="@termux" -_TAG_VERSION=8.1.0 -_TAG_REVISION=81 +_TAG_VERSION=11.0.0 +_TAG_REVISION=48 TERMUX_PKG_VERSION=${_TAG_VERSION}.${_TAG_REVISION} 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 https://android.googlesource.com/platform/system/tools/aidl) TERMUX_PKG_GIT_BRANCH=android-${_TAG_VERSION}_r${_TAG_REVISION} TERMUX_PKG_SHA256=(SKIP_CHECKSUM - SKIP_CHECKSUM SKIP_CHECKSUM SKIP_CHECKSUM SKIP_CHECKSUM) @@ -32,6 +30,10 @@ termux_step_post_get_source() { ${TERMUX_PKG_SRCURL[$i]} done + for f in base/tools/aapt2/*.proto; do + sed -i 's:frameworks/base/tools/aapt2/::' $f + 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") @@ -73,7 +75,8 @@ termux_step_pre_configure() { export PATH=$_PREFIX_FOR_BUILD/bin:$PATH CFLAGS+=" -fPIC" - CXXFLAGS+=" -fPIC" + CXXFLAGS+=" -fPIC -std=c++17" + CPPFLAGS+=" -D__ANDROID_SDK_VERSION__=__ANDROID_API__" _TMP_LIBDIR=$TERMUX_PKG_SRCDIR/_lib rm -rf $_TMP_LIBDIR @@ -82,7 +85,7 @@ termux_step_pre_configure() { rm -rf $_TMP_BINDIR mkdir -p $_TMP_BINDIR - LDFLAGS+=" -L$_TMP_LIBDIR" + LDFLAGS+=" -llog -L$_TMP_LIBDIR" } termux_step_make() { @@ -91,103 +94,74 @@ termux_step_make() { 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 LIBIDMAP2_POLICIES_INCDIR=$TERMUX_PKG_SRCDIR/base/cmds/idmap2/libidmap2_policies/include local AAPT2_SRCDIR=$TERMUX_PKG_SRCDIR/base/tools/aapt2 local ZIPALIGN_SRCDIR=$TERMUX_PKG_SRCDIR/build/tools/zipalign local AIDL_SRCDIR=$TERMUX_PKG_SRCDIR/aidl + CPPFLAGS+=" -I. -I./include -I$LIBBASE_SRCDIR/include -I$CORE_INCDIR" + # Build libcutils: 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 + for f in $libcutils_sources; do + $CXX $CXXFLAGS $CPPFLAGS $f -c done $CC $CFLAGS *.o -shared $LDFLAGS \ - -llog \ -o $_TMP_LIBDIR/libandroid-cutils.so # 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 + $CXX $CXXFLAGS $CPPFLAGS $f -c done $CXX $CXXFLAGS *.o -shared $LDFLAGS \ -landroid-cutils \ - -llog \ -o $_TMP_LIBDIR/libandroid-utils.so # Build libbase: cd $LIBBASE_SRCDIR - local LIBBASE_CPPFLAGS="$CPPFLAGS \ - -I./include \ - -I$CORE_INCDIR" for f in $libbase_sources; do - $CXX $CXXFLAGS $LIBBASE_CPPFLAGS $f -c + $CXX $CXXFLAGS $CPPFLAGS $f -c done $CXX $CXXFLAGS *.o -shared $LDFLAGS \ - -llog \ -o $_TMP_LIBDIR/libandroid-base.so # Build libziparchive: 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 + $CXX $CXXFLAGS $CPPFLAGS $f -c done $CXX $CXXFLAGS *.o -shared $LDFLAGS \ -landroid-base \ - -llog \ + -lz \ -o $_TMP_LIBDIR/libandroid-ziparchive.so + CPPFLAGS+=" -I$LIBZIPARCHIVE_SRCDIR/include" + # Build libandroidfw: 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 + $CXX $CXXFLAGS $CPPFLAGS $f -c done $CXX $CXXFLAGS *.o -shared $LDFLAGS \ -landroid-base \ -landroid-ziparchive \ - -llog \ -o $_TMP_LIBDIR/libandroid-fw.so + CPPFLAGS+=" -I$ANDROIDFW_SRCDIR/include" + # Build aapt: 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 + $CXX $CXXFLAGS $CPPFLAGS $f -c done $CXX $CXXFLAGS *.o $LDFLAGS \ -landroid-fw \ -landroid-utils \ - -llog \ -lexpat \ -lpng \ -lz \ @@ -195,25 +169,18 @@ termux_step_make() { # Build aapt2: cd $AAPT2_SRCDIR - local AAPT2_CPPFLAGS="$CPPFLAGS \ - -I. \ - -I./include \ - -I$LIBBASE_SRCDIR/include \ - -I$LIBZIPARCHIVE_SRCDIR/include \ - -I$ANDROIDFW_SRCDIR/include \ - -I$CORE_INCDIR" - for f in $libaapt2_sources_proto; do + for f in $libaapt2_proto; do protoc --cpp_out=. $f done - for f in $aapt2_sources_cpp; do - $CXX $CXXFLAGS $AAPT2_CPPFLAGS $f -c -o ${f%.*}.o + for f in $aapt2_sources; do + $CXX $CXXFLAGS $CPPFLAGS -I$LIBIDMAP2_POLICIES_INCDIR \ + $f -c -o ${f%.*}.o done - $CXX $CXXFLAGS *.o */*.o $LDFLAGS \ + $CXX $CXXFLAGS $(find . -name '*.o') $LDFLAGS \ -landroid-base \ -landroid-fw \ -landroid-utils \ -landroid-ziparchive \ - -llog \ -lexpat \ -lpng \ -lprotobuf \ @@ -221,17 +188,12 @@ termux_step_make() { # Build zipalign: 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 + $CXX $CXXFLAGS $CPPFLAGS -I$TERMUX_PKG_SRCDIR/zopfli/src $f -c done $CXX $CXXFLAGS *.o $LDFLAGS \ - -landroid-fw \ -landroid-utils \ - -llog \ + -landroid-ziparchive \ -lzopfli \ -lz \ -o $_TMP_BINDIR/zipalign @@ -244,15 +206,11 @@ termux_step_make() { typedef union yy::parser::value_type YYSTYPE; typedef yy::parser::location_type YYLTYPE; EOF - local AIDL_CPPFLAGS="$CPPFLAGS \ - -I. \ - -I$LIBBASE_SRCDIR/include" - for f in $aidl_sources_cpp; do - $CXX $CXXFLAGS $AIDL_CPPFLAGS $f -c + for f in $aidl_sources; do + $CXX $CXXFLAGS $CPPFLAGS $f -c done $CXX $CXXFLAGS *.o $LDFLAGS \ -landroid-base \ - -llog \ -o $_TMP_BINDIR/aidl } diff --git a/packages/aapt/libcutils-properties.cpp.patch b/packages/aapt/libcutils-properties.cpp.patch new file mode 100644 index 000000000..f48df1570 --- /dev/null +++ b/packages/aapt/libcutils-properties.cpp.patch @@ -0,0 +1,15 @@ +--- a/core/libcutils/properties.cpp ++++ b/core/libcutils/properties.cpp +@@ -134,6 +134,7 @@ + data->callback(name, value, data->cookie); + } + ++#if defined __ANDROID__ && __ANDROID_API__ >= 26 + static void property_list_callback(const prop_info* pi, void* data) { + __system_property_read_callback(pi, trampoline, data); + } +@@ -142,3 +143,4 @@ + callback_data data = { fn, cookie }; + return __system_property_foreach(property_list_callback, &data); + } ++#endif diff --git a/packages/aapt/libcutils-sockets_unix.cpp.patch b/packages/aapt/libcutils-sockets_unix.cpp.patch new file mode 100644 index 000000000..16674ce66 --- /dev/null +++ b/packages/aapt/libcutils-sockets_unix.cpp.patch @@ -0,0 +1,11 @@ +--- a/core/libcutils/sockets_unix.cpp ++++ b/core/libcutils/sockets_unix.cpp +@@ -50,7 +50,7 @@ + return writev(sock, iovec_buffers, num_buffers); + } + +-#if defined(__ANDROID__) ++#if defined(__ANDROID__) && !defined(__TERMUX__) + int android_get_control_socket(const char* name) { + int fd = __android_get_control_from_env(ANDROID_SOCKET_ENV_PREFIX, name); + diff --git a/packages/aapt/libutils-Threads.cpp.patch b/packages/aapt/libutils-Threads.cpp.patch new file mode 100644 index 000000000..37c26cbd8 --- /dev/null +++ b/packages/aapt/libutils-Threads.cpp.patch @@ -0,0 +1,56 @@ +--- a/core/libutils/Threads.cpp ++++ b/core/libutils/Threads.cpp +@@ -36,7 +36,7 @@ + + #include + +-#if defined(__ANDROID__) ++#if defined(__ANDROID__) && !defined(__TERMUX__) + #include + #include + #endif +@@ -67,7 +67,7 @@ + + typedef void* (*android_pthread_entry)(void*); + +-#if defined(__ANDROID__) ++#if defined(__ANDROID__) && !defined(__TERMUX__) + struct thread_data_t { + thread_func_t entryFunction; + void* userData; +@@ -131,7 +131,7 @@ + pthread_attr_init(&attr); + pthread_attr_setdetachstate(&attr, PTHREAD_CREATE_DETACHED); + +-#if defined(__ANDROID__) /* valgrind is rejecting RT-priority create reqs */ ++#if defined(__ANDROID__) && !defined(__TERMUX__) /* valgrind is rejecting RT-priority create reqs */ + if (threadPriority != PRIORITY_DEFAULT || threadName != NULL) { + // Now that the pthread_t has a method to find the associated + // android_thread_id_t (pid) from pthread_t, it would be possible to avoid +@@ -175,7 +175,7 @@ + return 1; + } + +-#if defined(__ANDROID__) ++#if defined(__ANDROID__) && !defined(__TERMUX__) + static pthread_t android_thread_id_t_to_pthread(android_thread_id_t thread) + { + return (pthread_t) thread; +@@ -301,7 +301,7 @@ + gCreateThreadFn = func; + } + +-#if defined(__ANDROID__) ++#if defined(__ANDROID__) && !defined(__TERMUX__) + int androidSetThreadPriority(pid_t tid, int pri) + { + int rc = 0; +@@ -843,7 +843,7 @@ + return mRunning; + } + +-#if defined(__ANDROID__) ++#if defined(__ANDROID__) && !defined(__TERMUX__) + pid_t Thread::getTid() const + { + // mTid is not defined until the child initializes it, and the caller may need it earlier diff --git a/packages/aapt/libutils-misc.cpp.patch b/packages/aapt/libutils-misc.cpp.patch index d09f5ab4d..7a79fdd23 100644 --- a/packages/aapt/libutils-misc.cpp.patch +++ b/packages/aapt/libutils-misc.cpp.patch @@ -4,26 +4,26 @@ #include #include --#if defined(__ANDROID__) -+#if defined(__ANDROID__) && !defined(__TERMUX__) +-#if defined(__ANDROID__) && !defined(__ANDROID_RECOVERY__) ++#if defined(__ANDROID__) && !defined(__TERMUX__) && !defined(__ANDROID_RECOVERY__) #include #include #endif -@@ -68,7 +68,7 @@ +@@ -70,7 +70,7 @@ + void add_sysprop_change_callback(sysprop_change_callback, int) {} #endif - } --#if defined(__ANDROID__) -+#if defined(__ANDROID__) && !defined(__TERMUX__) +-#if defined(__ANDROID__) && !defined(__ANDROID_RECOVERY__) ++#if defined(__ANDROID__) && !defined(__TERMUX__) && !defined(__ANDROID_RECOVERY__) void (*get_report_sysprop_change_func())() { void (*func)() = nullptr; void* handle = android_load_sphal_library("libutils.so", RTLD_NOW); -@@ -83,7 +83,7 @@ +@@ -85,7 +85,7 @@ void report_sysprop_change() { do_report_sysprop_change(); --#if defined(__ANDROID__) -+#if defined(__ANDROID__) && !defined(__TERMUX__) +-#if defined(__ANDROID__) && !defined(__ANDROID_RECOVERY__) ++#if defined(__ANDROID__) && !defined(__TERMUX__) && !defined(__ANDROID_RECOVERY__) // libutils.so is double loaded; from the default namespace and from the // 'sphal' namespace. Redirect the sysprop change event to the other instance // of libutils.so loaded in the 'sphal' namespace so that listeners attached diff --git a/packages/aapt/libziparchive-include-ziparchive-zip_writer.h.patch b/packages/aapt/libziparchive-include-ziparchive-zip_writer.h.patch new file mode 100644 index 000000000..b473c47e3 --- /dev/null +++ b/packages/aapt/libziparchive-include-ziparchive-zip_writer.h.patch @@ -0,0 +1,17 @@ +--- a/core/libziparchive/include/ziparchive/zip_writer.h ++++ b/core/libziparchive/include/ziparchive/zip_writer.h +@@ -19,7 +19,6 @@ + #include + #include + +-#include + #include + #include + #include +@@ -184,6 +183,4 @@ + + std::unique_ptr z_stream_; + std::vector buffer_; +- +- FRIEND_TEST(zipwriter, WriteToUnseekableFile); + }; diff --git a/packages/aapt/libziparchive-zip_archive.cc.patch b/packages/aapt/libziparchive-zip_archive.cc.patch new file mode 100644 index 000000000..cbf8a6c2b --- /dev/null +++ b/packages/aapt/libziparchive-zip_archive.cc.patch @@ -0,0 +1,38 @@ +--- a/core/libziparchive/zip_archive.cc ++++ b/core/libziparchive/zip_archive.cc +@@ -38,7 +38,7 @@ + #define lseek64 lseek + #endif + +-#if defined(__BIONIC__) ++#if defined(__BIONIC__) && __ANDROID_API__ >= 29 + #include + #endif + +@@ -155,7 +155,7 @@ + return 0; + } + +-#if defined(__BIONIC__) ++#if defined(__BIONIC__) && __ANDROID_API__ >= 29 + uint64_t GetOwnerTag(const ZipArchive* archive) { + return android_fdsan_create_owner_tag(ANDROID_FDSAN_OWNER_TYPE_ZIPARCHIVE, + reinterpret_cast(archive)); +@@ -171,7 +171,7 @@ + num_entries(0), + hash_table_size(0), + hash_table(nullptr) { +-#if defined(__BIONIC__) ++#if defined(__BIONIC__) && __ANDROID_API__ >= 29 + if (assume_ownership) { + CHECK(mapped_zip.HasFd()); + android_fdsan_exchange_owner_tag(mapped_zip.GetFileDescriptor(), 0, GetOwnerTag(this)); +@@ -191,7 +191,7 @@ + + ZipArchive::~ZipArchive() { + if (close_file && mapped_zip.GetFileDescriptor() >= 0) { +-#if defined(__BIONIC__) ++#if defined(__BIONIC__) && __ANDROID_API__ >= 29 + android_fdsan_close_with_tag(mapped_zip.GetFileDescriptor(), GetOwnerTag(this)); + #else + close(mapped_zip.GetFileDescriptor()); diff --git a/packages/aapt/libziparchive-zip_writer.cc.patch b/packages/aapt/libziparchive-zip_writer.cc.patch index 40d2ddf31..0409bed80 100644 --- a/packages/aapt/libziparchive-zip_writer.cc.patch +++ b/packages/aapt/libziparchive-zip_writer.cc.patch @@ -1,6 +1,6 @@ --- a/core/libziparchive/zip_writer.cc +++ b/core/libziparchive/zip_writer.cc -@@ -356,7 +356,7 @@ +@@ -389,7 +389,7 @@ CHECK(z_stream_->avail_out != 0); // Prepare the input. diff --git a/packages/aapt/sources.sh b/packages/aapt/sources.sh index d89a578ce..6dc35b11f 100644 --- a/packages/aapt/sources.sh +++ b/packages/aapt/sources.sh @@ -1,47 +1,44 @@ # libcutils -local libcutils_nonwindows_sources_cpp=" - android_get_control_file.cpp +local libcutils_sockets_nonwindows_sources=" + socket_inaddr_any_server_unix.cpp + socket_local_client_unix.cpp + socket_local_server_unix.cpp + socket_network_client_unix.cpp sockets_unix.cpp " -local libcutils_sources_cpp=" - $libcutils_nonwindows_sources_cpp - fs_config.cpp - sched_policy.cpp +local libcutils_sockets_sources=" + $libcutils_sockets_nonwindows_sources sockets.cpp " -local libcutils_nonwindows_sources_c=" - fs.c - multiuser.c - socket_inaddr_any_server_unix.c - socket_local_client_unix.c - socket_local_server_unix.c - socket_network_client_unix.c - str_parms.c +local libcutils_nonwindows_sources=" + fs.cpp + hashmap.cpp + multiuser.cpp + str_parms.cpp " -libcutils_nonwindows_sources_c+=" - ashmem-host.c - trace-host.c +libcutils_nonwindows_sources+=" + ashmem-host.cpp + fs_config.cpp + trace-host.cpp " -local libcutils_sources_c=" - $libcutils_nonwindows_sources_c - config_utils.c - canned_fs_config.c - hashmap.c - iosched_policy.c - load_file.c - native_handle.c - open_memstream.c - record_stream.c - strdup16to8.c - strdup8to16.c +local libcutils_sources=" + $libcutils_sockets_sources + $libcutils_nonwindows_sources + config_utils.cpp + canned_fs_config.cpp + iosched_policy.cpp + load_file.cpp + native_handle.cpp + properties.cpp + record_stream.cpp strlcpy.c - threads.c + threads.cpp " # libutils -#CallStack.cpp local libutils_sources=" + Errors.cpp FileMap.cpp JenkinsHash.cpp NativeHandle.cpp @@ -49,7 +46,6 @@ local libutils_sources=" PropertyMap.cpp RefBase.cpp SharedBuffer.cpp - Static.cpp StopWatch.cpp String8.cpp String16.cpp @@ -66,16 +62,23 @@ local libutils_sources=" # libbase local libbase_linux_sources=" errors_unix.cpp - chrono_utils.cpp " local libbase_sources=" $libbase_linux_sources + abi_compatibility.cpp + chrono_utils.cpp + cmsg.cpp file.cpp + liblog_symbols.cpp logging.cpp + mapped_file.cpp + parsebool.cpp parsenetaddress.cpp - quick_exit.cpp + process.cpp + properties.cpp stringprintf.cpp strings.cpp + threads.cpp test_utils.cpp " @@ -95,10 +98,14 @@ local androidfw_sources=" AssetManager2.cpp AttributeResolution.cpp ChunkIterator.cpp + ConfigDescription.cpp + Idmap.cpp LoadedArsc.cpp + Locale.cpp LocaleData.cpp misc.cpp ObbFile.cpp + PosixUtils.cpp ResourceTypes.cpp ResourceUtils.cpp StreamingZipInflater.cpp @@ -109,12 +116,13 @@ local androidfw_sources=" " # aapt2 -local libaapt2_sources_proto=" +local libaapt2_proto=" + Configuration.proto Resources.proto ResourcesInternal.proto " -local libaapt2_sources_cpp=" - ${libaapt2_sources_proto//.proto/.pb.cc} +local libaapt2_sources=" + ${libaapt2_proto//.proto/.pb.cc} compile/IdAssigner.cpp compile/InlineXmlFormatParser.cpp compile/NinePatch.cpp @@ -125,52 +133,56 @@ local libaapt2_sources_cpp=" compile/Pseudolocalizer.cpp compile/XmlIdCollector.cpp configuration/ConfigurationParser.cpp + dump/DumpManifest.cpp filter/AbiFilter.cpp filter/ConfigFilter.cpp - flatten/Archive.cpp - flatten/TableFlattener.cpp - flatten/XmlFlattener.cpp - io/BigBufferStreams.cpp + format/Archive.cpp + format/Container.cpp + format/binary/BinaryResourceParser.cpp + format/binary/ResChunkPullParser.cpp + format/binary/TableFlattener.cpp + format/binary/XmlFlattener.cpp + format/proto/ProtoDeserialize.cpp + format/proto/ProtoSerialize.cpp + io/BigBufferStream.cpp io/File.cpp - io/FileInputStream.cpp + io/FileStream.cpp io/FileSystem.cpp - io/StringInputStream.cpp + io/StringStream.cpp io/Util.cpp io/ZipArchive.cpp link/AutoVersioner.cpp link/ManifestFixer.cpp + link/NoDefaultResourceRemover.cpp link/ProductFilter.cpp link/PrivateAttributeMover.cpp link/ReferenceLinker.cpp + link/ResourceExcluder.cpp link/TableMerger.cpp link/XmlCompatVersioner.cpp link/XmlNamespaceRemover.cpp link/XmlReferenceLinker.cpp + optimize/MultiApkGenerator.cpp optimize/ResourceDeduper.cpp + optimize/ResourceFilter.cpp + optimize/ResourcePathShortener.cpp optimize/VersionCollapser.cpp process/SymbolTable.cpp - proto/ProtoHelpers.cpp - proto/TableProtoDeserializer.cpp - proto/TableProtoSerializer.cpp split/TableSplitter.cpp + text/Printer.cpp text/Unicode.cpp text/Utf8Iterator.cpp - unflatten/BinaryResourceParser.cpp - unflatten/ResChunkPullParser.cpp util/BigBuffer.cpp util/Files.cpp util/Util.cpp - ConfigDescription.cpp Debug.cpp DominatorTree.cpp - Flags.cpp java/AnnotationProcessor.cpp java/ClassDefinition.cpp java/JavaClassGenerator.cpp java/ManifestClassGenerator.cpp java/ProguardRules.cpp LoadedApk.cpp - Locale.cpp Resource.cpp ResourceParser.cpp ResourceTable.cpp @@ -178,45 +190,57 @@ local libaapt2_sources_cpp=" ResourceValues.cpp SdkConstants.cpp StringPool.cpp + trace/TraceBuffer.cpp xml/XmlActionExecutor.cpp xml/XmlDom.cpp xml/XmlPullParser.cpp xml/XmlUtil.cpp " -local aapt2_sources_cpp=" - $libaapt2_sources_cpp +local aapt2_tool_sources=" + cmd/Command.cpp cmd/Compile.cpp + cmd/Convert.cpp cmd/Diff.cpp cmd/Dump.cpp cmd/Link.cpp cmd/Optimize.cpp cmd/Util.cpp +" +local aapt2_sources=" + $libaapt2_sources + $aapt2_tool_sources Main.cpp " # aidl -local libaidl_sources_cpp=" +local libaidl_sources=" aidl.cpp + aidl_checkapi.cpp + aidl_const_expressions.cpp aidl_language.cpp + aidl_typenames.cpp + aidl_to_cpp.cpp + aidl_to_java.cpp + aidl_to_ndk.cpp ast_cpp.cpp ast_java.cpp code_writer.cpp generate_cpp.cpp + aidl_to_cpp_common.cpp + generate_ndk.cpp generate_java.cpp generate_java_binder.cpp + generate_aidl_mappings.cpp import_resolver.cpp line_reader.cpp io_delegate.cpp options.cpp - type_cpp.cpp - type_java.cpp - type_namespace.cpp " -libaidl_sources_cpp+=" +libaidl_sources+=" lex.yy.c aidl_language_y.tab.cc " -local aidl_sources_cpp=" - $libaidl_sources_cpp - main_java.cpp +local aidl_sources=" + $libaidl_sources + main.cpp "