96 lines
3.4 KiB
Python
96 lines
3.4 KiB
Python
# Autotools
|
|
|
|
def autotools_configure(ctx, extra_args = [], extra_env = {}):
|
|
env = {
|
|
"CFLAGS": options.cflags,
|
|
"CXXFLAGS": options.cxxflags,
|
|
"LDFLAGS": options.ldflags,
|
|
}
|
|
env.update(extra_env)
|
|
ctx.run([
|
|
ctx.source_dir / "configure",
|
|
"--host=" + options.target_triple,
|
|
"--with-sysroot=" + ctx.sysroot,
|
|
"--prefix=" + options.prefix,
|
|
"--sysconfdir=" + options.sysconfdir,
|
|
"--localstatedir=" + options.localstatedir,
|
|
"--bindir=" + options.bindir,
|
|
"--sbindir=" + options.sbindir,
|
|
"--libdir=" + options.libdir,
|
|
"--disable-static",
|
|
"--enable-shared",
|
|
] + extra_args, env = env)
|
|
|
|
def autotools_build(ctx, extra_args = []):
|
|
ctx.run(["make", "-j" + str(ctx.jobs)] + extra_args)
|
|
|
|
def autotools_install(ctx, pkg, extra_args = []):
|
|
ctx.run(["make", "install"] + extra_args, env = { "DESTDIR": pkg.dest_dir })
|
|
|
|
def autotools(configure_args = [], configure_env = {}, build_args = [], install_args = []):
|
|
def _configure(ctx):
|
|
autotools_configure(ctx, extra_args = configure_args, extra_env = configure_env)
|
|
def _build(ctx):
|
|
autotools_build(ctx, extra_args = build_args)
|
|
def _install(ctx, pkg):
|
|
autotools_install(ctx, pkg, extra_args = install_args)
|
|
return _configure, _build, _install
|
|
|
|
# CMake
|
|
|
|
def cmake_configure(ctx, extra_args = [], extra_env = {}, host = False):
|
|
if host:
|
|
env = {
|
|
"CFLAGS": options.host_cflags,
|
|
"CXXFLAGS": options.host_cxxflags,
|
|
"LDFLAGS": options.host_ldflags,
|
|
}
|
|
toolchain_args = []
|
|
else:
|
|
env = {
|
|
"CFLAGS": options.cflags,
|
|
"CXXFLAGS": options.cxxflags,
|
|
"LDFLAGS": options.ldflags,
|
|
}
|
|
toolchain_args = [
|
|
"-DCMAKE_SYSTEM_NAME=Linux",
|
|
"-DCMAKE_SYSTEM_PROCESSOR=" + options.target_arch,
|
|
"-DCMAKE_SYSROOT=" + ctx.sysroot,
|
|
"-DCMAKE_C_COMPILER=" + options.target_triple + "-gcc",
|
|
"-DCMAKE_CXX_COMPILER=" + options.target_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",
|
|
]
|
|
env.update(extra_env)
|
|
ctx.run([
|
|
"cmake",
|
|
"-S", ctx.source_dir,
|
|
"-B", ctx.build_dir,
|
|
"-G", "Ninja",
|
|
"-DCMAKE_BUILD_TYPE=Release",
|
|
"-DCMAKE_INSTALL_PREFIX=" + options.prefix,
|
|
"-DCMAKE_INSTALL_SYSCONFDIR=" + options.sysconfdir,
|
|
"-DCMAKE_INSTALL_LOCALSTATEDIR=" + options.localstatedir,
|
|
] + toolchain_args + extra_args, env = env)
|
|
|
|
def cmake_build(ctx, extra_args = []):
|
|
ctx.run(["cmake", "--build", ctx.build_dir, "-j", str(ctx.jobs)] + extra_args)
|
|
|
|
def cmake_install(ctx, pkg, extra_args = []):
|
|
ctx.run(
|
|
["cmake", "--install", ctx.build_dir] + extra_args,
|
|
env = {"DESTDIR": pkg.dest_dir},
|
|
)
|
|
|
|
def cmake(configure_args = [], configure_env = {}, build_args = [], install_args = [], host = False):
|
|
def _configure(ctx):
|
|
cmake_configure(ctx, extra_args = configure_args, extra_env = configure_env, host = host)
|
|
def _build(ctx):
|
|
cmake_build(ctx, extra_args = build_args)
|
|
def _install(ctx, pkg):
|
|
cmake_install(ctx, pkg, extra_args = install_args)
|
|
return _configure, _build, _install
|
|
|