How termux/android-build-tools works
Project Type and Purpose
• The project is a build system toolkit for Android tools. Its main purpose is to facilitate building key Android build tools by integrating submodules (sourced from AOSP) and applying a series of patches.
• It is not a full-stack application but a specialized build system that wraps around components like aidl (AIDL compiler), aapt, aapt2, and zipalign.
Main Components
a. Build System & Toolchain:
• CMake build scripts (CMakeLists.txt) as the driver for the entire building process.
• Build dependencies (C and C++ toolchain, bison, flex, ninja, pkgconf, etc.) and runtime libraries (libfmt, googletest, expat, libpng, protobuf).
b. Source Components:
• Git submodules which incorporate AOSP repositories (like “base” as referenced in the README).
• The Android build tool sources (integrated from upstream) that are patched.
c. Patching Mechanism:
• Several “patches” directories (for aidl, base, build, core, incremental_delivery, libbase, libziparchive, native). These represent modifications on top of the upstream source code.
d. Vendor and Versioning:
• The vendor directory and version.h.in file, which might be used to manage versions and third-party libraries.
e. Development and Deployment Workflow:
• .github/workflows which indicate automated builds/tests through CI (using build.yml).
• The clone.sh script, indicating the process to clone the repository with updated submodules.
Relationships and Data Flow
• Data Flow/Process: Start with a clone operation that recursively fetches submodules and runs clone.sh to set everything up. Then, CMake is used to generate build files (likely for ninja) which integrate the source, patches, and third-party dependencies.
• The patched components flow into the respective build targets (aidl, aapt, aapt2, and zipalign) which are then compiled into final tools.
• The CI/CD pipeline (GitHub workflows) initiates the build process and likely runs tests; this should be shown as an external process triggering builds.
Architectural Patterns and Technologies
• The design follows a modular approach by separating build logic (CMake), patch management, and dependency management (git submodules).
• Integration with system toolchains and the layered approach to patching upstream code.
• Incorporate external dependencies (build and runtime) as supporting libraries used by the tools.