first
This commit is contained in:
@@ -0,0 +1,82 @@
|
||||
# Commonly used helpers, auto-loaded into every recipe.
|
||||
|
||||
def autotools_configure(ctx, extra_args = []):
|
||||
args = [
|
||||
ctx.source_dir + "/configure",
|
||||
"--prefix=" + ctx.prefix,
|
||||
"--sysconfdir=/etc",
|
||||
"--localstatedir=/var",
|
||||
]
|
||||
args.extend(extra_args)
|
||||
ctx.run(args, env = _toolchain_env(ctx))
|
||||
|
||||
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 = [], build_args = [], install_args = []):
|
||||
def _configure(ctx):
|
||||
autotools_configure(ctx, extra_args = configure_args)
|
||||
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
|
||||
|
||||
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
|
||||
|
||||
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)
|
||||
|
||||
def _toolchain_env(ctx):
|
||||
env = {}
|
||||
for key, var in [("cflags", "CFLAGS"), ("cxxflags", "CXXFLAGS"), ("ldflags", "LDFLAGS")]:
|
||||
if key in ctx.options:
|
||||
env[var] = ctx.options[key]
|
||||
return env
|
||||
Reference in New Issue
Block a user