Skip to content

Commit 1b6d317

Browse files
build: add android test build
Signed-off-by: DreamConnected <1487442471@qq.com>
1 parent f019de6 commit 1b6d317

11 files changed

Lines changed: 163 additions & 11 deletions

File tree

.github/workflows/android.yml

Lines changed: 79 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,79 @@
1+
name: Android-arm64-Builds
2+
on:
3+
workflow_dispatch:
4+
inputs:
5+
ndk_version:
6+
description: 'Android NDK version'
7+
required: false
8+
default: 'r28c'
9+
10+
jobs:
11+
build:
12+
runs-on: ubuntu-latest
13+
steps:
14+
- uses: actions/checkout@v4
15+
16+
- name: Set up Android NDK
17+
uses: nttld/setup-ndk@v1
18+
with:
19+
ndk-version: ${{ github.event.inputs.ndk_version || 'r28c' }}
20+
21+
- name: Install dependencies
22+
run: |
23+
sudo apt-get install -y -qq build-essential pipx python3-venv pkg-config cmake docbook2x \
24+
python3-pip pipx jq
25+
sudo npm install -g conventional-changelog-cli
26+
conventional-changelog -o CHANGELOG.md -r 2
27+
pipx ensurepath
28+
pipx install meson==0.61
29+
pipx install ninja
30+
31+
- name: Download Dependencies
32+
run: |
33+
libepoxy=$(curl -s https://api.github.com/repos/DreamConnected/libepoxy-dev/releases/latest | grep browser_download_url | cut -d'"' -f4 |grep -E 'zip$')
34+
libepoxy_file=$(curl -s https://api.github.com/repos/DreamConnected/libepoxy-dev/releases/latest | grep name | cut -d'"' -f4 |grep -E 'zip$')
35+
wget -q ${libepoxy} && sudo unzip -q -o ${libepoxy_file} -d / && echo 1/1 ${libepoxy} ${libepoxy_file}
36+
37+
- name: Build virglrenderer for Android
38+
run: |
39+
sed -i "s|android-ndk-r28c|$ANDROID_NDK_HOME|g" aarch64-android-api30.txt
40+
export PKG_CONFIG_PATH=/data/share/lib/pkgconfig:/data/share/lib64/pkgconfig:$PKG_CONFIG_PATH
41+
42+
meson setup build \
43+
-Dvenus=true \
44+
-Dvulkan-dload=true \
45+
-Dplatforms=egl \
46+
-Dvideo=false \
47+
-Drender-server-worker=thread \
48+
-Ddrm-renderers= \
49+
-Dtests=false \
50+
-Dfuzzer=false \
51+
-Dvalgrind=false \
52+
-Dtracing=none \
53+
--prefix=/data/share \
54+
--cross-file=aarch64-android-api30.txt
55+
56+
meson compile -C build
57+
sudo /usr/local/bin/ninja -C build install
58+
echo "RELEASE_TAG=$(meson introspect meson.build --projectinfo | jq -r '.version')-$(git log -1 --format=%h)" >> $GITHUB_ENV
59+
60+
- name: Upload artifacts virglrenderer
61+
uses: actions/upload-artifact@v4.3.1
62+
with:
63+
name: android-${{ github.event.inputs.target_arch || 'aarch64' }}-virglrenderer
64+
path: /data/share/*
65+
66+
- name: Create a TAR file for artifact
67+
run: |
68+
tar -czvf android-${{ github.event.inputs.target_arch || 'aarch64' }}-api30-virglrenderer.tar.gz -C /data/share .
69+
70+
- name: Create Release and Upload Release Asset
71+
uses: softprops/action-gh-release@v1
72+
with:
73+
tag_name: ${{ env.RELEASE_TAG }}
74+
name: Release ${{ env.RELEASE_TAG }}
75+
body_path: CHANGELOG.md
76+
draft: false
77+
prerelease: false
78+
files: |
79+
android-${{ github.event.inputs.target_arch || 'aarch64' }}-api30-virglrenderer.tar.gz

.github/workflows/sync.yml

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
name: Sync Fork
2+
3+
on:
4+
schedule:
5+
- cron: '0 0 1 * *' # every first day of month 00:00
6+
workflow_dispatch: # on button click
7+
8+
jobs:
9+
sync:
10+
11+
runs-on: ubuntu-latest
12+
13+
steps:
14+
- uses: tgymnich/fork-sync@v2.0.10
15+
with:
16+
owner: Container-On-Android
17+
base: main
18+
head: main
19+
pr_title: "Merge upstream branch 'main'"
20+
pr_message: "Merge branch 'lxc:main' into main"
21+
auto_merge: true
22+
merge_method: rebase
23+
ignore_fail: true

aarch64-android-api30.txt

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
[binaries]
2+
c = 'android-ndk-r28c/toolchains/llvm/prebuilt/linux-x86_64/bin/aarch64-linux-android30-clang'
3+
cpp = 'android-ndk-r28c/toolchains/llvm/prebuilt/linux-x86_64/bin/aarch64-linux-android30-clang++'
4+
ar = 'android-ndk-r28c/toolchains/llvm/prebuilt/linux-x86_64/bin/llvm-ar'
5+
as = 'android-ndk-r28c/toolchains/llvm/prebuilt/linux-x86_64/bin/llvm-as'
6+
ld = 'android-ndk-r28c/toolchains/llvm/prebuilt/linux-x86_64/bin/llvm-ld'
7+
strip = 'android-ndk-r28c/toolchains/llvm/prebuilt/linux-x86_64/bin/llvm-strip'
8+
ranlib = 'android-ndk-r28c/toolchains/llvm/prebuilt/linux-x86_64/bin/llvm-ranlib'
9+
pkgconfig = '/usr/bin/pkg-config'
10+
cmake = '/usr/bin/cmake'
11+
12+
[host_machine]
13+
system = 'linux'
14+
cpu_family = 'aarch64'
15+
cpu = 'aarch64'
16+
endian = 'little'
17+
18+
[target_machine]
19+
system = 'android'
20+
cpu_family = 'aarch64'
21+
cpu = 'aarch64'
22+
endian = 'little'

config.h.meson

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -55,6 +55,7 @@
5555
#mesondefine ENABLE_VIDEO
5656
#mesondefine ENABLE_TRACING
5757
#mesondefine ENABLE_TESTS
58+
#mesondefine IS_BIONIC
5859
#mesondefine UTIL_ARCH_LITTLE_ENDIAN
5960
#mesondefine UTIL_ARCH_BIG_ENDIAN
6061
#mesondefine PIPE_ARCH_X86

meson.build

Lines changed: 12 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -93,6 +93,10 @@ conf_data.set('_GNU_SOURCE', 1)
9393
# APIs. Unstable APIs may be changed or removed without a notice.
9494
conf_data.set('VIRGL_RENDERER_UNSTABLE_APIS', 1)
9595

96+
## Android
97+
have = cc.get_id().contains('clang') and cc.has_header('android/log.h')
98+
conf_data.set10('IS_BIONIC', have)
99+
96100
drm_renderers = get_option('drm-renderers')
97101

98102
with_drm_msm = drm_renderers.contains('msm')
@@ -116,7 +120,12 @@ if with_drm_renderers
116120
conf_data.set('ENABLE_DRM', 1)
117121
endif
118122

119-
libdrm_dep = dependency('libdrm', version : '>=2.4.50', required: with_drm_renderers or get_option('video'))
123+
if conf_data.get('IS_BIONIC') == true
124+
libdrm_dep = dependency('libdrm', required: false)
125+
liblog_dep = cc.find_library('log', required: true)
126+
else
127+
libdrm_dep = dependency('libdrm', version : '>=2.4.50', required: with_drm_renderers or get_option('video'))
128+
endif
120129
libdrm_amdgpu_dep = dependency('libdrm_amdgpu', version : '>=2.4.121', required: with_drm_amdgpu)
121130
conf_data.set('ENABLE_LIBDRM', libdrm_dep.found())
122131
drm_uapi_dep = declare_dependency(
@@ -172,6 +181,7 @@ endif
172181

173182
with_host_windows = host_machine.system() == 'windows'
174183
with_host_darwin = host_machine.system() == 'darwin'
184+
with_target_android = target_machine.system() == 'android'
175185

176186
if thread_dep.found() and not with_host_windows
177187
conf_data.set('HAVE_PTHREAD', 1)
@@ -279,7 +289,7 @@ have_glx = false
279289

280290
if with_egl
281291
if cc.has_header('epoxy/egl.h', dependencies: epoxy_dep) and epoxy_dep.get_variable(pkgconfig: 'epoxy_has_egl') == '1'
282-
if with_host_windows or with_host_darwin
292+
if with_host_windows or with_host_darwin or with_target_android
283293
have_egl = true
284294
else
285295
if libdrm_dep.found()

src/mesa/util/os_misc.c

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -54,9 +54,11 @@
5454

5555
#if DETECT_OS_ANDROID
5656
# define LOG_TAG "MESA"
57-
# include <unistd.h>
58-
# include <log/log.h>
59-
# include <cutils/properties.h>
57+
# include <android/log.h>
58+
# include <sys/system_properties.h>
59+
# define LOG_PRI(priority, tag, ...) __android_log_print(priority, tag, __VA_ARGS__)
60+
# define PROPERTY_VALUE_MAX PROP_VALUE_MAX
61+
# define PROPERTY_KEY_MAX PROP_NAME_MAX
6062
#elif DETECT_OS_LINUX || DETECT_OS_CYGWIN || DETECT_OS_SOLARIS || DETECT_OS_HURD
6163
# include <unistd.h>
6264
#elif DETECT_OS_OPENBSD || DETECT_OS_FREEBSD
@@ -188,7 +190,7 @@ os_get_android_option(const char *name)
188190
}
189191

190192
const char *opt = NULL;
191-
int len = property_get(key, value, NULL);
193+
int len = __system_property_get(key, value);
192194
if (len > 1) {
193195
opt = ralloc_strdup(options_tbl, value);
194196
}

src/meson.build

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -141,11 +141,16 @@ video_sources = [
141141
virgl_depends = [
142142
gallium_dep,
143143
epoxy_dep,
144-
libdrm_dep,
145144
thread_dep,
146145
m_dep,
147146
]
148147

148+
if conf_data.get('IS_BIONIC') == true
149+
virgl_depends += [liblog_dep]
150+
else
151+
virgl_depends += [libdrm_dep]
152+
endif
153+
149154
if with_tracing == 'perfetto'
150155
virgl_depends += [vperfetto_min_dep]
151156
endif

src/vrend/vrend_winsys.c

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -55,7 +55,7 @@ static struct virgl_glx *glx_info = NULL;
5555
int vrend_winsys_init(uint32_t flags, int preferred_fd)
5656
{
5757
if (flags & VIRGL_RENDERER_USE_EGL) {
58-
#ifdef ENABLE_GBM
58+
#if defined(ENABLE_GBM) && !IS_BIONIC
5959
/*
6060
* If the user specifies a preferred DRM fd and we can't use it, fail. If the user doesn't
6161
* specify an fd, it's possible to initialize EGL without one.
@@ -75,6 +75,13 @@ int vrend_winsys_init(uint32_t flags, int preferred_fd)
7575
return -1;
7676
}
7777

78+
use_context = CONTEXT_EGL;
79+
#elif IS_BIONIC
80+
(void)preferred_fd;
81+
egl = virgl_egl_init(NULL, flags & VIRGL_RENDERER_USE_SURFACELESS,
82+
flags & VIRGL_RENDERER_USE_GLES);
83+
if (!egl) return -1;
84+
7885
use_context = CONTEXT_EGL;
7986
#else
8087
(void)preferred_fd;

src/vrend/vrend_winsys_egl.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,7 @@
4141
#include <stdbool.h>
4242
#include <unistd.h>
4343

44-
#ifdef ENABLE_LIBDRM
44+
#if defined(ENABLE_LIBDRM) && !IS_BIONIC
4545
#include <xf86drm.h>
4646
#endif
4747

vtest/meson.build

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -37,11 +37,14 @@ vtest_depends = [
3737
libvirglrenderer_dep,
3838
gallium_dep,
3939
thread_dep,
40-
libdrm_dep,
4140
drm_uapi_dep,
4241
mesa_dep,
4342
]
4443

44+
if conf_data.get('IS_BIONIC') == false
45+
virgl_depends += [libdrm_dep]
46+
endif
47+
4548
if with_tracing == 'percetto'
4649
vtest_depends += [percetto_dep]
4750
endif

0 commit comments

Comments
 (0)