Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(369)

Unified Diff: chrome/tools/build/win/create_installer_archive.py

Issue 1372303003: Make create_installer_archive.py operate silently by default. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Document optional argument in gyp/GN Created 5 years, 3 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « chrome/installer/mini_installer/BUILD.gn ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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..3e2798245a83139436502891269b76733d1d3f53 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(verbose, build_dir, compressed_file, input_file):
csharp 2015/09/29 17:01:37 verbose should probably be the last argument
gab 2015/09/29 17:32:27 Done.
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(verbose, cmd)
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(options.verbose, cmd)
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(options.verbose, cmd)
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(verbose, cmd, **kw):
csharp 2015/09/29 17:01:37 The order should probably be "cmd, verbose, **kw".
gab 2015/09/29 17:32:28 Done.
+ """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")
csharp 2015/09/29 17:01:36 nit:kw['stdout'] -> devnull
gab 2015/09/29 17:32:28 You mean s/kw['stdout']/devnull/ as a variable to
csharp 2015/09/29 17:38:00 Ah, I hadn't realized it was still used.
exit_code = subprocess.call(cmd, **kw)
csharp 2015/09/29 17:01:37 add stdout=devnull
gab 2015/09/29 17:32:28 IIUC you want me to use the above debated variable
if (exit_code != 0):
raise Exception("Error while running cmd: %s, exit_code: %s" %
@@ -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(options.verbose, cmd)
elif options.skip_rebuild_archive != "true":
os.remove(archive_file)
- RunSystemCommand(cmd)
+ RunSystemCommand(options.verbose, cmd)
# 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.verbose, options.build_dir,
+ compressed_archive_file_path, orig_file)
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.verbose, options.build_dir, setup_file_path,
+ patch_file)
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(options.verbose, cmd, stdout=open(os.devnull, "w"))
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))
« no previous file with comments | « chrome/installer/mini_installer/BUILD.gn ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698