2022-08-08 10:17:54 +02:00
|
|
|
#!/usr/bin/env -S python3 -u
|
2014-02-18 08:33:06 +01:00
|
|
|
|
2014-06-21 11:04:03 +02:00
|
|
|
import os, os.path
|
2023-12-13 19:01:30 +01:00
|
|
|
import shutil
|
2015-11-21 00:17:00 +01:00
|
|
|
import sys, subprocess
|
2014-02-18 08:33:06 +01:00
|
|
|
|
2018-03-04 20:43:59 +01:00
|
|
|
if len(sys.argv) < 4:
|
|
|
|
print("Usage: build.py SDK_PATH NDK_PATH ABI [configure_args...]", file=sys.stderr)
|
2014-02-18 08:33:06 +01:00
|
|
|
sys.exit(1)
|
|
|
|
|
|
|
|
sdk_path = sys.argv[1]
|
|
|
|
ndk_path = sys.argv[2]
|
2018-03-04 20:43:59 +01:00
|
|
|
android_abi = sys.argv[3]
|
|
|
|
configure_args = sys.argv[4:]
|
2014-02-18 08:33:06 +01:00
|
|
|
|
2024-01-18 06:36:49 +01:00
|
|
|
if not os.path.isfile(os.path.join(sdk_path, 'licenses', 'android-sdk-license')):
|
2022-03-14 18:49:44 +01:00
|
|
|
print("SDK not found in", sdk_path, file=sys.stderr)
|
2014-02-18 08:33:06 +01:00
|
|
|
sys.exit(1)
|
|
|
|
|
|
|
|
if not os.path.isdir(ndk_path):
|
|
|
|
print("NDK not found in", ndk_path, file=sys.stderr)
|
|
|
|
sys.exit(1)
|
|
|
|
|
|
|
|
# the path to the MPD sources
|
2015-01-22 18:51:53 +01:00
|
|
|
mpd_path = os.path.abspath(os.path.join(os.path.dirname(sys.argv[0]) or '.', '..'))
|
2015-11-20 22:10:22 +01:00
|
|
|
sys.path[0] = os.path.join(mpd_path, 'python')
|
2014-02-18 08:33:06 +01:00
|
|
|
|
|
|
|
# output directories
|
2015-11-23 10:38:48 +01:00
|
|
|
from build.dirs import lib_path, tarball_path, src_path
|
2023-09-26 12:07:48 +02:00
|
|
|
from build.toolchain import AndroidNdkToolchain
|
2014-02-18 08:33:06 +01:00
|
|
|
|
|
|
|
# a list of third-party libraries to be used by MPD on Android
|
2015-11-23 10:43:06 +01:00
|
|
|
from build.libs import *
|
2014-02-18 08:33:06 +01:00
|
|
|
thirdparty_libs = [
|
2020-05-26 21:08:29 +02:00
|
|
|
libmodplug,
|
|
|
|
wildmidi,
|
2020-06-10 20:58:31 +02:00
|
|
|
gme,
|
2015-11-23 10:43:06 +01:00
|
|
|
ffmpeg,
|
2018-02-20 22:45:15 +01:00
|
|
|
libnfs,
|
2014-02-18 08:33:06 +01:00
|
|
|
]
|
|
|
|
|
|
|
|
# build the third-party libraries
|
|
|
|
for x in thirdparty_libs:
|
2023-09-26 12:09:21 +02:00
|
|
|
toolchain = AndroidNdkToolchain(mpd_path, lib_path,
|
|
|
|
tarball_path, src_path,
|
|
|
|
ndk_path, android_abi,
|
2016-10-26 11:55:38 +02:00
|
|
|
use_cxx=x.use_cxx)
|
2015-11-20 20:30:42 +01:00
|
|
|
if not x.is_installed(toolchain):
|
|
|
|
x.build(toolchain)
|
2014-02-18 08:33:06 +01:00
|
|
|
|
|
|
|
# configure and build MPD
|
2023-09-26 12:09:21 +02:00
|
|
|
toolchain = AndroidNdkToolchain(mpd_path, lib_path,
|
|
|
|
tarball_path, src_path,
|
|
|
|
ndk_path, android_abi,
|
2016-10-26 11:55:38 +02:00
|
|
|
use_cxx=True)
|
2014-02-18 08:33:06 +01:00
|
|
|
|
2017-12-29 17:12:55 +01:00
|
|
|
configure_args += [
|
|
|
|
'-Dandroid_sdk=' + sdk_path,
|
|
|
|
'-Dandroid_ndk=' + ndk_path,
|
|
|
|
'-Dandroid_abi=' + android_abi,
|
|
|
|
'-Dandroid_strip=' + toolchain.strip,
|
2024-04-24 00:24:54 +02:00
|
|
|
'-Dopenssl:asm=disabled',
|
|
|
|
'-Dwrap_mode=forcefallback'
|
2017-12-29 17:12:55 +01:00
|
|
|
]
|
|
|
|
|
|
|
|
from build.meson import configure as run_meson
|
|
|
|
run_meson(toolchain, mpd_path, '.', configure_args)
|
2023-12-13 19:01:30 +01:00
|
|
|
|
|
|
|
ninja = shutil.which("ninja")
|
|
|
|
subprocess.check_call([ninja], env=toolchain.env)
|