From c63cac0c19c0cebf079ca2fec939120904a65a65 Mon Sep 17 00:00:00 2001 From: Aiden Park Date: Tue, 4 Dec 2018 15:40:06 -0800 Subject: [PATCH] Clean-up build clean/distclean command When BaseTools is not ready, 'python BuildLoader.py clean' initiates building BaseTools even if it is 'clean' command. Therefore, move rebuild_basetools() into pre_build(). Additionaly, all unstaging files in BaseTools directory will be cleared to re-compile BaseTools when 'distclean' is executed. Signed-off-by: Aiden Park --- BuildLoader.py | 21 ++++++++++++++++----- 1 file changed, 16 insertions(+), 5 deletions(-) diff --git a/BuildLoader.py b/BuildLoader.py index 4b5b4d17..08a4a4d7 100755 --- a/BuildLoader.py +++ b/BuildLoader.py @@ -114,10 +114,6 @@ def prep_env (): os.environ['CONF_PATH'] = os.path.join(os.environ['WORKSPACE'], 'Conf') os.environ['TOOL_CHAIN'] = toolchain - # Check if BaseTools has been compiled - rebuild_basetools () - - def get_board_config_file (check_dir, board_cfgs): platform_dir = os.path.join (check_dir, 'Platform') if not os.path.isdir (platform_dir): @@ -908,6 +904,9 @@ class Build(object): def pre_build(self): + # Check if BaseTools has been compiled + rebuild_basetools () + # Update search path sbl_dir = os.environ['SBL_SOURCE'] plt_dir = os.environ['PLT_SOURCE'] @@ -1213,6 +1212,7 @@ def main(): os.path.join (sbl_dir, 'BootloaderCorePkg/Platform.dsc'), os.path.join (workspace, 'Report.log') ] + cmds = [] if args.distclean: dirs.extend ([ @@ -1222,13 +1222,24 @@ def main(): files.extend ([ ]) + cmds.extend ([ + 'git clean -xdf BaseTools', + ]) + for dir in dirs: - shutil.rmtree(os.path.join (workspace, dir), ignore_errors=True) + dirpath = os.path.join (workspace, dir) + print 'Removing %s' % dirpath + shutil.rmtree(dirpath, ignore_errors=True) for file in files: if os.path.exists(file): + print 'Removing %s' % file os.remove(file) + for cmd in cmds: + x = subprocess.call(cmd.split(' '), cwd=sbl_dir) + if x: raise Exception ('Failed to run clean-up commands !') + print('Clean Done !') cleanp = sp.add_parser('clean', help='clean build dir')