mirror of
https://github.com/bol-van/zapret.git
synced 2024-11-29 21:40:52 +03:00
github: build for Android
This commit is contained in:
parent
a8432a3caa
commit
30443ed31d
98
.github/workflows/build.yml
vendored
98
.github/workflows/build.yml
vendored
@ -281,9 +281,77 @@ jobs:
|
|||||||
path: zapret-*.zip
|
path: zapret-*.zip
|
||||||
if-no-files-found: error
|
if-no-files-found: error
|
||||||
|
|
||||||
|
build-android:
|
||||||
|
name: Android ${{ matrix.abi }}
|
||||||
|
runs-on: ubuntu-latest
|
||||||
|
strategy:
|
||||||
|
matrix:
|
||||||
|
include:
|
||||||
|
- abi: armeabi-v7a
|
||||||
|
target: armv7a-linux-androideabi
|
||||||
|
- abi: arm64-v8a
|
||||||
|
target: aarch64-linux-android
|
||||||
|
- abi: x86
|
||||||
|
target: i686-linux-android
|
||||||
|
- abi: x86_64
|
||||||
|
target: x86_64-linux-android
|
||||||
|
steps:
|
||||||
|
- name: Checkout
|
||||||
|
uses: actions/checkout@v4
|
||||||
|
with:
|
||||||
|
path: zapret
|
||||||
|
|
||||||
|
- name: Build
|
||||||
|
env:
|
||||||
|
ABI: ${{ matrix.abi }}
|
||||||
|
TARGET: ${{ matrix.target }}
|
||||||
|
run: |
|
||||||
|
DEPS_DIR=$GITHUB_WORKSPACE/deps
|
||||||
|
export TOOLCHAIN=$ANDROID_NDK_HOME/toolchains/llvm/prebuilt/linux-x86_64
|
||||||
|
export API=21
|
||||||
|
export CC="$TOOLCHAIN/bin/clang --target=$TARGET$API"
|
||||||
|
export AR=$TOOLCHAIN/bin/llvm-ar
|
||||||
|
export AS=$CC
|
||||||
|
export LD=$TOOLCHAIN/bin/ld
|
||||||
|
export RANLIB=$TOOLCHAIN/bin/llvm-ranlib
|
||||||
|
export STRIP=$TOOLCHAIN/bin/llvm-strip
|
||||||
|
export PKG_CONFIG_PATH=$DEPS_DIR/lib/pkgconfig
|
||||||
|
|
||||||
|
# optimize for size
|
||||||
|
export CFLAGS="-Os -flto=auto"
|
||||||
|
export LDFLAGS="-Os"
|
||||||
|
|
||||||
|
# netfilter libs
|
||||||
|
wget -qO- https://www.netfilter.org/pub/libnfnetlink/libnfnetlink-1.0.2.tar.bz2 | tar -xj
|
||||||
|
wget -qO- https://www.netfilter.org/pub/libmnl/libmnl-1.0.5.tar.bz2 | tar -xj
|
||||||
|
wget -qO- https://www.netfilter.org/pub/libnetfilter_queue/libnetfilter_queue-1.0.5.tar.bz2 | tar -xj
|
||||||
|
patch -p1 -d libnetfilter_queue-* -i ../zapret/.github/workflows/libnetfilter_queue-android.patch
|
||||||
|
|
||||||
|
for i in libmnl libnfnetlink libnetfilter_queue ; do
|
||||||
|
(
|
||||||
|
cd $i-*
|
||||||
|
CFLAGS="$CFLAGS -Wno-implicit-function-declaration" \
|
||||||
|
./configure --prefix= --host=$TARGET --enable-static --disable-shared --disable-dependency-tracking
|
||||||
|
make install -j$(nproc) DESTDIR=$DEPS_DIR
|
||||||
|
)
|
||||||
|
sed -i "s|^prefix=.*|prefix=$DEPS_DIR|g" $DEPS_DIR/lib/pkgconfig/$i.pc
|
||||||
|
done
|
||||||
|
|
||||||
|
# zapret
|
||||||
|
CFLAGS="$CFLAGS -I$DEPS_DIR/include" LDFLAGS="$LDFLAGS -L$DEPS_DIR/lib" \
|
||||||
|
make -C zapret android -j$(nproc)
|
||||||
|
zip zapret-android-$ABI.zip -j zapret/binaries/my/*
|
||||||
|
|
||||||
|
- name: Upload artifacts
|
||||||
|
uses: actions/upload-artifact@v4
|
||||||
|
with:
|
||||||
|
name: zapret-android-${{ matrix.abi }}
|
||||||
|
path: zapret-*.zip
|
||||||
|
if-no-files-found: error
|
||||||
|
|
||||||
release:
|
release:
|
||||||
if: github.event_name == 'push' && startsWith(github.ref, 'refs/tags/v')
|
if: github.event_name == 'push' && startsWith(github.ref, 'refs/tags/v')
|
||||||
needs: [ build-linux, build-windows, build-macos, build-freebsd ]
|
needs: [ build-linux, build-windows, build-macos, build-freebsd, build-android ]
|
||||||
permissions:
|
permissions:
|
||||||
contents: write
|
contents: write
|
||||||
runs-on: ubuntu-latest
|
runs-on: ubuntu-latest
|
||||||
@ -342,18 +410,22 @@ jobs:
|
|||||||
if [ -d $dir ]; then
|
if [ -d $dir ]; then
|
||||||
echo "Processing $dir"
|
echo "Processing $dir"
|
||||||
case $dir in
|
case $dir in
|
||||||
*-freebsd-x86_64 ) run_dir freebsd-x64 ;;
|
*-android-arm64-v8a ) run_dir android-aarch64 ;;
|
||||||
*-linux-arm ) run_dir arm ;;
|
*-android-armeabi-v7a ) run_dir android-arm ;;
|
||||||
*-linux-arm64 ) run_dir aarch64 ;;
|
*-android-x86 ) run_dir android-x86 ;;
|
||||||
*-linux-mips64 ) run_dir mips64r2-msb ;;
|
*-android-x86_64 ) run_dir android-x86_64 ;;
|
||||||
*-linux-mipselsf ) run_dir mips32r1-lsb ;;
|
*-freebsd-x86_64 ) run_dir freebsd-x64 ;;
|
||||||
*-linux-mipssf ) run_dir mips32r1-msb ;;
|
*-linux-arm ) run_dir arm ;;
|
||||||
*-linux-ppc ) run_dir ppc ;;
|
*-linux-arm64 ) run_dir aarch64 ;;
|
||||||
*-linux-x86 ) run_dir x86 ;;
|
*-linux-mips64 ) run_dir mips64r2-msb ;;
|
||||||
*-linux-x86_64 ) run_dir x86_64 ;;
|
*-linux-mipselsf ) run_dir mips32r1-lsb ;;
|
||||||
*-mac-x64 ) run_dir mac64 ;;
|
*-linux-mipssf ) run_dir mips32r1-msb ;;
|
||||||
*-win-x86 ) run_dir win32 ;;
|
*-linux-ppc ) run_dir ppc ;;
|
||||||
*-win-x86_64 ) run_dir win64 ;;
|
*-linux-x86 ) run_dir x86 ;;
|
||||||
|
*-linux-x86_64 ) run_dir x86_64 ;;
|
||||||
|
*-mac-x64 ) run_dir mac64 ;;
|
||||||
|
*-win-x86 ) run_dir win32 ;;
|
||||||
|
*-win-x86_64 ) run_dir win64 ;;
|
||||||
esac
|
esac
|
||||||
fi
|
fi
|
||||||
done
|
done
|
||||||
|
41
.github/workflows/libnetfilter_queue-android.patch
vendored
Normal file
41
.github/workflows/libnetfilter_queue-android.patch
vendored
Normal file
@ -0,0 +1,41 @@
|
|||||||
|
--- a/src/extra/pktbuff.c
|
||||||
|
+++ b/src/extra/pktbuff.c
|
||||||
|
@@ -14,7 +14,7 @@
|
||||||
|
#include <string.h> /* for memcpy */
|
||||||
|
#include <stdbool.h>
|
||||||
|
|
||||||
|
-#include <netinet/if_ether.h>
|
||||||
|
+#include <linux/if_ether.h>
|
||||||
|
#include <netinet/ip.h>
|
||||||
|
#include <netinet/tcp.h>
|
||||||
|
|
||||||
|
--- a/src/nlmsg.c
|
||||||
|
+++ b/src/nlmsg.c
|
||||||
|
@@ -21,7 +21,7 @@
|
||||||
|
|
||||||
|
#include <linux/netfilter/nfnetlink_queue.h>
|
||||||
|
|
||||||
|
-#include <libnetfilter_queue/libnetfilter_queue.h>
|
||||||
|
+// #include <libnetfilter_queue/libnetfilter_queue.h>
|
||||||
|
|
||||||
|
#include "internal.h"
|
||||||
|
|
||||||
|
--- a/src/extra/tcp.c
|
||||||
|
+++ b/src/extra/tcp.c
|
||||||
|
@@ -139,12 +139,16 @@ void nfq_tcp_compute_checksum_ipv6(struc
|
||||||
|
* (union is compatible to any of its members)
|
||||||
|
* This means this part of the code is -fstrict-aliasing safe now.
|
||||||
|
*/
|
||||||
|
+#ifndef __ANDROID__
|
||||||
|
union tcp_word_hdr {
|
||||||
|
struct tcphdr hdr;
|
||||||
|
uint32_t words[5];
|
||||||
|
};
|
||||||
|
+#endif
|
||||||
|
|
||||||
|
+#ifndef tcp_flag_word
|
||||||
|
#define tcp_flag_word(tp) ( ((union tcp_word_hdr *)(tp))->words[3])
|
||||||
|
+#endif
|
||||||
|
|
||||||
|
/**
|
||||||
|
* nfq_pkt_snprintf_tcp_hdr - print tcp header into one buffer in a humnan
|
Loading…
Reference in New Issue
Block a user