Commit 89bf4c5f authored by Max Kellermann's avatar Max Kellermann

python/build/meson.py: move two functions to the top level

parent f80ebf68
...@@ -2,43 +2,37 @@ import os.path, subprocess, sys ...@@ -2,43 +2,37 @@ import os.path, subprocess, sys
from build.project import Project from build.project import Project
class MesonProject(Project): def make_cross_file(toolchain):
def __init__(self, url, md5, installed, configure_args=[], if toolchain.is_windows:
**kwargs): system = 'windows'
Project.__init__(self, url, md5, installed, **kwargs) else:
self.configure_args = configure_args system = 'linux'
def _make_cross_file(self, toolchain): if toolchain.is_arm:
if toolchain.is_windows: cpu_family = 'arm'
system = 'windows' if toolchain.is_armv7:
cpu = 'armv7'
else: else:
system = 'linux' cpu = 'armv6'
elif toolchain.is_aarch64:
if toolchain.is_arm: cpu_family = 'aarch64'
cpu_family = 'arm' cpu = 'arm64-v8a'
if toolchain.is_armv7: else:
cpu = 'armv7' cpu_family = 'x86'
else: if 'x86_64' in toolchain.arch:
cpu = 'armv6' cpu = 'x86_64'
elif toolchain.is_aarch64:
cpu_family = 'aarch64'
cpu = 'arm64-v8a'
else: else:
cpu_family = 'x86' cpu = 'i686'
if 'x86_64' in toolchain.arch:
cpu = 'x86_64'
else:
cpu = 'i686'
# TODO: support more CPUs # TODO: support more CPUs
endian = 'little' endian = 'little'
# TODO: write pkg-config wrapper # TODO: write pkg-config wrapper
path = os.path.join(toolchain.build_path, 'meson.cross') path = os.path.join(toolchain.build_path, 'meson.cross')
os.makedirs(toolchain.build_path, exist_ok=True) os.makedirs(toolchain.build_path, exist_ok=True)
with open(path, 'w') as f: with open(path, 'w') as f:
f.write(""" f.write("""
[binaries] [binaries]
c = '%s' c = '%s'
cpp = '%s' cpp = '%s'
...@@ -69,31 +63,40 @@ endian = '%s' ...@@ -69,31 +63,40 @@ endian = '%s'
repr((toolchain.cppflags + ' ' + toolchain.cxxflags).split()), repr((toolchain.cppflags + ' ' + toolchain.cxxflags).split()),
repr(toolchain.ldflags.split()), repr(toolchain.ldflags.split()),
system, cpu_family, cpu, endian)) system, cpu_family, cpu, endian))
return path return path
def configure(self, toolchain): def configure(toolchain, src, build, args=()):
src = self.unpack(toolchain) cross_file = make_cross_file(toolchain)
cross_file = self._make_cross_file(toolchain) configure = [
build = self.make_build_path(toolchain) 'meson',
configure = [ src, build,
'meson',
src, build, '--prefix', toolchain.install_prefix,
'--prefix', toolchain.install_prefix, # this is necessary because Meson uses Debian's build machine
# MultiArch path (e.g. "lib/x86_64-linux-gnu") for cross
# builds, which is obviously wrong
'--libdir', 'lib',
# this is necessary because Meson uses Debian's build machine '--buildtype', 'plain',
# MultiArch path (e.g. "lib/x86_64-linux-gnu") for cross
# builds, which is obviously wrong
'--libdir', 'lib',
'--buildtype', 'plain', '--default-library=static',
'--default-library=static', '--cross-file', cross_file,
] + args
'--cross-file', cross_file, subprocess.check_call(configure, env=toolchain.env)
] + self.configure_args
subprocess.check_call(configure, env=toolchain.env) class MesonProject(Project):
def __init__(self, url, md5, installed, configure_args=[],
**kwargs):
Project.__init__(self, url, md5, installed, **kwargs)
self.configure_args = configure_args
def configure(self, toolchain):
src = self.unpack(toolchain)
build = self.make_build_path(toolchain)
configure(toolchain, src, build, self.configure_args)
return build return build
def build(self, toolchain): def build(self, toolchain):
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment