Chromium Code Reviews| Index: chrome/tools/build/win/create_installer_archive.py |
| diff --git a/chrome/tools/build/win/create_installer_archive.py b/chrome/tools/build/win/create_installer_archive.py |
| index d687ba2340b29b9452c39d0a4c128a89267c78a7..37b6cef2db9cb199ff90bec189813a184a3c3b1a 100755 |
| --- a/chrome/tools/build/win/create_installer_archive.py |
| +++ b/chrome/tools/build/win/create_installer_archive.py |
| @@ -66,7 +66,7 @@ def BuildVersion(build_dir): |
| return '%s.%s.%s.%s' % (major, minor, build, patch) |
| -def CompressUsingLZMA(build_dir, compressed_file, input_file): |
| +def CompressUsingLZMA(build_dir, compressed_file, input_file, verbose): |
| lzma_exec = GetLZMAExec(build_dir) |
| cmd = [lzma_exec, |
| 'a', '-t7z', |
| @@ -89,7 +89,7 @@ def CompressUsingLZMA(build_dir, compressed_file, input_file): |
| input_file,] |
| if os.path.exists(compressed_file): |
| os.remove(compressed_file) |
| - RunSystemCommand(cmd) |
| + RunSystemCommand(cmd, verbose) |
| def CopyAllFilesToStagingDir(config, distribution, staging_dir, build_dir, |
| @@ -134,7 +134,7 @@ def GenerateDiffPatch(options, orig_file, new_file, patch_file): |
| else: |
| exe_file = os.path.join(options.build_dir, BSDIFF_EXEC) |
| cmd = [exe_file, orig_file, new_file, patch_file,] |
| - RunSystemCommand(cmd) |
| + RunSystemCommand(cmd, options.verbose) |
| def GetLZMAExec(build_dir): |
| lzma_exec = os.path.join(build_dir, "..", "..", "third_party", |
| @@ -153,7 +153,7 @@ def GetPrevVersion(build_dir, temp_dir, last_chrome_installer, output_name): |
| '-o"%s"' % temp_dir, |
| prev_archive_file, |
| 'Chrome-bin/*/chrome.dll',] |
| - RunSystemCommand(cmd) |
| + RunSystemCommand(cmd, options.verbose) |
| dll_path = glob.glob(os.path.join(temp_dir, 'Chrome-bin', '*', 'chrome.dll')) |
| return os.path.split(os.path.split(dll_path[0])[0])[1] |
| @@ -184,8 +184,14 @@ def Readconfig(input_file, current_version): |
| config.read(input_file) |
| return config |
| -def RunSystemCommand(cmd, **kw): |
| - print 'Running', cmd |
| +def RunSystemCommand(cmd, verbose, **kw): |
| + """Runs |cmd|, printing verbose output if |verbose| and redirecting its output |
| + to os.devnull otherwise. |
| + """ |
| + if verbose: |
| + print 'Running', cmd |
| + else: |
| + kw['stdout'] = open(os.devnull, "w") |
| exit_code = subprocess.call(cmd, **kw) |
| if (exit_code != 0): |
| raise Exception("Error while running cmd: %s, exit_code: %s" % |
|
grt (UTC plus 2)
2015/09/30 18:25:08
is it possible to capture the command's stdout in
gab
2015/10/01 14:21:18
Improved the way stdout/stderr capture is done by
grt (UTC plus 2)
2015/10/01 14:31:56
awesome!
|
| @@ -245,10 +251,10 @@ def CreateArchiveFile(options, staging_dir, current_version, prev_version): |
| # There doesnt seem to be any way in 7za.exe to override existing file so |
| # we always delete before creating a new one. |
| if not os.path.exists(archive_file): |
| - RunSystemCommand(cmd) |
| + RunSystemCommand(cmd, options.verbose) |
| elif options.skip_rebuild_archive != "true": |
| os.remove(archive_file) |
| - RunSystemCommand(cmd) |
| + RunSystemCommand(cmd, options.verbose) |
| # Do not compress the archive in developer (component) builds. |
| if options.component_build == '1': |
| @@ -278,7 +284,8 @@ def CreateArchiveFile(options, staging_dir, current_version, prev_version): |
| compressed_archive_file_path = os.path.join(options.output_dir, |
| compressed_archive_file) |
| - CompressUsingLZMA(options.build_dir, compressed_archive_file_path, orig_file) |
| + CompressUsingLZMA(options.build_dir, compressed_archive_file_path, orig_file, |
| + options.verbose) |
| return compressed_archive_file |
| @@ -299,7 +306,8 @@ def PrepareSetupExec(options, current_version, prev_version): |
| setup_file = SETUP_PATCH_FILE_PREFIX + '_' + current_version + \ |
| '_from_' + prev_version + COMPRESSED_FILE_EXT |
| setup_file_path = os.path.join(options.build_dir, setup_file) |
| - CompressUsingLZMA(options.build_dir, setup_file_path, patch_file) |
| + CompressUsingLZMA(options.build_dir, setup_file_path, patch_file, |
| + options.verbose) |
| else: |
| cmd = ['makecab.exe', |
| '/D', 'CompressionType=LZX', |
| @@ -307,7 +315,7 @@ def PrepareSetupExec(options, current_version, prev_version): |
| '/L', options.output_dir, |
| os.path.join(options.build_dir, SETUP_EXEC),] |
| # Send useless makecab progress on stdout to the bitbucket. |
| - RunSystemCommand(cmd, stdout=open(os.devnull, "w")) |
| + RunSystemCommand(cmd, options.verbose, stdout=open(os.devnull, "w")) |
|
csharp
2015/09/29 17:38:00
What about removing the stdout setting here and ju
gab
2015/09/29 17:44:02
Feels knowing the actual command could be useful.
gab
2015/10/01 14:21:19
Revised this as it made things more complicated fo
|
| setup_file = SETUP_EXEC[:-1] + "_" |
| return setup_file |
| @@ -626,6 +634,8 @@ def _ParseOptions(): |
| help='Specify the target architecture for installer - this is used ' |
| 'to determine which CRT runtime files to pull and package ' |
| 'with the installer archive {x86|x64}.') |
| + parser.add_option('-v', '--verbose', action='store_true', dest='verbose', |
| + default=False) |
| options, _ = parser.parse_args() |
| if not options.build_dir: |
| @@ -650,5 +660,7 @@ def _ParseOptions(): |
| if '__main__' == __name__: |
| - print sys.argv |
| - sys.exit(main(_ParseOptions())) |
| + options = _ParseOptions() |
| + if options.verbose: |
| + print sys.argv |
| + sys.exit(main(options)) |