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

Side by Side Diff: chrome/tools/build/win/create_installer_archive.py

Issue 1837233003: Detect debug/release of out\Default from args.gn (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Comment and printout tweaks per CR Created 4 years, 8 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 unified diff | Download patch
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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
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 # See the original of this function and then gn documentation for why this
445 # regular expression is correct:
446 # https://chromium.googlesource.com/chromium/src/+/master/tools/gn/docs/refe rence.md#GN-build-language-grammar
447 m = re.match('^\s*is_debug\s*=\s*false(\s*$|\s*#.*$)', l)
448 if m:
449 return 'Release'
450
451 # if is_debug is set to anything other than false, or if it
452 # does not exist at all, we should use the default value (True).
453 return 'Debug'
454
455
425 # Copy the relevant CRT DLLs to |build_dir|. We copy DLLs from all versions 456 # 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 457 # of VS installed to make sure we have the correct CRT version, unused DLLs
427 # should not conflict with the others anyways. 458 # should not conflict with the others anyways.
428 def CopyVisualStudioRuntimeDLLs(target_arch, build_dir): 459 def CopyVisualStudioRuntimeDLLs(target_arch, build_dir):
429 is_debug = os.path.basename(build_dir).startswith('Debug') 460 is_debug = os.path.basename(build_dir).startswith('Debug')
430 if not is_debug and not os.path.basename(build_dir).startswith('Release'): 461 if not is_debug and not os.path.basename(build_dir).startswith('Release'):
431 print ("Warning: could not determine build configuration from " 462 gn_type = _read_configuration_from_gn(build_dir)
432 "output directory, assuming Release build.") 463 if gn_type == 'Debug':
464 is_debug = True
465 elif gn_type == 'Release':
466 is_debug = False
467 else:
468 print ("Warning: could not determine build configuration from "
469 "output directory or args.gn, assuming Release build. If "
470 "setup.exe fails to launch, please check that your build "
471 "configuration is Release.")
433 472
434 crt_dlls = [] 473 crt_dlls = []
435 sys_dll_dir = None 474 sys_dll_dir = None
436 if is_debug: 475 if is_debug:
437 crt_dlls = glob.glob( 476 crt_dlls = glob.glob(
438 "C:/Program Files (x86)/Microsoft Visual Studio */VC/redist/" 477 "C:/Program Files (x86)/Microsoft Visual Studio */VC/redist/"
439 "Debug_NonRedist/" + target_arch + "/Microsoft.*.DebugCRT/*.dll") 478 "Debug_NonRedist/" + target_arch + "/Microsoft.*.DebugCRT/*.dll")
440 else: 479 else:
441 crt_dlls = glob.glob( 480 crt_dlls = glob.glob(
442 "C:/Program Files (x86)/Microsoft Visual Studio */VC/redist/" + 481 "C:/Program Files (x86)/Microsoft Visual Studio */VC/redist/" +
(...skipping 238 matching lines...) Expand 10 before | Expand all | Expand 10 after
681 MINI_INSTALLER_INPUT_FILE) 720 MINI_INSTALLER_INPUT_FILE)
682 721
683 return options 722 return options
684 723
685 724
686 if '__main__' == __name__: 725 if '__main__' == __name__:
687 options = _ParseOptions() 726 options = _ParseOptions()
688 if options.verbose: 727 if options.verbose:
689 print sys.argv 728 print sys.argv
690 sys.exit(main(options)) 729 sys.exit(main(options))
OLDNEW
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698