2022-08-08 10:17:54 +02:00
|
|
|
#!/usr/bin/env -S python3 -u
|
2014-12-09 12:59:03 +01:00
|
|
|
|
|
|
|
import os, os.path
|
2015-11-21 00:17:00 +01:00
|
|
|
import sys, subprocess
|
2017-12-29 17:12:55 +01:00
|
|
|
import shutil
|
2014-12-09 12:59:03 +01:00
|
|
|
|
|
|
|
configure_args = sys.argv[1:]
|
|
|
|
|
2017-02-20 21:06:37 +01:00
|
|
|
x64 = True
|
2014-12-17 16:47:25 +01:00
|
|
|
|
2017-02-20 21:04:44 +01:00
|
|
|
while len(configure_args) > 0:
|
|
|
|
arg = configure_args[0]
|
|
|
|
if arg == '--64':
|
|
|
|
x64 = True
|
2017-02-20 21:06:27 +01:00
|
|
|
elif arg == '--32':
|
|
|
|
x64 = False
|
2017-02-20 21:04:44 +01:00
|
|
|
else:
|
|
|
|
break
|
|
|
|
configure_args.pop(0)
|
2017-02-20 21:04:07 +01:00
|
|
|
|
|
|
|
if x64:
|
2014-12-17 16:35:27 +01:00
|
|
|
host_arch = 'x86_64-w64-mingw32'
|
2017-02-20 21:04:07 +01:00
|
|
|
else:
|
|
|
|
host_arch = 'i686-w64-mingw32'
|
2014-12-17 16:35:27 +01:00
|
|
|
|
2014-12-09 12:59:03 +01:00
|
|
|
# the path to the MPD sources
|
2015-01-26 20:59:57 +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-12-09 12:59:03 +01:00
|
|
|
|
|
|
|
# output directories
|
2015-11-23 10:38:48 +01:00
|
|
|
from build.dirs import lib_path, tarball_path, src_path
|
2015-06-03 07:48:38 +02:00
|
|
|
|
2014-12-17 16:47:25 +01:00
|
|
|
arch_path = os.path.join(lib_path, host_arch)
|
|
|
|
build_path = os.path.join(arch_path, 'build')
|
|
|
|
root_path = os.path.join(arch_path, 'root')
|
2014-12-09 12:59:03 +01:00
|
|
|
|
2015-11-20 20:30:42 +01:00
|
|
|
class CrossGccToolchain:
|
2023-09-26 12:19:10 +02:00
|
|
|
def __init__(self, top_path: str,
|
|
|
|
toolchain_path, arch, x64: bool,
|
2015-11-20 23:47:52 +01:00
|
|
|
tarball_path, src_path, build_path, install_prefix):
|
2015-11-20 20:30:42 +01:00
|
|
|
self.arch = arch
|
2021-09-20 22:54:54 +02:00
|
|
|
self.actual_arch = arch
|
2015-11-20 23:47:52 +01:00
|
|
|
self.tarball_path = tarball_path
|
|
|
|
self.src_path = src_path
|
|
|
|
self.build_path = build_path
|
2015-11-20 20:30:42 +01:00
|
|
|
self.install_prefix = install_prefix
|
|
|
|
|
|
|
|
toolchain_bin = os.path.join(toolchain_path, 'bin')
|
|
|
|
self.cc = os.path.join(toolchain_bin, arch + '-gcc')
|
|
|
|
self.cxx = os.path.join(toolchain_bin, arch + '-g++')
|
|
|
|
self.ar = os.path.join(toolchain_bin, arch + '-ar')
|
2023-03-06 13:25:43 +01:00
|
|
|
self.arflags = 'rcs'
|
2016-10-26 10:40:19 +02:00
|
|
|
self.ranlib = os.path.join(toolchain_bin, arch + '-ranlib')
|
2015-11-20 20:30:42 +01:00
|
|
|
self.nm = os.path.join(toolchain_bin, arch + '-nm')
|
|
|
|
self.strip = os.path.join(toolchain_bin, arch + '-strip')
|
2018-10-14 23:41:20 +02:00
|
|
|
self.windres = os.path.join(toolchain_bin, arch + '-windres')
|
2015-11-20 20:30:42 +01:00
|
|
|
|
2018-01-19 11:18:45 +01:00
|
|
|
common_flags = '-O2 -g'
|
2017-08-31 19:46:30 +02:00
|
|
|
|
|
|
|
if not x64:
|
|
|
|
# enable SSE support which is required for LAME
|
|
|
|
common_flags += ' -march=pentium3'
|
|
|
|
|
2018-01-19 11:18:45 +01:00
|
|
|
self.cflags = common_flags
|
|
|
|
self.cxxflags = common_flags
|
2018-02-24 22:42:19 +01:00
|
|
|
self.cppflags = '-isystem ' + os.path.join(install_prefix, 'include') + \
|
|
|
|
' -DWINVER=0x0600 -D_WIN32_WINNT=0x0600'
|
2018-11-04 10:47:20 +01:00
|
|
|
self.ldflags = '-L' + os.path.join(install_prefix, 'lib') + \
|
|
|
|
' -static-libstdc++ -static-libgcc'
|
2015-11-20 20:30:42 +01:00
|
|
|
self.libs = ''
|
|
|
|
|
2020-09-04 14:31:03 +02:00
|
|
|
# Explicitly disable _FORTIFY_SOURCE because it is broken with
|
|
|
|
# mingw. This prevents some libraries such as libFLAC to
|
|
|
|
# enable it.
|
|
|
|
self.cppflags += ' -D_FORTIFY_SOURCE=0'
|
|
|
|
|
2015-11-21 00:35:52 +01:00
|
|
|
self.is_arm = arch.startswith('arm')
|
|
|
|
self.is_armv7 = self.is_arm and 'armv7' in self.cflags
|
2018-08-17 17:53:46 +02:00
|
|
|
self.is_aarch64 = arch == 'aarch64'
|
2015-11-21 00:35:52 +01:00
|
|
|
self.is_windows = 'mingw32' in arch
|
|
|
|
|
2015-11-20 20:30:42 +01:00
|
|
|
self.env = dict(os.environ)
|
|
|
|
|
|
|
|
# redirect pkg-config to use our root directory instead of the
|
|
|
|
# default one on the build host
|
2017-12-29 17:12:55 +01:00
|
|
|
import shutil
|
|
|
|
bin_dir = os.path.join(install_prefix, 'bin')
|
2021-09-21 16:04:26 +02:00
|
|
|
os.makedirs(bin_dir, exist_ok=True)
|
2023-09-26 12:19:10 +02:00
|
|
|
self.pkg_config = shutil.copy(os.path.join(top_path, 'build', 'pkg-config.sh'),
|
2017-12-29 17:12:55 +01:00
|
|
|
os.path.join(bin_dir, 'pkg-config'))
|
|
|
|
self.env['PKG_CONFIG'] = self.pkg_config
|
2014-12-09 12:59:03 +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-12-09 12:59:03 +01:00
|
|
|
thirdparty_libs = [
|
2018-02-24 22:59:33 +01:00
|
|
|
libmpdclient,
|
2015-11-23 10:43:06 +01:00
|
|
|
libogg,
|
|
|
|
opus,
|
2021-10-07 13:26:39 +02:00
|
|
|
flac,
|
2015-11-23 10:43:06 +01:00
|
|
|
zlib,
|
|
|
|
libid3tag,
|
2017-07-19 20:26:11 +02:00
|
|
|
liblame,
|
2020-05-26 21:08:29 +02:00
|
|
|
libmodplug,
|
2021-11-04 08:23:24 +01:00
|
|
|
libopenmpt,
|
2020-05-26 21:08:29 +02:00
|
|
|
wildmidi,
|
2020-06-10 20:58:31 +02:00
|
|
|
gme,
|
2015-11-23 10:43:06 +01:00
|
|
|
ffmpeg,
|
|
|
|
curl,
|
2018-02-24 22:14:44 +01:00
|
|
|
libnfs,
|
2021-04-07 17:29:58 +02:00
|
|
|
jack,
|
2015-11-23 10:43:06 +01:00
|
|
|
boost,
|
2014-12-09 12:59:03 +01:00
|
|
|
]
|
|
|
|
|
|
|
|
# build the third-party libraries
|
2023-09-26 12:19:10 +02:00
|
|
|
toolchain = CrossGccToolchain(mpd_path,
|
|
|
|
'/usr', host_arch, x64,
|
2015-11-20 23:47:52 +01:00
|
|
|
tarball_path, src_path, build_path, root_path)
|
2015-11-20 20:30:42 +01:00
|
|
|
|
2014-12-09 12:59:03 +01:00
|
|
|
for x in thirdparty_libs:
|
2015-11-20 20:30:42 +01:00
|
|
|
if not x.is_installed(toolchain):
|
|
|
|
x.build(toolchain)
|
2014-12-09 12:59:03 +01:00
|
|
|
|
|
|
|
# configure and build MPD
|
|
|
|
|
2017-12-29 17:12:55 +01:00
|
|
|
from build.meson import configure as run_meson
|
|
|
|
run_meson(toolchain, mpd_path, '.', configure_args)
|
|
|
|
subprocess.check_call(['/usr/bin/ninja'], env=toolchain.env)
|