diff --git a/meson.build b/meson.build index 52b3f581a..e8d57e49d 100644 --- a/meson.build +++ b/meson.build @@ -17,6 +17,8 @@ pymod = import('python') python = pymod.find_installation('python3', required: true) cc = meson.get_compiler('cpp') +lib_dir = meson.current_source_dir() / 'thirdparty/lib' / host_machine.system() / host_machine.cpu() +inc_dir = 'thirdparty/include' / host_machine.system() global_cpp_defs = [ '-DSPLIT_SAVES', @@ -28,13 +30,21 @@ global_cpp_defs = [ '-DDEBUG', ] -if host_machine.system() == 'linux' +if host_machine.system() == 'linux' or host_machine.system() == 'android' global_cpp_defs += ['-Dlinux', '-D__linux', '-D__linux__'] endif +if host_machine.system() == 'android' + global_cpp_defs += ['-D__android__'] +endif + if get_option('renderer') == 'gles' global_cpp_defs += ['-DGLES'] - gl_dep = dependency('glesv2', required: true) + if host_machine.system() == 'android' + gl_dep = cc.find_library('GLESv3', required: true ) + else + gl_dep = dependency('glesv2', required: true) + endif glu_dep = dependency('', required: false) else gl_dep = dependency('gl', required: true) @@ -69,10 +79,21 @@ global_cpp_args = [ ] add_project_arguments(global_cpp_args, language: 'cpp') -sdl2_dep = dependency('sdl2') +if host_machine.system() == 'android' + sdl2_dep = declare_dependency( + dependencies: cc.find_library('SDL2', dirs: lib_dir, required: true ), + include_directories: inc_dir) +else + sdl2_dep = dependency('sdl2') +endif thread_dep = dependency('threads') dl_dep = cc.find_library('dl', required: true) -glm_dep = dependency('glm') + +if host_machine.system() == 'android' + glm_dep = declare_dependency(include_directories: inc_dir) +else + glm_dep = dependency('glm') +endif stb = subproject('stb').get_variable('stb_inc') stb_dep = declare_dependency(include_directories: stb) diff --git a/scripts/android.txt b/scripts/android.txt new file mode 100644 index 000000000..ef33861ff --- /dev/null +++ b/scripts/android.txt @@ -0,0 +1,23 @@ +[constants] +ndk_home = 'set_path_to_you_ndk' +ndk_api = 'set_api_ndk' + +[properties] +skip_sanity_check = true + +[binaries] +c = ndk_home / 'toolchains/llvm/prebuilt/linux-x86_64/bin/aarch64-linux-android' + ndk_api + '-clang' +cpp = ndk_home / 'toolchains/llvm/prebuilt/linux-x86_64/bin/aarch64-linux-android' + ndk_api + '-clang++' +ar = ndk_home / 'toolchains/llvm/prebuilt/linux-x86_64/bin/llvm-ar' +strip = ndk_home / 'toolchains/llvm/prebuilt/linux-x86_64/bin/llvm-strip' +sys_root = ndk_home / 'toolchains/llvm/prebuilt/linux-x86_64/sysroot' +as = ndk_home / 'toolchains/llvm/prebuilt/linux-x86_64/bin/llvm-as' +ranlib = ndk_home / 'toolchains/llvm/prebuilt/linux-x86_64/bin/llvm-ranlib' +ld = ndk_home / 'toolchains/llvm/prebuilt/linux-x86_64/bin/llvm-ld' +pkg_config = 'false' + +[host_machine] +system = 'android' +cpu_family = 'arm' +cpu = 'aarch64' +endian = 'little' \ No newline at end of file diff --git a/targets/app/meson.build b/targets/app/meson.build index db074a2c6..84f34fc2a 100644 --- a/targets/app/meson.build +++ b/targets/app/meson.build @@ -29,7 +29,7 @@ platform_sources = run_command( ).stdout().strip().split('\n') # linux-specific files -if host_machine.system() == 'linux' +if host_machine.system() == 'linux' or host_machine.system() == 'android' platform_sources += run_command( 'sh', '-c', 'find "' diff --git a/targets/minecraft/meson.build b/targets/minecraft/meson.build index a01210c79..5bd6f814e 100644 --- a/targets/minecraft/meson.build +++ b/targets/minecraft/meson.build @@ -64,8 +64,16 @@ lib_minecraft = static_library('minecraft', cpp_args : global_cpp_args + global_cpp_defs, ) +_inc_dir = '../../' / inc_dir + zlib_dep = dependency('zlib') -crypto_dep = dependency('libcrypto') # for MD5 in Hasher.cpp on Linux +if host_machine.system() == 'android' + crypto_dep = declare_dependency( + dependencies: cc.find_library('crypto', dirs: lib_dir, required: true ), + include_directories: _inc_dir) +else + crypto_dep = dependency('libcrypto') # for MD5 in Hasher.cpp on Linux +endif minecraft_dep = declare_dependency( link_with : lib_minecraft, diff --git a/targets/platform/meson.build b/targets/platform/meson.build index 893bcf60c..84a86f7c6 100644 --- a/targets/platform/meson.build +++ b/targets/platform/meson.build @@ -1,4 +1,5 @@ platform_inc = include_directories('.') +_inc_dir = '../../' / inc_dir _threads = dependency('threads') lib_platform_core = static_library('platform_core', @@ -14,16 +15,39 @@ platform_dep = declare_dependency( ) # SDL2-based platform implementations (formerly 4J.* modules) -_sdl2 = dependency('sdl2') +if host_machine.system() == 'android' + _sdl2 = declare_dependency( + dependencies: cc.find_library('SDL2', dirs: lib_dir, required: true ), + include_directories: _inc_dir) +else + _sdl2 = dependency('sdl2') +endif _defs = [] if get_option('renderer') == 'gles' - _gl = dependency('glesv2', required: true) + if host_machine.system() == 'android' + _gl = cc.find_library('GLESv3', required: true ) + _egl = cc.find_library('EGL', required: true ) + else + _gl = dependency('glesv2', required: true) + endif _defs += ['-DGLES'] else _gl = dependency('gl', required: true) endif +deps = [ + _sdl2, + _gl, + _threads, + glm_dep, + stb_dep, +] + +if host_machine.system() == 'android' + deps += _egl +endif + sdl2_sources = files( 'sdl2/Input.cpp', 'sdl2/Profile.cpp', @@ -35,7 +59,7 @@ sdl2_sources = files( lib_platform_sdl2 = static_library('platform_sdl2', sdl2_sources, include_directories: [platform_inc, include_directories('sdl2')], - dependencies: [_sdl2, _gl, _threads, glm_dep, stb_dep], + dependencies: deps, cpp_args: _defs + global_cpp_args + global_cpp_defs, ) @@ -44,7 +68,7 @@ lib_platform_sdl2 = static_library('platform_sdl2', render_dep = declare_dependency( link_with: lib_platform_sdl2, include_directories: [platform_inc, include_directories('sdl2')], - dependencies: [_sdl2, _gl, _threads, glm_dep], + dependencies: deps, ) input_dep = render_dep profile_dep = render_dep