100 lines
2.9 KiB
Python
100 lines
2.9 KiB
Python
# Commonly used helpers, auto-loaded into every recipe.
|
|
|
|
def _toolchain_env(ctx):
|
|
sysroot_flag = " --sysroot=" + ctx.sysroot
|
|
return {
|
|
"CFLAGS": OPTIONS.cflags + sysroot_flag,
|
|
"CXXFLAGS": OPTIONS.cxxflags + sysroot_flag,
|
|
"LDFLAGS": OPTIONS.ldflags + sysroot_flag,
|
|
}
|
|
|
|
# Autotools
|
|
|
|
def autotools_configure(ctx, extra_args = [], extra_env = {}):
|
|
args = [
|
|
ctx.source_dir + "/configure",
|
|
"--prefix=" + ctx.prefix,
|
|
"--sysconfdir=/etc",
|
|
"--localstatedir=/var",
|
|
"--bindir=" + ctx.prefix + "/bin",
|
|
"--sbindir=" + ctx.prefix + "/bin",
|
|
"--libdir=" + ctx.prefix + "/lib",
|
|
"--with-sysroot=" + ctx.sysroot,
|
|
"--disable-static",
|
|
"--enable-shared",
|
|
]
|
|
args.append("--host=" + OPTIONS.target_triple)
|
|
args.extend(extra_args)
|
|
|
|
envs = _toolchain_env(ctx)
|
|
envs.update(extra_env)
|
|
|
|
ctx.run(args, env = envs)
|
|
|
|
def autotools_build(ctx, extra_args = []):
|
|
args = ["make", "-j" + str(ctx.jobs)]
|
|
args.extend(extra_args)
|
|
ctx.run(args)
|
|
|
|
def autotools_check(ctx, extra_args = []):
|
|
args = ["make", "check", "-j" + str(ctx.jobs)]
|
|
args.extend(extra_args)
|
|
ctx.run(args)
|
|
|
|
def autotools_install(ctx, pkg, extra_args = []):
|
|
args = ["make", "install", "DESTDIR=" + pkg.destdir]
|
|
args.extend(extra_args)
|
|
ctx.run(args)
|
|
|
|
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
|
|
|
|
# Meson
|
|
|
|
def meson_configure(ctx, extra_args = []):
|
|
args = [
|
|
"meson",
|
|
"setup",
|
|
ctx.build_dir,
|
|
ctx.source_dir,
|
|
"--prefix=" + ctx.prefix,
|
|
]
|
|
args.extend(extra_args)
|
|
ctx.run(args, env = _toolchain_env(ctx))
|
|
|
|
def meson_build(ctx):
|
|
ctx.run(["meson", "compile", "-C", ctx.build_dir, "-j" + str(ctx.jobs)])
|
|
|
|
def meson_install(ctx, pkg):
|
|
ctx.run(["meson", "install", "-C", ctx.build_dir, "--destdir", pkg.destdir])
|
|
|
|
def meson(configure_args = [], build_args = [], install_args = []):
|
|
def _configure(ctx):
|
|
meson_configure(ctx, extra_args = configure_args)
|
|
def _build(ctx):
|
|
meson_build(ctx, extra_args = build_args)
|
|
def _install(ctx, pkg):
|
|
meson_install(ctx, pkg, extra_args = install_args)
|
|
return _configure, _build, _install
|
|
|
|
# Make
|
|
|
|
def make(ctx, target = None, extra_args = []):
|
|
args = ["make", "-C", ctx.source_dir, "O=" + ctx.build_dir,
|
|
"-j" + str(ctx.jobs)]
|
|
args.extend(extra_args)
|
|
if target:
|
|
args.append(target)
|
|
ctx.run(args)
|
|
|
|
def make_install(ctx, pkg, extra_args = []):
|
|
args = ["make", "-C", ctx.build_dir, "DESTDIR=" + pkg.destdir, "install"]
|
|
args.extend(extra_args)
|
|
ctx.run(args)
|