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

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

Issue 2021353003: Copy local CRT DLLs to gn output directories (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Make path a raw string Created 4 years, 6 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 | « build/vs_toolchain.py ('k') | 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
(...skipping 440 matching lines...) Expand 10 before | Expand all | Expand 10 after
451 # https://chromium.googlesource.com/chromium/src/+/master/tools/gn/docs/refe rence.md#GN-build-language-grammar 451 # https://chromium.googlesource.com/chromium/src/+/master/tools/gn/docs/refe rence.md#GN-build-language-grammar
452 m = re.match('^\s*is_debug\s*=\s*false(\s*$|\s*#.*$)', l) 452 m = re.match('^\s*is_debug\s*=\s*false(\s*$|\s*#.*$)', l)
453 if m: 453 if m:
454 return 'Release' 454 return 'Release'
455 455
456 # if is_debug is set to anything other than false, or if it 456 # if is_debug is set to anything other than false, or if it
457 # does not exist at all, we should use the default value (True). 457 # does not exist at all, we should use the default value (True).
458 return 'Debug' 458 return 'Debug'
459 459
460 460
461 # Copy the relevant CRT DLLs to |build_dir|. We copy DLLs from all versions
462 # of VS installed to make sure we have the correct CRT version, unused DLLs
463 # should not conflict with the others anyways.
464 def CopyVisualStudioRuntimeDLLs(target_arch, build_dir):
465 is_debug = os.path.basename(build_dir).startswith('Debug')
466 if not is_debug and not os.path.basename(build_dir).startswith('Release'):
467 gn_type = _read_configuration_from_gn(build_dir)
468 if gn_type == 'Debug':
469 is_debug = True
470 elif gn_type == 'Release':
471 is_debug = False
472 else:
473 print ("Warning: could not determine build configuration from "
474 "output directory or args.gn, assuming Release build. If "
475 "setup.exe fails to launch, please check that your build "
476 "configuration is Release.")
477
478 crt_dlls = []
479 sys_dll_dir = None
480 if is_debug:
481 crt_dlls = glob.glob(
482 "C:/Program Files (x86)/Microsoft Visual Studio */VC/redist/"
483 "Debug_NonRedist/" + target_arch + "/Microsoft.*.DebugCRT/*.dll")
484 else:
485 crt_dlls = glob.glob(
486 "C:/Program Files (x86)/Microsoft Visual Studio */VC/redist/" +
487 target_arch + "/Microsoft.*.CRT/*.dll")
488
489 # Also handle the case where someone is building using only winsdk and
490 # doesn't have Visual Studio installed.
491 if not crt_dlls:
492 if target_arch == 'x64':
493 # check we are are on a 64bit system by existence of WOW64 dir
494 if os.access("C:/Windows/SysWOW64", os.F_OK):
495 sys_dll_dir = "C:/Windows/System32"
496 else:
497 # only support packaging of 64bit installer on 64bit system
498 # but this just as bad as not finding DLLs at all so we
499 # don't abort here to mirror behavior below
500 print ("Warning: could not find x64 CRT DLLs on x86 system.")
501 else:
502 # On a 64-bit system, 32-bit dlls are in SysWOW64 (don't ask).
503 if os.access("C:/Windows/SysWOW64", os.F_OK):
504 sys_dll_dir = "C:/Windows/SysWOW64"
505 else:
506 sys_dll_dir = "C:/Windows/System32"
507
508 if sys_dll_dir is not None:
509 if is_debug:
510 crt_dlls = glob.glob(os.path.join(sys_dll_dir, "msvc*0d.dll"))
511 else:
512 crt_dlls = glob.glob(os.path.join(sys_dll_dir, "msvc*0.dll"))
513
514 if not crt_dlls:
515 print ("Warning: could not find CRT DLLs to copy to build dir - target "
516 "may not run on a system that doesn't have those DLLs.")
517
518 for dll in crt_dlls:
519 CopyIfChanged(dll, build_dir)
520
521
522 # Copies component build DLLs and generates required config files and manifests 461 # Copies component build DLLs and generates required config files and manifests
523 # in order for chrome.exe and setup.exe to be able to find those DLLs at 462 # in order for chrome.exe and setup.exe to be able to find those DLLs at
524 # run-time. 463 # run-time.
525 # This is meant for developer builds only and should never be used to package 464 # This is meant for developer builds only and should never be used to package
526 # an official build. 465 # an official build.
527 def DoComponentBuildTasks(staging_dir, build_dir, target_arch, current_version): 466 def DoComponentBuildTasks(staging_dir, build_dir, target_arch, current_version):
528 # Get the required directories for the upcoming operations. 467 # Get the required directories for the upcoming operations.
529 chrome_dir = os.path.join(staging_dir, CHROME_DIR) 468 chrome_dir = os.path.join(staging_dir, CHROME_DIR)
530 version_dir = os.path.join(chrome_dir, current_version) 469 version_dir = os.path.join(chrome_dir, current_version)
531 installer_dir = os.path.join(version_dir, 'Installer') 470 installer_dir = os.path.join(version_dir, 'Installer')
532 # |installer_dir| is technically only created post-install, but we need it 471 # |installer_dir| is technically only created post-install, but we need it
533 # now to add setup.exe's config and manifest to the archive. 472 # now to add setup.exe's config and manifest to the archive.
534 if not os.path.exists(installer_dir): 473 if not os.path.exists(installer_dir):
535 os.mkdir(installer_dir) 474 os.mkdir(installer_dir)
536 475
537 # Copy the VS CRT DLLs to |build_dir|. This must be done before the general
538 # copy step below to ensure the CRT DLLs are added to the archive and marked
539 # as a dependency in the exe manifests generated below.
540 CopyVisualStudioRuntimeDLLs(target_arch, build_dir)
541
542 # Explicitly list the component DLLs setup.exe depends on (this list may 476 # Explicitly list the component DLLs setup.exe depends on (this list may
543 # contain wildcards). These will be copied to |installer_dir| in the archive. 477 # contain wildcards). These will be copied to |installer_dir| in the archive.
544 # The use of source sets in gn builds means that references to some extra 478 # The use of source sets in gn builds means that references to some extra
545 # DLLs get pulled in to setup.exe (base_i18n.dll, ipc.dll, etc.). Unpacking 479 # DLLs get pulled in to setup.exe (base_i18n.dll, ipc.dll, etc.). Unpacking
546 # these to |installer_dir| is simpler and more robust than switching setup.exe 480 # these to |installer_dir| is simpler and more robust than switching setup.exe
547 # to use libraries instead of source sets. 481 # to use libraries instead of source sets.
548 setup_component_dll_globs = [ 'api-ms-win-*.dll', 482 setup_component_dll_globs = [ 'api-ms-win-*.dll',
549 'base.dll', 483 'base.dll',
550 'boringssl.dll', 484 'boringssl.dll',
551 'crcrypto.dll', 485 'crcrypto.dll',
552 'icui18n.dll', 486 'icui18n.dll',
553 'icuuc.dll', 487 'icuuc.dll',
554 'msvc*.dll', 488 'msvc*.dll',
489 'ucrtbase*.dll',
555 'vcruntime*.dll', 490 'vcruntime*.dll',
556 # DLLs needed due to source sets. 491 # DLLs needed due to source sets.
557 'base_i18n.dll', 492 'base_i18n.dll',
558 'ipc.dll', 493 'ipc.dll',
559 'net.dll', 494 'net.dll',
560 'prefs.dll', 495 'prefs.dll',
561 'protobuf_lite.dll', 496 'protobuf_lite.dll',
562 'url_lib.dll' ] 497 'url_lib.dll' ]
563 for setup_component_dll_glob in setup_component_dll_globs: 498 for setup_component_dll_glob in setup_component_dll_globs:
564 setup_component_dlls = glob.glob(os.path.join(build_dir, 499 setup_component_dlls = glob.glob(os.path.join(build_dir,
(...skipping 160 matching lines...) Expand 10 before | Expand all | Expand 10 after
725 MINI_INSTALLER_INPUT_FILE) 660 MINI_INSTALLER_INPUT_FILE)
726 661
727 return options 662 return options
728 663
729 664
730 if '__main__' == __name__: 665 if '__main__' == __name__:
731 options = _ParseOptions() 666 options = _ParseOptions()
732 if options.verbose: 667 if options.verbose:
733 print sys.argv 668 print sys.argv
734 sys.exit(main(options)) 669 sys.exit(main(options))
OLDNEW
« no previous file with comments | « build/vs_toolchain.py ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698