mirror of
https://github.com/revanced/aapt2.git
synced 2024-10-19 20:09:43 +02:00
feat: Apktool patches for aapt2
This commit is contained in:
parent
6002f4004a
commit
c8bdb9e423
18
.github/workflows/build.yml
vendored
18
.github/workflows/build.yml
vendored
@ -22,15 +22,25 @@ jobs:
|
||||
target_arch: [aarch64, arm, i686]
|
||||
fail-fast: false
|
||||
steps:
|
||||
- name: Checkout
|
||||
uses: actions/checkout@v3
|
||||
|
||||
- name: Clone termux-packages repository
|
||||
run: git clone https://github.com/termux/termux-packages .
|
||||
uses: actions/checkout@v3
|
||||
with:
|
||||
repository: termux/termux-packages
|
||||
|
||||
- name: Add aapt2 patches
|
||||
run: cp *.patch termux-packages/packages/aapt
|
||||
|
||||
- name: Build aapt package
|
||||
run: ./scripts/run-docker.sh ./build-package.sh -a ${{ matrix.target_arch }} aapt
|
||||
run: |
|
||||
cd termux-packages
|
||||
./scripts/run-docker.sh ./build-package.sh -a ${{ matrix.target_arch }} aapt
|
||||
|
||||
- name: Prepare artifacts
|
||||
run: |
|
||||
cd output
|
||||
cd termux-packages/output
|
||||
|
||||
for pkg in *.deb; do dpkg-deb -x $pkg extracted_packages; done
|
||||
|
||||
@ -43,4 +53,4 @@ jobs:
|
||||
uses: actions/upload-artifact@v3
|
||||
with:
|
||||
name: aapt-${{ matrix.target_arch }}-${{ github.sha }}
|
||||
path: output/extracted_packages/data/data/com.termux/files/usr/
|
||||
path: termux-packages/output/extracted_packages/data/data/com.termux/files/usr/
|
||||
|
5
.vscode/settings.json
vendored
Normal file
5
.vscode/settings.json
vendored
Normal file
@ -0,0 +1,5 @@
|
||||
{
|
||||
"yaml.schemas": {
|
||||
"https://json.schemastore.org/github-workflow.json": "file:///c%3A/Coding/JavaProjects/revanced-aapt2/.github/workflows/build.yml"
|
||||
}
|
||||
}
|
122
aapt2-Apktool-patches.patch
Normal file
122
aapt2-Apktool-patches.patch
Normal file
@ -0,0 +1,122 @@
|
||||
--- 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 @@
|
||||
}
|
||||
|
||||
if (!type.empty() && type != "attr") {
|
||||
- return false;
|
||||
+ // Apktool: Don't die out if private resource.
|
||||
}
|
||||
|
||||
if (entry.empty()) {
|
||||
--- 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
|
||||
|| (!options_.allow_reserved_package_id && package_id_int < kAppPackageId)) {
|
||||
- context.GetDiagnostics()->Error(
|
||||
+ context.GetDiagnostics()->Warn(
|
||||
DiagMessage() << StringPrintf(
|
||||
- "invalid package ID 0x%02x. Must be in the range 0x7f-0xff.", package_id_int));
|
||||
+ "invalid package ID 0x%02x. Must be in the range 0x7f-0xff. Ignoring...", package_id_int));
|
||||
return 1;
|
||||
}
|
||||
context.SetPackageId(static_cast<uint8_t>(package_id_int));
|
||||
@@ -2410,6 +2410,23 @@
|
||||
".mpg", ".mpeg", ".mp4", ".m4a", ".m4v", ".3gp", ".3gpp", ".3g2", ".3gpp2", ".wma", ".wmv",
|
||||
".webm", ".mkv"});
|
||||
|
||||
+ // Populate no compress extensions specified in the extensions file.
|
||||
+ if (options_.extensions_to_not_compress_path) {
|
||||
+ std::ifstream extensionsFile(options_.extensions_to_not_compress_path.value());
|
||||
+
|
||||
+ if (extensionsFile.fail()) {
|
||||
+ context.GetDiagnostics()->Error(
|
||||
+ DiagMessage() << "could not open extensions file "
|
||||
+ << options_.extensions_to_not_compress_path.value()
|
||||
+ << " for reading");
|
||||
+ return 1;
|
||||
+ }
|
||||
+
|
||||
+ for (std::string line; getline(extensionsFile, line);) {
|
||||
+ options_.extensions_to_not_compress.insert(line);
|
||||
+ }
|
||||
+ }
|
||||
+
|
||||
// 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
|
||||
@@ -71,6 +71,7 @@
|
||||
bool do_not_compress_anything = false;
|
||||
std::unordered_set<std::string> extensions_to_not_compress;
|
||||
Maybe<std::regex> regex_to_not_compress;
|
||||
+ Maybe<std::string> extensions_to_not_compress_path;
|
||||
|
||||
// Static lib options.
|
||||
bool no_static_lib_packages = false;
|
||||
@@ -272,6 +273,8 @@
|
||||
&options_.manifest_fixer_options.rename_overlay_target_package);
|
||||
AddOptionalFlagList("-0", "File suffix not to compress.",
|
||||
&options_.extensions_to_not_compress);
|
||||
+ AddOptionalFlag("-e", "File containing list of extensions not to compress.",
|
||||
+ &options_.extensions_to_not_compress_path);
|
||||
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
|
||||
@@ -58,6 +58,8 @@
|
||||
"true", "false", "null"};
|
||||
|
||||
static bool IsValidSymbol(const StringPiece& symbol) {
|
||||
+ // Apktool: Everything is a valid symbol
|
||||
+ return true;
|
||||
return sJavaIdentifiers.find(symbol) == sJavaIdentifiers.end();
|
||||
}
|
||||
|
||||
--- a/base/tools/aapt2/link/PrivateAttributeMover.cpp
|
||||
+++ b/base/tools/aapt2/link/PrivateAttributeMover.cpp
|
||||
@@ -81,7 +81,6 @@
|
||||
}
|
||||
|
||||
ResourceTableType* priv_attr_type = package->FindOrCreateType(ResourceType::kAttrPrivate);
|
||||
- CHECK(priv_attr_type->entries.empty());
|
||||
priv_attr_type->entries = std::move(private_attr_entries);
|
||||
}
|
||||
return true;
|
Loading…
Reference in New Issue
Block a user