Compare commits

...

No commits in common. "a25bad5618caff90c2281462948aeb7922aa9bfd" and "135d2d529695737b6b997d597c6e82bd7aad202c" have entirely different histories.

3 changed files with 66 additions and 62 deletions

View File

@ -12,35 +12,28 @@ on:
required: false
default: 'Update package'
env:
NDK_VERSION: "23.2.8568313"
jobs:
build:
name: build
runs-on: ubuntu-latest
strategy:
matrix:
target_arch: [x86_64, x86, arm64-v8a, armeabi-v7a]
fail-fast: false
steps:
- name: Checkout
uses: actions/checkout@v3
with:
submodules: 'true'
- name: Set up Java 1.8
uses: actions/setup-java@v3
- uses: nttld/setup-ndk@v1
id: setup-ndk
with:
distribution: 'zulu'
java-version: '8'
- name: Setup Android SDK
uses: android-actions/setup-android@v2
- name: Setup Android NDK
run: sdkmanager "ndk;${{ env.NDK_VERSION }}"
- name: Build aapt2
ndk-version: r23c
add-to-path: false
- run: ./build.sh ${{ matrix.target_arch }}
env:
NDK_TOOLCHAIN: "${{ env.ANDROID_HOME }}/ndk/${{ env.NDK_VERSION }}/toolchains/llvm/prebuilt/linux-x86_64"
run: ./build.sh
NDK_TOOLCHAIN: ${{ steps.setup-ndk.outputs.ndk-path }}/toolchains/llvm/prebuilt/linux-x86_64
- name: Upload artifacts
uses: actions/upload-artifact@v3

14
.gitmodules vendored
View File

@ -1,42 +1,56 @@
[submodule "src/expat"]
shallow = true
path = src/expat
url = https://android.googlesource.com/platform/external/expat.git
[submodule "src/fmtlib"]
shallow = true
path = src/fmtlib
url = https://android.googlesource.com/platform/external/fmtlib.git
[submodule "src/boringssl"]
shallow = true
path = src/boringssl
url = https://boringssl.googlesource.com/boringssl.git
[submodule "src/incremental_delivery"]
shallow = true
path = src/incremental_delivery
url = https://android.googlesource.com/platform/system/incremental_delivery
[submodule "src/libbase"]
shallow = true
path = src/libbase
url = https://android.googlesource.com/platform/system/libbase
[submodule "src/libpng"]
shallow = true
path = src/libpng
url = https://android.googlesource.com/platform/external/libpng.git
[submodule "src/pcre"]
shallow = true
path = src/pcre
url = https://android.googlesource.com/platform/external/pcre.git
[submodule "src/zopfli"]
shallow = true
path = src/zopfli
url = https://android.googlesource.com/platform/external/zopfli
[submodule "src/protobuf"]
shallow = true
path = src/protobuf
url = https://android.googlesource.com/platform/external/protobuf
[submodule "src/logging"]
shallow = true
path = src/logging
url = https://android.googlesource.com/platform/system/logging.git
[submodule "src/selinux"]
shallow = true
path = src/selinux
url = https://android.googlesource.com/platform/external/selinux.git
[submodule "src/core"]
shallow = true
path = src/core
url = https://android.googlesource.com/platform/system/core.git
[submodule "src/base"]
shallow = true
path = src/base
url = https://android.googlesource.com/platform/frameworks/base
[submodule "src/libziparchive"]
shallow = true
path = src/libziparchive
url = https://android.googlesource.com/platform/system/libziparchive

87
build.sh Normal file → Executable file
View File

