├── .gitignore ├── .gitmodules ├── README.md ├── .github └── workflows │ └── build.yml └── androidbuildlib /.gitignore: -------------------------------------------------------------------------------- 1 | /libs 2 | /bin 3 | 4 | /.vscode 5 | /.idea 6 | *.iml -------------------------------------------------------------------------------- /.gitmodules: -------------------------------------------------------------------------------- 1 | [submodule "aria2"] 2 | path = aria2 3 | url = https://github.com/aria2/aria2 4 | [submodule "c-ares"] 5 | path = c-ares 6 | url = https://github.com/c-ares/c-ares 7 | [submodule "libexpat"] 8 | path = libexpat 9 | url = https://github.com/libexpat/libexpat 10 | [submodule "zlib"] 11 | path = zlib 12 | url = https://github.com/madler/zlib 13 | [submodule "openssl"] 14 | path = openssl 15 | url = https://github.com/openssl/openssl 16 | [submodule "libssh2"] 17 | path = libssh2 18 | url = https://github.com/libssh2/libssh2 19 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # aria2-android 2 | 3 | [![Build aria2](https://github.com/devgianlu/aria2-android/actions/workflows/build.yml/badge.svg)](https://github.com/devgianlu/aria2-android/actions/workflows/build.yml) 4 | 5 | All you need to cross-compile [aria2](https://github.com/aria2/aria2) for Android. 6 | 7 | ## Build 8 | 9 | Clone the repository with submodules (`--recurse-submodules`), install the Android NDK r23, set the `ANDROID_NDK_HOME` 10 | env variable and run `./build_all.sh`. 11 | 12 | This will compile aria2 for `armeavi-v7a`, `arm64-v8a`, `x86` and `x86_64`. The binaries can be found inside the `bin` 13 | folder. 14 | -------------------------------------------------------------------------------- /.github/workflows/build.yml: -------------------------------------------------------------------------------- 1 | name: Build aria2 2 | 3 | on: 4 | push: 5 | tags: 6 | - 'v*' 7 | 8 | jobs: 9 | build: 10 | runs-on: ubuntu-latest 11 | steps: 12 | - uses: actions/checkout@v2 13 | with: 14 | submodules: true 15 | - name: Setup NDK 16 | run: | 17 | sudo apt-get update 18 | sudo apt-get install -y autoconf automake autopoint autotools-dev libtool libxml2-dev libcppunit-dev 19 | wget https://dl.google.com/android/repository/android-ndk-r23b-linux.zip 20 | unzip -q android-ndk-r23b-linux.zip 21 | export ANDROID_NDK_HOME=`pwd`/android-ndk-r23b 22 | export PATH=$ANDROID_NDK_HOME/toolchains/llvm/prebuilt/linux-x86_64/bin:$PATH 23 | export SILENT=true 24 | - name: Build 25 | run: | 26 | ./build_all.sh 27 | file ./bin/armeabi-v7a/bin/aria2c 28 | file ./bin/arm64-v8a/bin/aria2c 29 | file ./bin/x86/bin/aria2c 30 | file ./bin/x86_64/bin/aria2c 31 | -------------------------------------------------------------------------------- /androidbuildlib: -------------------------------------------------------------------------------- 1 | #!/bin/bash -e 2 | 3 | print_help() 4 | { 5 | __text=" 6 | Configurable parameters 7 | out_path - target installation path to install generated library files for all archs, 8 | it need to be in relative path from the directory executing this script [default is libs] 9 | host_tag - host value that will build the library (hint: you can take a look for this value 10 | at your \$ANDROID_NDK_HOME/toolchains/llvm/prebuilt/ [default is linux-x86_64] 11 | minsdkversion - minimum sdk version to support, this is value of api level [default is 18] 12 | target_abis - target abis to build for, separated by space [default is \"armeabi-v7a x86 arm64-v8a x86_64\"] 13 | configure_params - additional params to pass to ./configure 14 | fresh_build - whether or not this is a fresh build, user might be using this when repeatitively build the same project over and over i.e. while debugging, so there's no need to keep re-execute './configure' and 'make clean' again. [default is true] 15 | no_host - whether ./configure should be called with the --host option [default is false] 16 | silent - whether the compilation should be less verbose [default is false] 17 | custom_silent - custom silent flag/option [default is \"--enable-silent-rules\"] 18 | " 19 | echo "$__text" 20 | } 21 | 22 | # print help 23 | if [ "$1" == "--help" ] 24 | then 25 | print_help 26 | exit 27 | fi 28 | 29 | # check for existence of configure, and Makefile 30 | if [ ! -e configure ] && { [ ! -e Makefile ] || [ ! -e makefile ]; } 31 | then 32 | echo "Cannot find either configure or Makefile file" 33 | exit 1 34 | fi 35 | 36 | out_path=libs 37 | # check system is linux or darwin 38 | if [ "$(uname)" == "Darwin" ]; then 39 | host_tag=darwin-x86_64 40 | else 41 | host_tag=linux-x86_64 42 | fi 43 | minsdkversion=18 44 | target_abis="armeabi-v7a x86 arm64-v8a x86_64" 45 | configure_params="" 46 | fresh_build=true 47 | no_host=false 48 | silent=false 49 | custom_silent="--enable-silent-rules" 50 | # support build zlib use the default value linux when build on macOS. 51 | chost="linux" 52 | 53 | for ARGUMENT in "$@" 54 | do 55 | KEY=$(echo $ARGUMENT | cut -f1 -d=) 56 | VALUE=$(echo $ARGUMENT | cut -f2- -d=) 57 | 58 | case "$KEY" in 59 | "no_host" ) no_host="${VALUE}" ;; 60 | "out_path" ) out_path="${VALUE}" ;; 61 | "host_tag" ) host_tag="${VALUE}" ;; 62 | "minsdkversion" ) minsdkversion="${VALUE}" ;; 63 | "target_abis" ) target_abis="${VALUE}" ;; 64 | "configure_params" ) configure_params="${VALUE}" ;; 65 | "fresh_build" ) fresh_build="${VALUE}" ;; 66 | "silent" ) silent="${VALUE}" ;; 67 | "custom_silent" ) custom_silent="${VALUE}" ;; 68 | *) 69 | echo "" 70 | echo "Unknown '$KEY' parameter" 71 | print_help 72 | exit 1 73 | ;; 74 | esac 75 | done 76 | 77 | echo "" 78 | echo "-Will use following setting-" 79 | echo "output = $out_path" 80 | echo "host_tag = $host_tag" 81 | echo "minsdkversion = $minsdkversion" 82 | echo "target_abis = $target_abis" 83 | echo "configure_params = $configure_params" 84 | echo "fresh_build = $fresh_build" 85 | echo "no_host = $no_host" 86 | echo "silent = $silent" 87 | echo "custom_silent = $custom_silent" 88 | echo "chost = $chost" 89 | echo "" 90 | 91 | # check to create installation dir of built library files 92 | if [ ! -d "$out_path" ] 93 | then 94 | mkdir "$out_path" 95 | 96 | for dir in $target_abis 97 | do 98 | if [ ! -d "$out_path"/"$dir" ] 99 | then 100 | mkdir "$out_path"/"$dir" 101 | fi 102 | done 103 | fi 104 | 105 | export TOOLCHAIN=$ANDROID_NDK_HOME/toolchains/llvm/prebuilt/$host_tag 106 | 107 | for target in $target_abis 108 | do 109 | if [ $target == "armeabi-v7a" ] 110 | then 111 | echo "prepare for armeabi-v7a" 112 | cc_prefix=armv7a-linux-androideabi$minsdkversion- 113 | support_prefix=arm-linux-androideabi- 114 | host=armv7a-linux-androideabi 115 | install_dir=`pwd`/"$out_path"/armeabi-v7a 116 | CFLAGS="${CFLAGS} -march=armv7-a -mfpu=neon -mfloat-abi=softfp -mthumb" 117 | elif [ $target == "x86" ] 118 | then 119 | echo "prepare for x86" 120 | cc_prefix=i686-linux-android$minsdkversion- 121 | support_prefix=i686-linux-android- 122 | host=i686-linux-android 123 | install_dir=`pwd`/"$out_path"/x86 124 | CFLAGS="${CFLAGS} -march=i686 -mtune=intel -mssse3 -mfpmath=sse -m32" 125 | elif [ $target == "arm64-v8a" ] 126 | then 127 | echo "prepare for arm64-v8a" 128 | cc_prefix=aarch64-linux-android$minsdkversion- 129 | support_prefix=aarch64-linux-android- 130 | host=aarch64-linux-android 131 | install_dir=`pwd`/"$out_path"/arm64-v8a 132 | else 133 | echo "prepare for x86_64" 134 | cc_prefix=x86_64-linux-android$minsdkversion- 135 | support_prefix=x86_64-linux-android- 136 | host=x86_64-linux-android 137 | install_dir=`pwd`/"$out_path"/x86_64 138 | CFLAGS="${CFLAGS} -march=x86-64 -msse4.2 -mpopcnt -m64 -mtune=intel" 139 | fi 140 | 141 | echo "" 142 | echo "cc_prefix = $cc_prefix" 143 | echo "support_prefix = $support_prefix" 144 | echo "host = $host" 145 | echo "install_dir = $install_dir" 146 | echo "CFLAGS = $CFLAGS" 147 | echo "" 148 | 149 | export AR=$TOOLCHAIN/bin/llvm-ar 150 | export CC=$TOOLCHAIN/bin/${cc_prefix}clang 151 | export AS=$CC 152 | export CXX=$TOOLCHAIN/bin/${cc_prefix}clang++ 153 | export LD=$TOOLCHAIN/bin/ld 154 | export RANLIB=$TOOLCHAIN/bin/llvm-ranlib 155 | export STRIP=$TOOLCHAIN/bin/llvm-strip 156 | export CHOST=$chost 157 | 158 | export LDFLAGS="-Wl,-z,max-page-size=16384" 159 | 160 | # only confiture and make clean when there's no flag telling to ignore 161 | if [ "$fresh_build" == "true" ] 162 | then 163 | VERBOSE_FLAGS="" 164 | if [ "$silent" == "true" ] 165 | then 166 | VERBOSE_FLAGS="-s V=0" 167 | configure_params="$custom_silent $configure_params" 168 | fi 169 | 170 | if [ "$no_host" == "true" ] 171 | then 172 | ./configure --prefix="$install_dir" $configure_params || exit 173 | else 174 | ./configure --host="$host" --prefix="$install_dir" $configure_params || exit 175 | fi 176 | 177 | make $VERBOSE_FLAGS clean || exit 178 | fi 179 | 180 | make -j$(nproc) $VERBOSE_FLAGS || exit 181 | make install || exit 182 | echo "Done building $target" 183 | done 184 | 185 | echo "All done" 186 | --------------------------------------------------------------------------------