Update clean operation

This commit is contained in:
topjohnwu 2023-06-20 14:50:02 -07:00
parent a6b1149b9f
commit 5805573625

View File

@ -506,19 +506,26 @@ def build_stub(args):
def cleanup(args): def cleanup(args):
support_targets = {"native", "java"} support_targets = {"native", "cpp", "rust", "java"}
if args.target: if args.target:
args.target = set(args.target) & support_targets args.target = set(args.target) & support_targets
if "native" in args.target:
args.target.add("cpp")
args.target.add("rust")
else: else:
args.target = support_targets args.target = support_targets
if "native" in args.target: if "cpp" in args.target:
header("* Cleaning native") header("* Cleaning C++")
rm_rf(op.join("native", "libs")) rm_rf(op.join("native", "libs"))
rm_rf(op.join("native", "obj")) rm_rf(op.join("native", "obj"))
rm_rf(op.join("native", "out")) rm_rf(op.join("native", "out"))
if "rust" in args.target:
header("* Cleaning Rust")
rm_rf(op.join("native", "src", "target")) rm_rf(op.join("native", "src", "target"))
rm(op.join("native", "src", "boot", "update_metadata.rs")) rm(op.join("native", "src", "boot", "proto", "mod.rs"))
rm(op.join("native", "src", "boot", "proto", "update_metadata.rs"))
for rs_gen in glob.glob("native/**/*-rs.*pp", recursive=True): for rs_gen in glob.glob("native/**/*-rs.*pp", recursive=True):
rm(rs_gen) rm(rs_gen)
@ -697,7 +704,7 @@ avd_patch_parser.set_defaults(func=patch_avd_ramdisk)
clean_parser = subparsers.add_parser("clean", help="cleanup") clean_parser = subparsers.add_parser("clean", help="cleanup")
clean_parser.add_argument( clean_parser.add_argument(
"target", nargs="*", help="native, java, or empty to clean both" "target", nargs="*", help="native, cpp, rust, java, or empty to clean all"
) )
clean_parser.set_defaults(func=cleanup) clean_parser.set_defaults(func=cleanup)