From 93196a1995787760839f0e0af084d5017ee0f3d8 Mon Sep 17 00:00:00 2001 From: "Magomed Kostoev (mkostoevr)" Date: Sat, 4 Dec 2021 09:29:17 +0000 Subject: [PATCH] [WS] Make cleanup.py remove compiled files git-svn-id: svn://kolibrios.org@9379 a494cfbc-eb01-0410-851d-a64ba20cac60 --- _tools/cleanup.py | 5 ++++- _tools/workspace/build.py | 24 +++++++++++++++++++----- 2 files changed, 23 insertions(+), 6 deletions(-) diff --git a/_tools/cleanup.py b/_tools/cleanup.py index 1a2d61c80d..1fcc260b2e 100755 --- a/_tools/cleanup.py +++ b/_tools/cleanup.py @@ -3,6 +3,8 @@ import os import sys import shutil +import workspace.build + if len(sys.argv) < 2 or sys.argv[1] != "--remove-everything": print(f"Please call `{sys.argv[0]} --remove-everything` if you really want to remove all your workspace files") exit() @@ -13,7 +15,8 @@ shutil.rmtree("workspace", ignore_errors = True) # Remove tup database shutil.rmtree(".tup", ignore_errors = True) -# TODO: Make build.py remove the stuff it built +# Make build.py remove the stuff it built +workspace.build.clean() # Remove files copied from _tools/workspace tools = os.path.dirname(os.path.realpath(__file__)) diff --git a/_tools/workspace/build.py b/_tools/workspace/build.py index 9b4e281000..e237f42ba1 100644 --- a/_tools/workspace/build.py +++ b/_tools/workspace/build.py @@ -7,13 +7,27 @@ sys.path.append(path_to_tools) from lib.tupfile_parser import parse_tupfile_outputs -def build(): - os.system("tup") - outputs = parse_tupfile_outputs("Tupfile.lua") - for name in outputs: +def get_executable_file(output_file_list): + for name in output_file_list: if name.endswith(".inc"): continue return name +def build(): + os.system("tup") + output_file_list = parse_tupfile_outputs("Tupfile.lua") + return get_executable_file(output_file_list) + +def clean(): + output_file_list = parse_tupfile_outputs("Tupfile.lua") + for output_file in output_file_list: + os.remove(output_file) + +def main(argv): + if len(argv) == 2 and argv[1] == "clean": + clean() + else: + build() + if __name__ == "__main__": - build() + main(sys.argv)