Repository navigation
76 lines (65 loc) · 2.52 KB
/
Copy pathbuild.yml
File metadata and controls
76 lines (65 loc) · 2.52 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
name: Android Static Build Libcap
on:
workflow_dispatch:
inputs:
target_arch:
description: 'Target architecture (aarch64/arm/x86_64/i686)'
required: false
default: 'aarch64'
ndk_version:
description: 'Android NDK version'
required: false
default: 'r27c'
android_api:
description: 'Android API level'
required: false
default: '30'
jobs:
build:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- name: Set up Android NDK
uses: nttld/setup-ndk@v1
with:
ndk-version: ${{ github.event.inputs.ndk_version || 'r27c' }}
- name: Install dependencies
run: sudo apt-get install -y gcc perl
- name: Clone libcap
run: |
git clone https://kernel.googlesource.com/pub/scm/linux/kernel/git/morgan/libcap libcap
- name: Set build parameters
id: vars
run: |
case "${{ github.event.inputs.target_arch || 'aarch64' }}" in
aarch64) target="aarch64-linux-android" ;;
arm) target="armv7a-linux-androideabi" ;;
x86_64) target="x86_64-linux-android" ;;
i686) target="i686-linux-android" ;;
*) echo "Unsupported architecture"; exit 1 ;;
esac
echo "target=$target" >> $GITHUB_OUTPUT
echo "api=${{ github.event.inputs.android_api || '30' }}" >> $GITHUB_OUTPUT
- name: Build selected tools (static)
run: |
cd libcap
export NDK_TOOLCHAIN=$ANDROID_NDK_HOME/toolchains/llvm/prebuilt/linux-x86_64/bin
export TARGET=${{ steps.vars.outputs.target }}
export API=${{ steps.vars.outputs.api }}
find ./* -type f -exec sed -i 's/-lpthread/-lc/g' {} \;
sed -i 's/ifeq ($(GOLANG),yes)/ifeq ($(GOLANG),no)/g' Makefile
sed -i 's|(inc_prefix)/include|(inc_prefix)/usr/include|g' libcap/Makefile
BUILD_CC=gcc make \
CC="$NDK_TOOLCHAIN/clang --target=$TARGET$API" \
AR=$NDK_TOOLCHAIN/llvm-ar \
RANLIB=$NDK_TOOLCHAIN/llvm-ranlib \
OBJCOPY=$NDK_TOOLCHAIN/llvm-objcopy \
PREFIX=/data/sysroot \
prefix=/data/sysroot
sudo make install DESTDIR=/data/sysroot
sudo find /data/sysroot -type f \( -executable -o -name "*.a" \) -exec $NDK_TOOLCHAIN/llvm-strip --strip-all {} \;
- name: Upload sbin binaries
uses: actions/upload-artifact@v4.3.1
with:
name: android-${{ github.event.inputs.target_arch || 'aarch64' }}-libcap-sbin
path: /data/sysroot/sbin/*