@ -6,17 +6,17 @@ if [[ -z "${NDK_TOOLCHAIN}" ]]; then
exit 1
fi
root="$(pwd)"
# Prerequisites.
sudo apt install \
golang \
ninja-build \
autogen \
autoconf \
libtool \
build-essential \
-y || exit 1
golang \
ninja-build \
autogen \
autoconf \
libtool \
build-essential \
-y || exit 1
root="$(pwd)"
# Install protobuf compiler.
cd "src/protobuf" || exit 1
@ -26,6 +26,9 @@ make -j nproc
sudo make install
sudo ldconfig
# Go back.
cd "$root" || exit 1
# Apply patches.
git apply patches/incremental_delivery.patch --whitespace=fix
git apply patches/libpng.patch --whitespace=fix
@ -35,6 +38,7 @@ git apply patches/aapt2.patch --whitespace=fix
# Define all the compilers and targets that will be built.
api="30"
architecture=$1
declare -A compilers=(
[x86_64]="x86_64-linux-android"
[x86]="i686-linux-android"
@ -43,46 +47,39 @@ declare -A compilers=(
)
build_directory="build"
aapt_binary_path="$root$build_directory/cmake/aapt2"
aapt_binary_path="$root/$build_directory/cmake/aapt2"
# Build all the target architectures.
for architecture in "${!compilers[@]}"; do
bin_directory="$root/dist/$architecture"
bin_directory="$root/dist/$architecture"
# switch to cmake build directory.
[[ -d dir ]] || mkdir -p $build_directory && cd $build_directory || exit 1
# switch to cmake build directory.
[[ -d dir ]] || mkdir -p $build_directory && cd $build_directory || exit 1
# Define the compiler architecture and compiler.
compiler_arch="${compilers[$architecture]}"
c_compiler="$compiler_arch$api-clang"
cxx_compiler="${c_compiler}++"
# Copy libc.a to libpthread.a.
lib_path="$NDK_TOOLCHAIN/sysroot/usr/lib/$compiler_arch/$api/"
cp -n "$lib_path"libc.a "$lib_path"libpthread.a
# Run make for the target architecture.
compiler_bin_directory="$NDK_TOOLCHAIN/bin/"
cmake -GNinja \
-DCMAKE_C_COMPILER="$compiler_bin_directory$c_compiler" \
-DCMAKE_CXX_COMPILER="$compiler_bin_directory$cxx_compiler" \
-DCMAKE_BUILD_WITH_INSTALL_RPATH=True \
-DCMAKE_BUILD_TYPE=Release \
-DANDROID_ABI="$architecture" \
-DPROTOC_PATH="/usr/local/bin/protoc" \
-DCMAKE_SYSROOT="$NDK_TOOLCHAIN/sysroot" \
.. || exit 1
# Define the compiler architecture and compiler.
compiler_arch="${compilers[$architecture]}"
c_compiler="$compiler_arch$api-clang"
cxx_compiler="${c_compiler}++"
ninja -j16 || exit 1
"$NDK_TOOLCHAIN/bin/llvm-strip" --strip-unneeded "$aapt_binary_path"
# Copy libc.a to libpthread.a.
lib_path="$NDK_TOOLCHAIN/sysroot/usr/lib/$compiler_arch/$api/"
cp -n "$lib_path"libc.a "$lib_path"libpthread.a
# Create bin directory.
rm -rf "$bin_directory"
mkdir -p "$bin_directory"
# Run make for the target architecture.
compiler_bin_directory="$NDK_TOOLCHAIN/bin/"
cmake -GNinja \
-DCMAKE_C_COMPILER="$compiler_bin_directory$c_compiler" \
-DCMAKE_CXX_COMPILER="$compiler_bin_directory$cxx_compiler" \
-DCMAKE_BUILD_WITH_INSTALL_RPATH=True \
-DCMAKE_BUILD_TYPE=Release \
-DANDROID_ABI="$architecture" \
-DPROTOC_PATH="/usr/local/bin/protoc" \
-DCMAKE_SYSROOT="$NDK_TOOLCHAIN/sysroot" \
.. || exit 1
# Move aapt2 to bin directory.
mv "$aapt_binary_path" "$bin_directory"
ninja -j16 || exit 1
"$NDK_TOOLCHAIN/bin/llvm-strip" --strip-unneeded "$aapt_binary_path"
# Go back to the root directory.
cd ..
rm -rf $build_directory
done
# Create bin directory.
mkdir -p "$bin_directory"
# Move aapt2 to bin directory.
mv "$aapt_binary_path" "$bin_directory"