mirror of
https://github.com/revanced/aapt2.git
synced 2024-09-27 00:27:02 +02:00
Compare commits
18 Commits
da74fa0317
...
b496bf7496
Author | SHA1 | Date | |
---|---|---|---|
|
b496bf7496 | ||
|
2d77cb6e54 | ||
|
a19f9722c5 | ||
|
5f59a408dd | ||
|
63c29d1dfb | ||
|
28b4e7ae73 | ||
|
6d13d16395 | ||
|
099133dce3 | ||
|
cb312e6ce3 | ||
|
9b638dedce | ||
|
050a59a8f5 | ||
|
51d1ec26ad | ||
|
8540582d6f | ||
|
e04bdb99dc | ||
|
70675e25cf | ||
|
39e55667ee | ||
|
cce76972b6 | ||
|
2910c576be |
64
.github/workflows/build.yml
vendored
64
.github/workflows/build.yml
vendored
@ -1,58 +1,56 @@
|
||||
name: Build aapt2 binary
|
||||
name: Build package aapt
|
||||
|
||||
on:
|
||||
push:
|
||||
branches:
|
||||
- main
|
||||
paths:
|
||||
- '.github/**'
|
||||
workflow_dispatch:
|
||||
inputs:
|
||||
logLevel:
|
||||
description: 'Reason'
|
||||
required: false
|
||||
default: 'update package'
|
||||
|
||||
env:
|
||||
NDK_VERSION: "23.2.8568313"
|
||||
|
||||
jobs:
|
||||
build:
|
||||
name: build
|
||||
runs-on: ubuntu-latest
|
||||
env:
|
||||
ANDROID_HOME: "/opt/termux/android-sdk"
|
||||
NDK: "/opt/termux/android-ndk"
|
||||
|
||||
strategy:
|
||||
matrix:
|
||||
target_arch: [i686]
|
||||
fail-fast: false
|
||||
steps:
|
||||
- name: Checkout
|
||||
uses: actions/checkout@v3
|
||||
|
||||
- name: Checkout build-tools
|
||||
- name: Clone termux-packages repository
|
||||
uses: actions/checkout@v3
|
||||
with:
|
||||
repository: 'RohitVerma882/build-tools'
|
||||
path: 'build-tools'
|
||||
repository: termux/termux-packages
|
||||
path: termux-packages
|
||||
|
||||
- name: Set up Java 1.8
|
||||
uses: actions/setup-java@v3
|
||||
with:
|
||||
distribution: 'zulu'
|
||||
java-version: '8'
|
||||
- name: Apply termux patches
|
||||
run: |
|
||||
cd termux-packages
|
||||
git apply ../termux/*.patch
|
||||
|
||||
- name: Setup Android SDK
|
||||
uses: android-actions/setup-android@v2
|
||||
- name: Build aapt package
|
||||
run: |
|
||||
cd termux-packages
|
||||
./scripts/run-docker.sh ./build-package.sh -a ${{ matrix.target_arch }} aapt
|
||||
|
||||
- name: Setup Android NDK
|
||||
run: sdkmanager "ndk;${{ env.NDK_VERSION }}"
|
||||
|
||||
- name: Install dependencies
|
||||
run: |
|
||||
sudo apt-get update
|
||||
sudo apt-get upgrade git -y
|
||||
sudo apt-get install build-essential unzip nasm cmake ninja-build -y || exit 1
|
||||
|
||||
- name: Build aapt2
|
||||
env:
|
||||
NDK_TOOLCHAIN: "${{ env.ANDROID_HOME }}/ndk/${{ env.NDK_VERSION }}/toolchains/llvm/prebuilt/linux-x86_64"
|
||||
run: ./build.sh
|
||||
- name: Prepare artifacts
|
||||
run: |
|
||||
cd termux-packages/output
|
||||
for pkg in *.deb; do dpkg-deb -x $pkg extracted_packages; done
|
||||
cd extracted_packages/data/data/com.termux/files/usr/
|
||||
rm -r include/ share/ lib/pkgconfig/ lib/cmake/
|
||||
find bin ! -name 'aapt2' -mindepth 1 -exec rm -f {} +
|
||||
|
||||
- name: Upload artifacts
|
||||
uses: actions/upload-artifact@v3
|
||||
with:
|
||||
name: dist
|
||||
path: build-tools/dist/
|
||||
name: aapt-${{ matrix.target_arch }}-${{ github.sha }}
|
||||
path: termux-packages/output/extracted_packages/data/data/com.termux/files/usr/bin/
|
@ -2,4 +2,4 @@
|
||||
|
||||
[![build workflow](https://github.com/revanced/aapt2/actions/workflows/build.yml/badge.svg)](https://github.com/revanced/aapt2/actions/workflows/build.yml)
|
||||
|
||||
This repository contains a workflow to build the aapt2 binaries for Android.
|
||||
This repository contains a workflow to build the aapt2 package via the [`termux-packages` build system](https://github.com/termux/termux-packages).
|
@ -1,5 +1,38 @@
|
||||
--- a/src/aapt2/ResourceUtils.cpp
|
||||
+++ b/src/aapt2/ResourceUtils.cpp
|
||||
--- a/base/tools/aapt2/Android.bp
|
||||
+++ b/base/tools/aapt2/Android.bp
|
||||
@@ -54,6 +54,7 @@
|
||||
},
|
||||
darwin: {
|
||||
cflags: ["-D_DARWIN_UNLIMITED_STREAMS"],
|
||||
+ static_libs: ["libc++_static"]
|
||||
},
|
||||
},
|
||||
header_libs: ["jni_headers"],
|
||||
@@ -210,6 +211,8 @@
|
||||
name: "aapt2",
|
||||
srcs: ["Main.cpp"] + toolSources,
|
||||
use_version_lib: true,
|
||||
+ stl: "libc++_static",
|
||||
+ static_executable: true,
|
||||
static_libs: ["libaapt2"],
|
||||
defaults: ["aapt2_defaults"],
|
||||
dist: {
|
||||
--- a/base/tools/aapt2/ResourceTable.cpp
|
||||
+++ b/base/tools/aapt2/ResourceTable.cpp
|
||||
@@ -460,9 +460,8 @@
|
||||
const bool validate = validation_ == Validation::kEnabled;
|
||||
const Source source = res.value ? res.value->GetSource() : Source{};
|
||||
if (validate && !res.allow_mangled && !IsValidResourceEntryName(res.name.entry)) {
|
||||
- diag->Error(DiagMessage(source)
|
||||
- << "resource '" << res.name << "' has invalid entry name '" << res.name.entry);
|
||||
- return false;
|
||||
+ // Apktool: Allow invalid entry names.
|
||||
+ return true;
|
||||
}
|
||||
|
||||
if (res.id.has_value() && !res.id->first.is_valid()) {
|
||||
--- a/base/tools/aapt2/ResourceUtils.cpp
|
||||
+++ b/base/tools/aapt2/ResourceUtils.cpp
|
||||
@@ -222,7 +222,7 @@
|
||||
}
|
||||
|
||||
@ -9,8 +42,8 @@
|
||||
}
|
||||
|
||||
if (entry.empty()) {
|
||||
--- a/src/aapt2/cmd/Link.cpp
|
||||
+++ b/src/aapt2/cmd/Link.cpp
|
||||
--- a/base/tools/aapt2/cmd/Link.cpp
|
||||
+++ b/base/tools/aapt2/cmd/Link.cpp
|
||||
@@ -2326,9 +2326,9 @@
|
||||
if (package_id_int > std::numeric_limits<uint8_t>::max()
|
||||
|| package_id_int == kFrameworkPackageId
|
||||
@ -47,8 +80,8 @@
|
||||
// Turn off auto versioning for static-libs.
|
||||
if (context.GetPackageType() == PackageType::kStaticLib) {
|
||||
options_.no_auto_version = true;
|
||||
--- a/src/aapt2/cmd/Link.h
|
||||
+++ b/src/aapt2/cmd/Link.h
|
||||
--- a/base/tools/aapt2/cmd/Link.h
|
||||
+++ b/base/tools/aapt2/cmd/Link.h
|
||||
@@ -71,6 +71,7 @@
|
||||
bool do_not_compress_anything = false;
|
||||
std::unordered_set<std::string> extensions_to_not_compress;
|
||||
@ -66,8 +99,8 @@
|
||||
AddOptionalSwitch("--no-compress", "Do not compress any resources.",
|
||||
&options_.do_not_compress_anything);
|
||||
AddOptionalSwitch("--keep-raw-values", "Preserve raw attribute values in xml files.",
|
||||
--- a/src/aapt2/java/JavaClassGenerator.cpp
|
||||
+++ b/src/aapt2/java/JavaClassGenerator.cpp
|
||||
--- a/base/tools/aapt2/java/JavaClassGenerator.cpp
|
||||
+++ b/base/tools/aapt2/java/JavaClassGenerator.cpp
|
||||
@@ -58,6 +58,8 @@
|
||||
"true", "false", "null"};
|
||||
|
||||
@ -77,8 +110,8 @@
|
||||
return sJavaIdentifiers.find(symbol) == sJavaIdentifiers.end();
|
||||
}
|
||||
|
||||
--- a/src/aapt2/link/PrivateAttributeMover.cpp
|
||||
+++ b/src/aapt2/link/PrivateAttributeMover.cpp
|
||||
--- a/base/tools/aapt2/link/PrivateAttributeMover.cpp
|
||||
+++ b/base/tools/aapt2/link/PrivateAttributeMover.cpp
|
||||
@@ -81,7 +81,6 @@
|
||||
}
|
||||
|
||||
@ -87,18 +120,3 @@
|
||||
priv_attr_type->entries = std::move(private_attr_entries);
|
||||
}
|
||||
return true;
|
||||
--- a/src/aapt2/ResourceTable.cpp
|
||||
+++ b/src/aapt2/ResourceTable.cpp
|
||||
@@ -375,11 +375,7 @@ bool ResourceTable::AddResourceWithIdMangled(const ResourceNameRef& name, const
|
||||
bool ResourceTable::ValidateName(NameValidator name_validator, const ResourceNameRef& name,
|
||||
const Source& source, IDiagnostics* diag) {
|
||||
const StringPiece bad_char = name_validator(name.entry);
|
||||
- if (!bad_char.empty()) {
|
||||
- diag->Error(DiagMessage(source) << "resource '" << name << "' has invalid entry name '"
|
||||
- << name.entry << "'. Invalid character '" << bad_char << "'");
|
||||
- return false;
|
||||
- }
|
||||
+ // Apktool: Allow invalid entry names.
|
||||
return true;
|
||||
}
|
||||
|
92
build.sh
92
build.sh
@ -1,85 +1,7 @@
|
||||
#!/bin/bash
|
||||
|
||||
compileAapt2() {
|
||||
arch="$1"
|
||||
c_compiler=""
|
||||
cxx_compiler=""
|
||||
case $arch in
|
||||
"arm64-v8a")
|
||||
c_compiler="aarch64-linux-android30-clang"
|
||||
cxx_compiler="aarch64-linux-android30-clang++"
|
||||
;;
|
||||
"armeabi-v7a")
|
||||
c_compiler="armv7a-linux-androideabi30-clang"
|
||||
cxx_compiler="armv7a-linux-androideabi30-clang++"
|
||||
;;
|
||||
"x86")
|
||||
c_compiler="i686-linux-android30-clang"
|
||||
cxx_compiler="i686-linux-android30-clang++"
|
||||
;;
|
||||
"x86-64")
|
||||
c_compiler="x86_64-linux-android30-clang"
|
||||
cxx_compiler="x86_64-linux-android30-clang++"
|
||||
;;
|
||||
*)
|
||||
echo "Unknown architecture: $arch"
|
||||
exit 1
|
||||
;;
|
||||
esac
|
||||
currentdir="$(pwd)"
|
||||
outdir="$currentdir/dist/$arch"
|
||||
|
||||
if [ -d "$outdir" ]; then
|
||||
echo "Skipping compilation against target $arch because it already exists."
|
||||
echo "Please delete $outdir and re-run this script to recompile against target $arch."
|
||||
return 0
|
||||
fi
|
||||
|
||||
echo "Compiling against target: $arch"
|
||||
echo "NDK toolchain: ${NDK_TOOLCHAIN}"
|
||||
echo "Output will be saved in: $outdir"
|
||||
echo "Compiling..."
|
||||
rm -rf "build"
|
||||
mkdir "build" && cd "build" || exit 1
|
||||
|
||||
cmake -G 'Ninja' \
|
||||
-DCMAKE_C_COMPILER="$NDK_TOOLCHAIN/bin/$c_compiler" \
|
||||
-DCMAKE_CXX_COMPILER="$NDK_TOOLCHAIN/bin/$cxx_compiler" \
|
||||
-DCMAKE_BUILD_WITH_INSTALL_RPATH=True \
|
||||
-DCMAKE_SYSROOT="$NDK_TOOLCHAIN/sysroot" \
|
||||
-DCMAKE_BUILD_TYPE=Release \
|
||||
-DANDROID_ABI="$arch" \
|
||||
.. || exit 1
|
||||
|
||||
ninja -j16 || exit 1
|
||||
|
||||
mkdir -p "$outdir"
|
||||
"$NDK_TOOLCHAIN/bin/llvm-strip" --strip-unneeded "aapt2"
|
||||
mv "aapt2" "$outdir"
|
||||
cd "$currentdir" || exit 1
|
||||
}
|
||||
|
||||
buildAapt2() {
|
||||
echo "Building aapt2, this may take a while..."
|
||||
cd build-tools || exit 1
|
||||
|
||||
echo "Applying patches..."
|
||||
git apply ../patches/*.patch || exit 1
|
||||
|
||||
mkdir -p "dist"
|
||||
for arch in "arm64-v8a" "armeabi-v7a" "x86"; do
|
||||
compileAapt2 $arch
|
||||
done
|
||||
}
|
||||
|
||||
main() {
|
||||
if [[ -z "${NDK_TOOLCHAIN}" ]]; then
|
||||
echo "Please specify the Android NDK you want to use in environment variable \"NDK_TOOLCHAIN\"."
|
||||
exit 1
|
||||
fi
|
||||
echo "Building aapt2 executable..."
|
||||
buildAapt2
|
||||
echo "All done!"
|
||||
}
|
||||
|
||||
main
|
||||
cd termux-packages
|
||||
mv ../setup.sh .
|
||||
./scripts/run-docker.sh ./setup.sh
|
||||
for arch in "aarch64" "arm" "i686"; do
|
||||
echo "Building aapt for $arch"
|
||||
./scripts/run-docker.sh ./build-package.sh -I -a $arch aapt
|
||||
done
|
||||
|
@ -1,11 +0,0 @@
|
||||
--- a/src/aapt2/Main.cpp
|
||||
+++ b/src/aapt2/Main.cpp
|
||||
@@ -54,7 +54,7 @@ class VersionCommand : public Command {
|
||||
}
|
||||
|
||||
int Action(const std::vector<std::string>& /* args */) override {
|
||||
- std::cerr << StringPrintf("%s %s", util::GetToolName(), util::GetToolFingerprint().c_str())
|
||||
+ std::cerr << StringPrintf("%s %s (by ReVanced, github.com/revanced/aapt2)", util::GetToolName(), util::GetToolFingerprint().c_str())
|
||||
<< std::endl;
|
||||
return 0;
|
||||
}
|
11
prepare.sh
Executable file
11
prepare.sh
Executable file
@ -0,0 +1,11 @@
|
||||
cd termux-packages/output
|
||||
for pkg in *.deb
|
||||
do
|
||||
echo "Extracting $pkg"
|
||||
extname=$(basename $pkg .deb)
|
||||
dpkg-deb -x $pkg $extname
|
||||
cd extracted_packages/data/data/com.termux/files/usr/
|
||||
rm -r include/ share/ lib/pkgconfig/ lib/cmake/
|
||||
find bin ! -name 'aapt2' -mindepth 1 -exec rm -f {} +
|
||||
echo "Extracted $pkg to $extname"
|
||||
done
|
4
setup.sh
Executable file
4
setup.sh
Executable file
@ -0,0 +1,4 @@
|
||||
mkdir -p /home/builder/.termux-build/aapt/src
|
||||
cd /home/builder/.termux-build/aapt/src
|
||||
echo "Cloning AOSP base..."
|
||||
git clone --depth 1 --single-branch --branch android-12.0.0_r27 https://android.googlesource.com/platform/frameworks/base
|
82
termux/Aapt-use-Apktool-fork.patch
Normal file
82
termux/Aapt-use-Apktool-fork.patch
Normal file
@ -0,0 +1,82 @@
|
||||
--- a/packages/aapt/build.sh
|
||||
+++ b/packages/aapt/build.sh
|
||||
@@ -6,8 +6,7 @@ _TAG_VERSION=12.0.0
|
||||
_TAG_REVISION=27
|
||||
TERMUX_PKG_VERSION=${_TAG_VERSION}.${_TAG_REVISION}
|
||||
TERMUX_PKG_REVISION=3
|
||||
-TERMUX_PKG_SRCURL=(https://android.googlesource.com/platform/frameworks/base
|
||||
- https://android.googlesource.com/platform/system/core
|
||||
+TERMUX_PKG_SRCURL=(https://android.googlesource.com/platform/system/core
|
||||
https://android.googlesource.com/platform/system/libbase
|
||||
https://android.googlesource.com/platform/system/libziparchive
|
||||
https://android.googlesource.com/platform/system/logging
|
||||
@@ -21,7 +20,6 @@ TERMUX_PKG_SHA256=(SKIP_CHECKSUM
|
||||
SKIP_CHECKSUM
|
||||
SKIP_CHECKSUM
|
||||
SKIP_CHECKSUM
|
||||
- SKIP_CHECKSUM
|
||||
SKIP_CHECKSUM)
|
||||
TERMUX_PKG_SKIP_SRC_EXTRACT=true
|
||||
TERMUX_PKG_BUILD_IN_SRC=true
|
||||
@@ -34,6 +32,8 @@ termux_step_post_get_source() {
|
||||
# tar files, but they change each time as the tar metadata
|
||||
# differs: https://github.com/google/gitiles/issues/84
|
||||
|
||||
+ git clone --depth 1 https://github.com/iBotPeaches/platform_frameworks_base.git base
|
||||
+
|
||||
for i in $(seq 0 $(( ${#TERMUX_PKG_SRCURL[@]}-1 ))); do
|
||||
git clone --depth 1 --single-branch \
|
||||
--branch $TERMUX_PKG_GIT_BRANCH \
|
||||
@@ -126,7 +126,7 @@ termux_step_make() {
|
||||
for f in $libcutils_sources; do
|
||||
$CXX $CXXFLAGS $CPPFLAGS $f -c
|
||||
done
|
||||
- $CC $CFLAGS *.o -shared $LDFLAGS \
|
||||
+ $CC $CFLAGS *.o $LDFLAGS \
|
||||
-o $_TMP_LIBDIR/libandroid-cutils.so
|
||||
|
||||
# Build libutils:
|
||||
@@ -134,7 +134,7 @@ termux_step_make() {
|
||||
for f in $libutils_sources; do
|
||||
$CXX $CXXFLAGS $CPPFLAGS $f -c
|
||||
done
|
||||
- $CXX $CXXFLAGS *.o -shared $LDFLAGS \
|
||||
+ $CXX $CXXFLAGS *.o $LDFLAGS \
|
||||
-landroid-cutils \
|
||||
-o $_TMP_LIBDIR/libandroid-utils.so
|
||||
|
||||
@@ -143,7 +143,7 @@ termux_step_make() {
|
||||
for f in $libbase_sources; do
|
||||
$CXX $CXXFLAGS $CPPFLAGS $f -c
|
||||
done
|
||||
- $CXX $CXXFLAGS *.o -shared $LDFLAGS \
|
||||
+ $CXX $CXXFLAGS *.o $LDFLAGS \
|
||||
-o $_TMP_LIBDIR/libandroid-base.so
|
||||
|
||||
# Build libziparchive:
|
||||
@@ -151,7 +151,7 @@ termux_step_make() {
|
||||
for f in $libziparchive_sources; do
|
||||
$CXX $CXXFLAGS -std=c++20 $CPPFLAGS -I$INCFS_SUPPORT_INCDIR $f -c
|
||||
done
|
||||
- $CXX $CXXFLAGS *.o -shared $LDFLAGS \
|
||||
+ $CXX $CXXFLAGS *.o $LDFLAGS \
|
||||
-landroid-base \
|
||||
-lz \
|
||||
-o $_TMP_LIBDIR/libandroid-ziparchive.so
|
||||
@@ -165,7 +165,7 @@ termux_step_make() {
|
||||
for f in $androidfw_sources $INCFS_UTIL_SRCDIR/map_ptr.cpp; do
|
||||
$CXX $CXXFLAGS $CPPFLAGS $f -c
|
||||
done
|
||||
- $CXX $CXXFLAGS *.o -shared $LDFLAGS \
|
||||
+ $CXX $CXXFLAGS *.o $LDFLAGS \
|
||||
-landroid-base \
|
||||
-landroid-cutils \
|
||||
-landroid-ziparchive \
|
||||
@@ -203,6 +203,7 @@ termux_step_make() {
|
||||
-lexpat \
|
||||
-lpng \
|
||||
-lprotobuf \
|
||||
+ -static \
|
||||
-o $_TMP_BINDIR/aapt2
|
||||
|
||||
# Build zipalign:
|
Loading…
Reference in New Issue
Block a user