From 712642d3b1ab2d37f5bab74660ff931201fa5f34 Mon Sep 17 00:00:00 2001 From: Stefan van der Walt Date: Thu, 17 Nov 2022 13:17:30 -0800 Subject: [PATCH] Add --clean flag to build command --- devpy/cmds/_build.py | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/devpy/cmds/_build.py b/devpy/cmds/_build.py index eae9744..9aa08cc 100644 --- a/devpy/cmds/_build.py +++ b/devpy/cmds/_build.py @@ -10,12 +10,13 @@ "--build-dir", default="build", help="Build directory; default is `$PWD/build`" ) @click.option("-j", "--jobs", help="Number of parallel tasks to launch", type=int) +@click.option("--clean", is_flag=True, help="Clean build directory before build") @click.option( "-v", "--verbose", is_flag=True, help="Print all build output, even installation" ) @click.argument("meson_args", nargs=-1) -def build(build_dir, meson_args, jobs=None, verbose=False): - """🔧 Build package with Meson/ninja +def build(build_dir, meson_args, jobs=None, clean=False, verbose=False): + """🔧 Build package with Meson/ninja and install MESON_ARGS are passed through directly to pytest, e.g.: @@ -26,6 +27,11 @@ def build(build_dir, meson_args, jobs=None, verbose=False): build_cmd = ["meson", "setup", f"--prefix={build_dir}", "build"] + list(meson_args) flags = [] + if clean: + print(f"Removing `{build_dir}`") + if os.path.isdir(build_dir): + shutil.rmtree(build_dir) + if os.path.exists(build_dir): flags += ["--reconfigure"]