*: Switch to python
This commit is contained in:
@@ -0,0 +1,45 @@
|
||||
def autotools_configure(self, extra_args=(), extra_env=None):
|
||||
p = self.profile
|
||||
env = {
|
||||
"CFLAGS": p.get("cflags", ""),
|
||||
"CXXFLAGS": p.get("cxxflags", ""),
|
||||
"LDFLAGS": p.get("ldflags", ""),
|
||||
}
|
||||
if extra_env:
|
||||
env.update(extra_env)
|
||||
args = [
|
||||
self.source_dir / "configure",
|
||||
f"--host={p['triple']}",
|
||||
f"--with-sysroot={self.sysroot}",
|
||||
f"--prefix={p.get('prefix', '/usr')}",
|
||||
f"--sysconfdir={p.get('sysconfdir', '/etc')}",
|
||||
f"--localstatedir={p.get('localstatedir', '/var')}",
|
||||
f"--bindir={p.get('bindir', '/usr/bin')}",
|
||||
f"--sbindir={p.get('sbindir', '/usr/bin')}",
|
||||
f"--libdir={p.get('libdir', '/usr/lib')}",
|
||||
"--disable-static",
|
||||
"--enable-shared",
|
||||
*extra_args,
|
||||
]
|
||||
self.run(*args, env=env)
|
||||
|
||||
|
||||
def autotools_build(self, extra_args=()):
|
||||
self.run("make", f"-j{self.jobs}", *extra_args)
|
||||
|
||||
|
||||
def autotools_install(self, extra_args=()):
|
||||
self.run("make", "install", *extra_args, env={"DESTDIR": str(self.dest_dir)})
|
||||
|
||||
|
||||
def autotools(*, configure_args=(), configure_env=None, build_args=(), install_args=()):
|
||||
def _configure(self):
|
||||
autotools_configure(self, configure_args, configure_env)
|
||||
|
||||
def _build(self):
|
||||
autotools_build(self, build_args)
|
||||
|
||||
def _install(self):
|
||||
autotools_install(self, (*install_args, f"DESTDIR={self.dest_dir}"))
|
||||
|
||||
return _configure, _build, _install
|
||||
@@ -0,0 +1,73 @@
|
||||
def cmake_configure(self, extra_args=(), extra_env=None, *, host=False):
|
||||
p = self.profile
|
||||
if host:
|
||||
env = {
|
||||
"CFLAGS": p.get("host_cflags", ""),
|
||||
"CXXFLAGS": p.get("host_cxxflags", ""),
|
||||
"LDFLAGS": p.get("host_ldflags", ""),
|
||||
}
|
||||
toolchain = []
|
||||
else:
|
||||
env = {
|
||||
"CFLAGS": p.get("cflags", ""),
|
||||
"CXXFLAGS": p.get("cxxflags", ""),
|
||||
"LDFLAGS": p.get("ldflags", ""),
|
||||
}
|
||||
toolchain = [
|
||||
"-DCMAKE_SYSTEM_NAME=Linux",
|
||||
f"-DCMAKE_SYSTEM_PROCESSOR={p['arch']}",
|
||||
f"-DCMAKE_SYSROOT={self.sysroot}",
|
||||
f"-DCMAKE_C_COMPILER={p['triple']}-gcc",
|
||||
f"-DCMAKE_CXX_COMPILER={p['triple']}-g++",
|
||||
"-DCMAKE_FIND_ROOT_PATH_MODE_PROGRAM=NEVER",
|
||||
"-DCMAKE_FIND_ROOT_PATH_MODE_LIBRARY=ONLY",
|
||||
"-DCMAKE_FIND_ROOT_PATH_MODE_INCLUDE=ONLY",
|
||||
"-DCMAKE_FIND_ROOT_PATH_MODE_PACKAGE=ONLY",
|
||||
]
|
||||
if extra_env:
|
||||
env.update(extra_env)
|
||||
self.run(
|
||||
"cmake",
|
||||
"-S",
|
||||
self.source_dir,
|
||||
"-B",
|
||||
self.build_dir,
|
||||
"-G",
|
||||
"Ninja",
|
||||
"-DCMAKE_BUILD_TYPE=Release",
|
||||
f"-DCMAKE_INSTALL_PREFIX={p.get('prefix', '/usr')}",
|
||||
f"-DCMAKE_INSTALL_SYSCONFDIR={p.get('sysconfdir', '/etc')}",
|
||||
f"-DCMAKE_INSTALL_LOCALSTATEDIR={p.get('localstatedir', '/var')}",
|
||||
*toolchain,
|
||||
*extra_args,
|
||||
env=env,
|
||||
)
|
||||
|
||||
|
||||
def cmake_build(self, extra_args=()):
|
||||
self.run("cmake", "--build", self.build_dir, "-j", self.jobs, *extra_args)
|
||||
|
||||
|
||||
def cmake_install(self, extra_args=()):
|
||||
self.run(
|
||||
"cmake",
|
||||
"--install",
|
||||
self.build_dir,
|
||||
*extra_args,
|
||||
env={"DESTDIR": str(self.dest_dir)},
|
||||
)
|
||||
|
||||
|
||||
def cmake(
|
||||
*, configure_args=(), configure_env=None, build_args=(), install_args=(), host=False
|
||||
):
|
||||
def _configure(self):
|
||||
cmake_configure(self, configure_args, configure_env, host=host)
|
||||
|
||||
def _build(self):
|
||||
cmake_build(self, build_args)
|
||||
|
||||
def _install(self):
|
||||
cmake_install(self, install_args)
|
||||
|
||||
return _configure, _build, _install
|
||||
@@ -0,0 +1,9 @@
|
||||
def make_build(self, extra_args=(), *, env=None):
|
||||
self.run("make", f"-j{self.jobs}", *extra_args, env=env)
|
||||
|
||||
|
||||
def make_install(self, extra_args=(), *, env=None):
|
||||
merged = {"DESTDIR": str(self.dest_dir)}
|
||||
if env:
|
||||
merged.update(env)
|
||||
self.run("make", "install", *extra_args, env=merged)
|
||||
@@ -0,0 +1,85 @@
|
||||
def meson_cross_file(self):
|
||||
cross = self.build_dir / "meson-cross.ini"
|
||||
self.write_text(
|
||||
cross,
|
||||
f"""\
|
||||
[binaries]
|
||||
c = '{self.triple}-gcc'
|
||||
cpp = '{self.triple}-g++'
|
||||
ar = '{self.triple}-gcc-ar'
|
||||
nm = '{self.triple}-nm'
|
||||
objcopy = '{self.triple}-objcopy'
|
||||
ranlib = '{self.triple}-ranlib'
|
||||
strip = '{self.triple}-strip'
|
||||
pkg-config = '{self.triple}-pkg-config'
|
||||
|
||||
[host_machine]
|
||||
system = 'linux'
|
||||
cpu_family = '{self.arch}'
|
||||
cpu = '{self.arch}'
|
||||
endian = 'little'
|
||||
""",
|
||||
)
|
||||
return cross
|
||||
|
||||
|
||||
def meson_configure(
|
||||
self, extra_args=(), extra_env=None, *, source_dir=None, flags=True, host=False
|
||||
):
|
||||
p = self.options
|
||||
env = {}
|
||||
if flags:
|
||||
env.update(
|
||||
{
|
||||
"CFLAGS": p.get("cflags", ""),
|
||||
"CXXFLAGS": p.get("cxxflags", ""),
|
||||
"LDFLAGS": p.get("ldflags", ""),
|
||||
}
|
||||
)
|
||||
if extra_env:
|
||||
env.update(extra_env)
|
||||
cross_args = [] if host else ["--cross-file", meson_cross_file(self)]
|
||||
self.run(
|
||||
"meson",
|
||||
"setup",
|
||||
source_dir or self.source_dir,
|
||||
*cross_args,
|
||||
f"--prefix={p.get('prefix', '/usr')}",
|
||||
f"--sysconfdir={p.get('sysconfdir', '/etc')}",
|
||||
f"--localstatedir={p.get('localstatedir', '/var')}",
|
||||
"--libdir=lib",
|
||||
"--sbindir=bin",
|
||||
"--bindir=bin",
|
||||
"--datadir=share",
|
||||
"--buildtype=release",
|
||||
"-Ddefault_library=shared",
|
||||
*extra_args,
|
||||
env=env,
|
||||
)
|
||||
|
||||
|
||||
def meson_build(self, extra_args=()):
|
||||
self.run("meson", "compile", f"-j{self.jobs}", *extra_args)
|
||||
|
||||
|
||||
def meson_install(self, extra_args=()):
|
||||
self.run(
|
||||
"meson",
|
||||
"install",
|
||||
"--no-rebuild",
|
||||
*extra_args,
|
||||
env={"DESTDIR": str(self.dest_dir)},
|
||||
)
|
||||
|
||||
|
||||
def meson(*, configure_args=(), configure_env=None, build_args=(), install_args=()):
|
||||
def _configure(self):
|
||||
meson_configure(self, configure_args, configure_env)
|
||||
|
||||
def _build(self):
|
||||
meson_build(self, build_args)
|
||||
|
||||
def _install(self):
|
||||
meson_install(self, install_args)
|
||||
|
||||
return _configure, _build, _install
|
||||
Reference in New Issue
Block a user