Skip to content

Commit 9d09cdb

Browse files
committed
fix: fix android build, by correctly setting some defines
1 parent 939ca0c commit 9d09cdb

File tree

3 files changed

+48
-1
lines changed

3 files changed

+48
-1
lines changed

platforms/android/app/jni/Application.mk

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,3 +11,7 @@ APP_PLATFORM := android-35
1111
# support 16KB page sizes:
1212
# see: https://developer.android.com/guide/practices/page-sizes
1313
APP_SUPPORT_FLEXIBLE_PAGE_SIZES := true
14+
15+
# support weak api defs:
16+
# see https://developer.android.com/ndk/guides/using-newer-apis
17+
APP_WEAK_API_DEFS := true

tools/dependencies/meson.build

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -384,7 +384,14 @@ if build_application
384384
curl_cpp_wrapper = dependency(
385385
'cpr',
386386
required: true,
387-
default_options: {'tests': 'disabled'},
387+
default_options: {
388+
'tests': 'disabled',
389+
'curl:tests': 'disabled',
390+
'curl:unittests': 'disabled',
391+
'curl:bearer-auth': 'enabled',
392+
'curl:brotli': 'enabled',
393+
'curl:libz': 'enabled',
394+
},
388395
)
389396

390397
graphics_lib += {

tools/options/meson.build

Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,42 @@ if meson.is_cross_build() and host_machine.system() == 'serenity'
3434
]
3535
core_lib += {'compile_args': temp}
3636
temp = 0
37+
elif meson.is_cross_build() and host_machine.system() == 'android'
38+
cpp = meson.get_compiler('cpp')
39+
target_android_api = '35'
40+
41+
android_api = cpp.get_define(
42+
'__ANDROID_API__',
43+
prefix: '#include <features.h>',
44+
).strip('"')
45+
assert(
46+
android_api != '',
47+
'failed to get android_api version',
48+
)
49+
50+
android_compile_args = []
51+
android_link_args = []
52+
53+
# APP_SUPPORT_FLEXIBLE_PAGE_SIZES
54+
android_link_args += '-Wl,-z,max-page-size=16384'
55+
56+
if android_api != target_android_api
57+
android_compile_args += ('-D__ANDROID_API__=' + target_android_api)
58+
endif
59+
60+
android_compile_args += [
61+
'-D__ANDROID_UNAVAILABLE_SYMBOLS_ARE_WEAK__',
62+
'-Werror=unguarded-availability',
63+
]
64+
65+
if not meson.is_subproject()
66+
add_global_link_arguments(android_link_args, language: ['cpp'])
67+
add_global_arguments(android_compile_args, language: ['cpp'])
68+
else
69+
add_project_link_arguments(android_link_args, language: ['cpp'])
70+
add_project_arguments(android_compile_args, language: ['cpp'])
71+
72+
endif
3773
endif
3874

3975
cpp = meson.get_compiler('cpp')

0 commit comments

Comments
 (0)