Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add --clean flag to build command #16

Merged
merged 1 commit into from
Nov 18, 2022
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 8 additions & 2 deletions devpy/cmds/_build.py
Original file line number Diff line number Diff line change
Expand Up @@ -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.:

Expand All @@ -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"]

Expand Down