From 7b7e3d8b06dd573b473babeb358af0dcb7dbeb44 Mon Sep 17 00:00:00 2001 From: Wez Furlong Date: Fri, 3 May 2019 15:52:39 -0700 Subject: [PATCH] fbcode_builder: getdeps: add clean command Summary: This cleans up the scratch dir, removing everything except for downloaded tarballs. Reviewed By: simpkins Differential Revision: D14781328 fbshipit-source-id: 9304e44a268cf7996c5e572a2eca219aefbf4b46 --- build/fbcode_builder/getdeps.py | 21 ++++++++++++++++----- 1 file changed, 16 insertions(+), 5 deletions(-) diff --git a/build/fbcode_builder/getdeps.py b/build/fbcode_builder/getdeps.py index 37af80be1..cb013f1ba 100755 --- a/build/fbcode_builder/getdeps.py +++ b/build/fbcode_builder/getdeps.py @@ -112,16 +112,27 @@ class ListDepsCmd(SubCmd): ) +def clean_dirs(opts): + for d in ["build", "installed", "extracted", "shipit"]: + d = os.path.join(opts.scratch_dir, d) + print("Cleaning %s..." % d) + if os.path.exists(d): + shutil.rmtree(d) + + +@cmd("clean", "clean up the scratch dir") +class CleanCmd(SubCmd): + def run(self, args): + opts = setup_build_options(args) + clean_dirs(opts) + + @cmd("build", "build a given project") class BuildCmd(SubCmd): def run(self, args): opts = setup_build_options(args) if args.clean: - for d in ["build", "installed", "extracted", "shipit"]: - d = os.path.join(opts.scratch_dir, d) - print("Cleaning %s..." % d) - if os.path.exists(d): - shutil.rmtree(d) + clean_dirs(opts) manifest = load_project(opts, args.project)