build: make --dry-run all work

This commit is contained in:
Ciro Santilli 六四事件 法轮功
2019-01-22 00:00:00 +00:00
parent 43618523cd
commit 4db08517dc
5 changed files with 15 additions and 9 deletions

View File

@@ -54,7 +54,7 @@ Build crosstool-NG with Newlib for bare metal compilation
'defconfig', LF, 'defconfig', LF,
], ],
) )
os.unlink(defconfig_dest) self.sh.rmrf(defconfig_dest)
self.sh.run_cmd( self.sh.run_cmd(
[ [
self.env['crosstool_ng_executable'], LF, self.env['crosstool_ng_executable'], LF,

View File

@@ -99,7 +99,7 @@ class Main(common.BuildCliFunction):
# Otherwise self.sh.cp would fail with "Text file busy" if you # Otherwise self.sh.cp would fail with "Text file busy" if you
# tried to rebuild while running m5term: # tried to rebuild while running m5term:
# https://stackoverflow.com/questions/16764946/what-generates-the-text-file-busy-message-in-unix/52427512#52427512 # 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']) self.sh.cp(m5term_build, self.env['gem5_m5term'])
def get_build_dir(self): def get_build_dir(self):

View File

@@ -721,7 +721,12 @@ Valid emulators: {}
tried.append('{}-{}'.format(prefix, tool)) tried.append('{}-{}'.format(prefix, tool))
if exists: if exists:
return prefix 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): def get_toolchain_tool(self, tool, allowed_toolchains=None):
return '{}-{}'.format(self.get_toolchain_prefix(tool, allowed_toolchains), tool) return '{}-{}'.format(self.get_toolchain_prefix(tool, allowed_toolchains), tool)

View File

@@ -14,7 +14,7 @@ from shell_helpers import LF
def main(): def main():
os.makedirs(self.env['release_dir'], exist_ok=True) os.makedirs(self.env['release_dir'], exist_ok=True)
if os.path.exists(self.env['release_zip_file']): 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) zipf = zipfile.ZipFile(self.env['release_zip_file'], 'w', zipfile.ZIP_DEFLATED)
for arch in self.env['all_long_archs']: for arch in self.env['all_long_archs']:
self.setup(common.get_argparse(default_args={'arch': arch})) self.setup(common.get_argparse(default_args={'arch': arch}))

View File

@@ -269,11 +269,12 @@ class ShellHelpers:
''' '''
if config_fragments is None: if config_fragments is None:
config_fragments = [] config_fragments = []
with open(config_path, 'a') as config_file: for config_fragment in config_fragments:
for config_fragment in config_fragments: self.print_cmd(['cat', config_fragment, '>>', config_path])
with open(config_fragment, 'r') as config_fragment_file: if not self.dry_run:
self.print_cmd(['cat', config_fragment, '>>', config_path]) with open(config_path, 'a') as config_file:
if not self.dry_run: for config_fragment in config_fragments:
with open(config_fragment, 'r') as config_fragment_file:
for line in config_fragment_file: for line in config_fragment_file:
config_file.write(line) config_file.write(line)
self.write_string_to_file(config_path, '\n'.join(configs), mode='a') self.write_string_to_file(config_path, '\n'.join(configs), mode='a')