Chromium Code Reviews| OLD | NEW |
|---|---|
| 1 #!/usr/bin/env python | 1 #!/usr/bin/env python |
| 2 # Copyright (c) 2012 The Chromium Authors. All rights reserved. | 2 # Copyright (c) 2012 The Chromium Authors. All rights reserved. |
| 3 # Use of this source code is governed by a BSD-style license that can be | 3 # Use of this source code is governed by a BSD-style license that can be |
| 4 # found in the LICENSE file. | 4 # found in the LICENSE file. |
| 5 | 5 |
| 6 """Script to create Chrome Installer archive. | 6 """Script to create Chrome Installer archive. |
| 7 | 7 |
| 8 This script is used to create an archive of all the files required for a | 8 This script is used to create an archive of all the files required for a |
| 9 Chrome install in appropriate directory structure. It reads chrome.release | 9 Chrome install in appropriate directory structure. It reads chrome.release |
| 10 file as input, creates chrome.7z archive, compresses setup.exe and | 10 file as input, creates chrome.7z archive, compresses setup.exe and |
| 11 generates packed_files.txt for mini_installer project. | 11 generates packed_files.txt for mini_installer project. |
| 12 | 12 |
| 13 """ | 13 """ |
| 14 | 14 |
| 15 import ConfigParser | 15 import ConfigParser |
| 16 import glob | 16 import glob |
| 17 import optparse | 17 import optparse |
| 18 import os | 18 import os |
| 19 import re | |
| 19 import shutil | 20 import shutil |
| 20 import subprocess | 21 import subprocess |
| 21 import sys | 22 import sys |
| 22 | 23 |
| 23 | 24 |
| 24 ARCHIVE_DIR = "installer_archive" | 25 ARCHIVE_DIR = "installer_archive" |
| 25 | 26 |
| 26 # suffix to uncompresed full archive file, appended to options.output_name | 27 # suffix to uncompresed full archive file, appended to options.output_name |
| 27 ARCHIVE_SUFFIX = ".7z" | 28 ARCHIVE_SUFFIX = ".7z" |
| 28 BSDIFF_EXEC = "bsdiff.exe" | 29 BSDIFF_EXEC = "bsdiff.exe" |
| (...skipping 386 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 415 dest_data = fdest.read() | 416 dest_data = fdest.read() |
| 416 if src_data != dest_data: | 417 if src_data != dest_data: |
| 417 # This may still raise if we get here, but this really should almost | 418 # This may still raise if we get here, but this really should almost |
| 418 # never happen (it would mean that the contents of e.g. msvcr100d.dll | 419 # never happen (it would mean that the contents of e.g. msvcr100d.dll |
| 419 # had been changed). | 420 # had been changed). |
| 420 shutil.copyfile(src, dest) | 421 shutil.copyfile(src, dest) |
| 421 else: | 422 else: |
| 422 shutil.copyfile(src, dest) | 423 shutil.copyfile(src, dest) |
| 423 | 424 |
| 424 | 425 |
| 426 # Taken and modified from: | |
| 427 # third_party\WebKit\Tools\Scripts\webkitpy\layout_tests\port\factory.py | |
| 428 def _read_configuration_from_gn(build_dir): | |
| 429 """Return the configuration to used based on args.gn, if possible.""" | |
| 430 path = os.path.join(build_dir, 'args.gn') | |
| 431 if not os.path.exists(path): | |
| 432 path = os.path.join(build_dir, 'toolchain.ninja') | |
| 433 if not os.path.exists(path): | |
| 434 # This does not appear to be a GN-based build directory, so we don't | |
| 435 # know how to interpret it. | |
| 436 return None | |
| 437 | |
| 438 # toolchain.ninja exists, but args.gn does not; this can happen when | |
| 439 # `gn gen` is run with no --args. | |
| 440 return 'Debug' | |
| 441 | |
| 442 args = open(path).read() | |
| 443 for l in args.splitlines(): | |
| 444 m = re.match('^\s*is_debug\s*=\s*false(\s*$|\s*#.*$)', l) | |
|
robertshield
2016/04/05 23:43:43
Could you add a comment here that this regex is co
brucedawson
2016/04/06 00:25:05
Done.
| |
| 445 if m: | |
| 446 return 'Release' | |
| 447 | |
| 448 # if is_debug is set to anything other than false, or if it | |
| 449 # does not exist at all, we should use the default value (True). | |
| 450 return 'Debug' | |
| 451 | |
| 452 | |
| 425 # Copy the relevant CRT DLLs to |build_dir|. We copy DLLs from all versions | 453 # Copy the relevant CRT DLLs to |build_dir|. We copy DLLs from all versions |
| 426 # of VS installed to make sure we have the correct CRT version, unused DLLs | 454 # of VS installed to make sure we have the correct CRT version, unused DLLs |
| 427 # should not conflict with the others anyways. | 455 # should not conflict with the others anyways. |
| 428 def CopyVisualStudioRuntimeDLLs(target_arch, build_dir): | 456 def CopyVisualStudioRuntimeDLLs(target_arch, build_dir): |
| 429 is_debug = os.path.basename(build_dir).startswith('Debug') | 457 is_debug = os.path.basename(build_dir).startswith('Debug') |
| 430 if not is_debug and not os.path.basename(build_dir).startswith('Release'): | 458 if not is_debug and not os.path.basename(build_dir).startswith('Release'): |
| 431 print ("Warning: could not determine build configuration from " | 459 gn_type = _read_configuration_from_gn(build_dir) |
| 432 "output directory, assuming Release build.") | 460 if gn_type == 'Debug': |
| 461 is_debug = True | |
| 462 elif gn_type == 'Release': | |
| 463 is_debug = False | |
| 464 else: | |
| 465 print ("Warning: could not determine build configuration from " | |
| 466 "output directory or args.gn, assuming Release build.") | |
|
robertshield
2016/04/05 23:43:43
What do you think about appending some explicit wo
brucedawson
2016/04/06 00:25:05
Done.
| |
| 433 | 467 |
| 434 crt_dlls = [] | 468 crt_dlls = [] |
| 435 sys_dll_dir = None | 469 sys_dll_dir = None |
| 436 if is_debug: | 470 if is_debug: |
| 437 crt_dlls = glob.glob( | 471 crt_dlls = glob.glob( |
| 438 "C:/Program Files (x86)/Microsoft Visual Studio */VC/redist/" | 472 "C:/Program Files (x86)/Microsoft Visual Studio */VC/redist/" |
| 439 "Debug_NonRedist/" + target_arch + "/Microsoft.*.DebugCRT/*.dll") | 473 "Debug_NonRedist/" + target_arch + "/Microsoft.*.DebugCRT/*.dll") |
| 440 else: | 474 else: |
| 441 crt_dlls = glob.glob( | 475 crt_dlls = glob.glob( |
| 442 "C:/Program Files (x86)/Microsoft Visual Studio */VC/redist/" + | 476 "C:/Program Files (x86)/Microsoft Visual Studio */VC/redist/" + |
| (...skipping 235 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 678 MINI_INSTALLER_INPUT_FILE) | 712 MINI_INSTALLER_INPUT_FILE) |
| 679 | 713 |
| 680 return options | 714 return options |
| 681 | 715 |
| 682 | 716 |
| 683 if '__main__' == __name__: | 717 if '__main__' == __name__: |
| 684 options = _ParseOptions() | 718 options = _ParseOptions() |
| 685 if options.verbose: | 719 if options.verbose: |
| 686 print sys.argv | 720 print sys.argv |
| 687 sys.exit(main(options)) | 721 sys.exit(main(options)) |
| OLD | NEW |