Compare commits

..

5 Commits

Author SHA1 Message Date
baiorett da74fa0317
chore: clean up some stuff (#6) [skip ci]
* Update build.yml

* Update build.yml

* Update build.yml

* Update build.yml

* Update build.yml

* Update build.yml

* Update build.yml

* Update build.yml

* Update build.yml

* Update build.yml

* Update build.yml

* Update build.yml

* Update build.yml

* Update build.yml

* Update build.yml

* Update build.yml

* Update build.yml

* Update build.sh

* Cleanup

Co-authored-by: Sculas <contact@sculas.xyz>
2022-06-17 01:50:11 +02:00
Sculas efe203ad75
chore: stop it, get some help [skip ci] 2022-06-17 01:44:31 +02:00
Sculas 5dfa0342bc
chore: remove termux [skip ci] 2022-06-17 00:36:41 +02:00
Lucaskyy 9a355db508
fix: wrong perms for build.sh 2022-06-17 00:14:31 +02:00
Lucaskyy 00a8d7f579
feat: apktool patches for aapt2 2022-06-16 23:59:53 +02:00
8 changed files with 155 additions and 179 deletions

View File

@ -1,56 +1,58 @@
name: Build package aapt
name: Build aapt2 binary
on:
push:
paths:
- '.github/**'
branches:
- main
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: Clone termux-packages repository
- name: Checkout build-tools
uses: actions/checkout@v3
with:
repository: termux/termux-packages
path: termux-packages
repository: 'RohitVerma882/build-tools'
path: 'build-tools'
- name: Apply termux patches
run: |
cd termux-packages
git apply ../termux/*.patch
- name: Set up Java 1.8
uses: actions/setup-java@v3
with:
distribution: 'zulu'
java-version: '8'
- name: Build aapt package
run: |
cd termux-packages
./scripts/run-docker.sh ./build-package.sh -a ${{ matrix.target_arch }} aapt
- name: Setup Android SDK
uses: android-actions/setup-android@v2
- 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: 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: Upload artifacts
uses: actions/upload-artifact@v3
with:
name: aapt-${{ matrix.target_arch }}-${{ github.sha }}
path: termux-packages/output/extracted_packages/data/data/com.termux/files/usr/bin/
name: dist
path: build-tools/dist/

View File

@ -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 package via the [`termux-packages` build system](https://github.com/termux/termux-packages).
This repository contains a workflow to build the aapt2 binaries for Android.

View File

@ -1,7 +1,85 @@
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
#!/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

View File

@ -0,0 +1,11 @@
--- 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;
}

View File

@ -1,38 +1,5 @@
--- 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
--- a/src/aapt2/ResourceUtils.cpp
+++ b/src/aapt2/ResourceUtils.cpp
@@ -222,7 +222,7 @@
}
@ -42,8 +9,8 @@
}
if (entry.empty()) {
--- a/base/tools/aapt2/cmd/Link.cpp
+++ b/base/tools/aapt2/cmd/Link.cpp
--- a/src/aapt2/cmd/Link.cpp
+++ b/src/aapt2/cmd/Link.cpp
@@ -2326,9 +2326,9 @@
if (package_id_int > std::numeric_limits<uint8_t>::max()
|| package_id_int == kFrameworkPackageId
@ -80,8 +47,8 @@
// Turn off auto versioning for static-libs.
if (context.GetPackageType() == PackageType::kStaticLib) {
options_.no_auto_version = true;
--- a/base/tools/aapt2/cmd/Link.h
+++ b/base/tools/aapt2/cmd/Link.h
--- a/src/aapt2/cmd/Link.h
+++ b/src/aapt2/cmd/Link.h
@@ -71,6 +71,7 @@
bool do_not_compress_anything = false;
std::unordered_set<std::string> extensions_to_not_compress;
@ -99,8 +66,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/base/tools/aapt2/java/JavaClassGenerator.cpp
+++ b/base/tools/aapt2/java/JavaClassGenerator.cpp
--- a/src/aapt2/java/JavaClassGenerator.cpp
+++ b/src/aapt2/java/JavaClassGenerator.cpp
@@ -58,6 +58,8 @@
"true", "false", "null"};
@ -110,8 +77,8 @@
return sJavaIdentifiers.find(symbol) == sJavaIdentifiers.end();
}
--- a/base/tools/aapt2/link/PrivateAttributeMover.cpp
+++ b/base/tools/aapt2/link/PrivateAttributeMover.cpp
--- a/src/aapt2/link/PrivateAttributeMover.cpp
+++ b/src/aapt2/link/PrivateAttributeMover.cpp
@@ -81,7 +81,6 @@
}
@ -120,3 +87,18 @@
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;
}

View File

@ -1,11 +0,0 @@
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

View File

@ -1,4 +0,0 @@
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

View File

@ -1,82 +0,0 @@
--- 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: