diff --git a/build-crosstool-ng b/build-crosstool-ng index 6e81021..af40db3 100755 --- a/build-crosstool-ng +++ b/build-crosstool-ng @@ -54,7 +54,7 @@ Build crosstool-NG with Newlib for bare metal compilation 'defconfig', LF, ], ) - os.unlink(defconfig_dest) + self.sh.rmrf(defconfig_dest) self.sh.run_cmd( [ self.env['crosstool_ng_executable'], LF, diff --git a/build-gem5 b/build-gem5 index f1e79a8..06e7bd8 100755 --- a/build-gem5 +++ b/build-gem5 @@ -99,7 +99,7 @@ class Main(common.BuildCliFunction): # Otherwise self.sh.cp would fail with "Text file busy" if you # tried to rebuild while running m5term: # https://stackoverflow.com/questions/16764946/what-generates-the-text-file-busy-message-in-unix/52427512#52427512 - os.unlink(self.env['gem5_m5term']) + self.sh.rmrf(self.env['gem5_m5term']) self.sh.cp(m5term_build, self.env['gem5_m5term']) def get_build_dir(self): diff --git a/common.py b/common.py index bf15407..24cf4fa 100644 --- a/common.py +++ b/common.py @@ -721,7 +721,12 @@ Valid emulators: {} tried.append('{}-{}'.format(prefix, tool)) if exists: return prefix - raise Exception('Tool not found. Tried:\n' + '\n'.join(tried)) + error_message = 'Tool not found. Tried:\n' + '\n'.join(tried) + if self.env['dry_run']: + self.log_error(error_message) + return '' + else: + raise Exception(error_message) def get_toolchain_tool(self, tool, allowed_toolchains=None): return '{}-{}'.format(self.get_toolchain_prefix(tool, allowed_toolchains), tool) diff --git a/release-zip b/release-zip index a89f8ab..40e5ef6 100755 --- a/release-zip +++ b/release-zip @@ -14,7 +14,7 @@ from shell_helpers import LF def main(): os.makedirs(self.env['release_dir'], exist_ok=True) if os.path.exists(self.env['release_zip_file']): - os.unlink(self.env['release_zip_file']) + self.sh.rmrf(self.env['release_zip_file']) zipf = zipfile.ZipFile(self.env['release_zip_file'], 'w', zipfile.ZIP_DEFLATED) for arch in self.env['all_long_archs']: self.setup(common.get_argparse(default_args={'arch': arch})) diff --git a/shell_helpers.py b/shell_helpers.py index 9996d9b..9ba1da9 100644 --- a/shell_helpers.py +++ b/shell_helpers.py @@ -269,11 +269,12 @@ class ShellHelpers: ''' if config_fragments is None: config_fragments = [] - with open(config_path, 'a') as config_file: - for config_fragment in config_fragments: - with open(config_fragment, 'r') as config_fragment_file: - self.print_cmd(['cat', config_fragment, '>>', config_path]) - if not self.dry_run: + for config_fragment in config_fragments: + self.print_cmd(['cat', config_fragment, '>>', config_path]) + if not self.dry_run: + with open(config_path, 'a') as config_file: + for config_fragment in config_fragments: + with open(config_fragment, 'r') as config_fragment_file: for line in config_fragment_file: config_file.write(line) self.write_string_to_file(config_path, '\n'.join(configs), mode='a')