From 4f2f3427e86f7bb68bd52791fbae05ae9b90d88c Mon Sep 17 00:00:00 2001 From: Brad House Date: Thu, 1 Aug 2024 17:00:15 -0400 Subject: [PATCH] CI: Add Android automated building with GitHub Actions (#843) Authored-By: Brad House (@bradh352) --- .github/workflows/android.yml | 73 +++++++++++++++++++++++++++++++++++ configure.ac | 12 +++++- 2 files changed, 84 insertions(+), 1 deletion(-) create mode 100644 .github/workflows/android.yml diff --git a/.github/workflows/android.yml b/.github/workflows/android.yml new file mode 100644 index 00000000..dee71058 --- /dev/null +++ b/.github/workflows/android.yml @@ -0,0 +1,73 @@ +# Copyright (C) The c-ares project and its contributors +# SPDX-License-Identifier: MIT +name: Android +on: + push: + pull_request: + +concurrency: + group: ${{ github.ref }}-android + cancel-in-progress: true + +env: + CMAKE_DEFAULT_FLAGS: "-DCMAKE_BUILD_TYPE=DEBUG -DCARES_STATIC=ON -DCARES_STATIC_PIC=ON -G Ninja -DANDROID_PLATFORM=android-26" + MAKE: make + +jobs: + build: + runs-on: ubuntu-latest + name: "Android" + steps: + - name: Install packages + uses: awalsh128/cache-apt-pkgs-action@latest + with: + packages: cmake ninja-build autoconf automake libtool pkg-config + version: 1.0 + - name: Checkout c-ares + uses: actions/checkout@v4 + - name: Setup NDK + uses: nttld/setup-ndk@v1 + id: setup-ndk + with: + ndk-version: r21e + add-to-path: false + - name: "CMake: armeabi-v7a build c-ares" + env: + BUILD_TYPE: CMAKE + CMAKE_FLAGS: "${{ env.CMAKE_DEFAULT_FLAGS }} -DANDROID_ABI=armeabi-v7a -DCMAKE_TOOLCHAIN_FILE=${{ steps.setup-ndk.outputs.ndk-path }}/build/cmake/android.toolchain.cmake" + run: | + ./ci/build.sh + - name: "CMake: arm64-v8a build c-ares" + env: + BUILD_TYPE: CMAKE + CMAKE_FLAGS: "${{ env.CMAKE_DEFAULT_FLAGS }} -DANDROID_ABI=arm64-v8a -DCMAKE_TOOLCHAIN_FILE=${{ steps.setup-ndk.outputs.ndk-path }}/build/cmake/android.toolchain.cmake" + run: | + ./ci/build.sh + - name: "CMake: x86 build c-ares" + env: + BUILD_TYPE: CMAKE + CMAKE_FLAGS: "${{ env.CMAKE_DEFAULT_FLAGS }} -DANDROID_ABI=x86 -DCMAKE_TOOLCHAIN_FILE=${{ steps.setup-ndk.outputs.ndk-path }}/build/cmake/android.toolchain.cmake" + run: | + ./ci/build.sh + - name: "CMake: x86_64 build c-ares" + env: + BUILD_TYPE: CMAKE + CMAKE_FLAGS: "${{ env.CMAKE_DEFAULT_FLAGS }} -DANDROID_ABI=x86_64 -DCMAKE_TOOLCHAIN_FILE=${{ steps.setup-ndk.outputs.ndk-path }}/build/cmake/android.toolchain.cmake" + run: | + ./ci/build.sh + - name: "Autotools: aarch64 build c-ares" + env: + BUILD_TYPE: autotools + TOOLCHAIN: "${{ steps.setup-ndk.outputs.ndk-path }}/toolchains/llvm/prebuilt/linux-x86_64" + TARGET: aarch64-linux-android + API: 26 + AR: "${{ steps.setup-ndk.outputs.ndk-path }}/toolchains/llvm/prebuilt/linux-x86_64/bin/llvm-ar" + CC: "${{ steps.setup-ndk.outputs.ndk-path }}/toolchains/llvm/prebuilt/linux-x86_64/bin/clang --target=aarch64-linux-android26" + AS: "${{ steps.setup-ndk.outputs.ndk-path }}/toolchains/llvm/prebuilt/linux-x86_64/bin/clang --target=aarch64-linux-android26" + CXX: "${{ steps.setup-ndk.outputs.ndk-path }}/toolchains/llvm/prebuilt/linux-x86_64/bin/clang++ --target=aarch64-linux-android26" + LD: "${{ steps.setup-ndk.outputs.ndk-path }}/toolchains/llvm/prebuilt/linux-x86_64/bin/ld" + RANLIB: "${{ steps.setup-ndk.outputs.ndk-path }}/toolchains/llvm/prebuilt/linux-x86_64/bin/llvm-ranlib" + STRIP: "${{ steps.setup-ndk.outputs.ndk-path }}/toolchains/llvm/prebuilt/linux-x86_64/bin/llvm-strip" + CONFIG_OPTS: "--host aarch64-linux-android --disable-shared" + run: | + ./ci/build.sh diff --git a/configure.ac b/configure.ac index 859b410f..60afc358 100644 --- a/configure.ac +++ b/configure.ac @@ -245,8 +245,18 @@ AC_SUBST(CARES_SYMBOL_HIDING_CFLAG) if test "$enable_warnings" = "yes"; then - AX_APPEND_COMPILE_FLAGS([-std=c90 -Wall -Wextra -Waggregate-return -Wcast-align -Wcast-qual -Wconversion -Wdeclaration-after-statement -Wdouble-promotion -Wfloat-equal -Wformat-security -Winit-self -Wjump-misses-init -Wlogical-op -Wmissing-braces -Wmissing-declarations -Wmissing-format-attribute -Wmissing-include-dirs -Wmissing-prototypes -Wnested-externs -Wno-coverage-mismatch -Wold-style-definition -Wpacked -Wpedantic -Wpointer-arith -Wredundant-decls -Wshadow -Wsign-conversion -Wstrict-overflow -Wstrict-prototypes -Wtrampolines -Wundef -Wunreachable-code -Wunused -Wvariadic-macros -Wvla -Wwrite-strings -Werror=implicit-int -Werror=implicit-function-declaration -Werror=partial-availability -Wno-long-long ], + AX_APPEND_COMPILE_FLAGS([-Wall -Wextra -Waggregate-return -Wcast-align -Wcast-qual -Wconversion -Wdeclaration-after-statement -Wdouble-promotion -Wfloat-equal -Wformat-security -Winit-self -Wjump-misses-init -Wlogical-op -Wmissing-braces -Wmissing-declarations -Wmissing-format-attribute -Wmissing-include-dirs -Wmissing-prototypes -Wnested-externs -Wno-coverage-mismatch -Wold-style-definition -Wpacked -Wpedantic -Wpointer-arith -Wredundant-decls -Wshadow -Wsign-conversion -Wstrict-overflow -Wstrict-prototypes -Wtrampolines -Wundef -Wunreachable-code -Wunused -Wvariadic-macros -Wvla -Wwrite-strings -Werror=implicit-int -Werror=implicit-function-declaration -Werror=partial-availability -Wno-long-long ], [AM_CFLAGS], [-Werror]) + + dnl Android requires c99, all others should use c90 + case $host_os in + *android*) + AX_APPEND_COMPILE_FLAGS([-std=c99], [AM_CFLAGS], [-Werror]) + ;; + *) + AX_APPEND_COMPILE_FLAGS([-std=c90], [AM_CFLAGS], [-Werror]) + ;; + esac fi if test "$ax_cv_c_compiler_vendor" = "intel"; then