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 |
(...skipping 440 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
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 def ParseDLLsFromDeps(build_dir, runtime_deps_file): | |
462 """Parses the runtime_deps file and returns the set of DLLs in it, relative | |
463 to build_dir.""" | |
464 build_dlls = set() | |
465 args = open(runtime_deps_file).read() | |
466 for l in args.splitlines(): | |
467 if os.path.splitext(l)[1] == ".dll": | |
468 build_dlls.add(os.path.join(build_dir, l)) | |
469 return build_dlls | |
470 | |
461 # Copies component build DLLs and generates required config files and manifests | 471 # Copies component build DLLs and generates required config files and manifests |
462 # in order for chrome.exe and setup.exe to be able to find those DLLs at | 472 # in order for chrome.exe and setup.exe to be able to find those DLLs at |
463 # run-time. | 473 # run-time. |
464 # This is meant for developer builds only and should never be used to package | 474 # This is meant for developer builds only and should never be used to package |
465 # an official build. | 475 # an official build. |
466 def DoComponentBuildTasks(staging_dir, build_dir, target_arch, current_version): | 476 def DoComponentBuildTasks(staging_dir, build_dir, target_arch, |
477 setup_runtime_deps, component_runtime_deps, | |
478 current_version): | |
467 # Get the required directories for the upcoming operations. | 479 # Get the required directories for the upcoming operations. |
468 chrome_dir = os.path.join(staging_dir, CHROME_DIR) | 480 chrome_dir = os.path.join(staging_dir, CHROME_DIR) |
469 version_dir = os.path.join(chrome_dir, current_version) | 481 version_dir = os.path.join(chrome_dir, current_version) |
470 installer_dir = os.path.join(version_dir, 'Installer') | 482 installer_dir = os.path.join(version_dir, 'Installer') |
471 # |installer_dir| is technically only created post-install, but we need it | 483 # |installer_dir| is technically only created post-install, but we need it |
472 # now to add setup.exe's config and manifest to the archive. | 484 # now to add setup.exe's config and manifest to the archive. |
473 if not os.path.exists(installer_dir): | 485 if not os.path.exists(installer_dir): |
474 os.mkdir(installer_dir) | 486 os.mkdir(installer_dir) |
475 | 487 |
476 # Explicitly list the component DLLs setup.exe depends on (this list may | 488 if setup_runtime_deps: |
477 # contain wildcards). These will be copied to |installer_dir| in the archive. | 489 setup_component_dlls = ParseDLLsFromDeps(build_dir, setup_runtime_deps) |
478 # The use of source sets in gn builds means that references to some extra | 490 else: |
479 # DLLs get pulled in to setup.exe (base_i18n.dll, ipc.dll, etc.). Unpacking | 491 # Explicitly list the component DLLs setup.exe depends on (this list may |
480 # these to |installer_dir| is simpler and more robust than switching setup.exe | 492 # contain wildcards). These will be copied to |installer_dir| in the |
481 # to use libraries instead of source sets. | 493 # archive. |
482 setup_component_dll_globs = [ 'api-ms-win-*.dll', | 494 # TODO(jbauman): Remove when GYP is deprecated on Windows. |
483 'base.dll', | 495 setup_component_dll_globs = [ 'api-ms-win-*.dll', |
484 'boringssl.dll', | 496 'base.dll', |
485 'crcrypto.dll', | 497 'boringssl.dll', |
486 'icui18n.dll', | 498 'crcrypto.dll', |
487 'icuuc.dll', | 499 'icui18n.dll', |
488 'msvc*.dll', | 500 'icuuc.dll', |
489 'ucrtbase*.dll', | 501 'msvc*.dll', |
490 'vcruntime*.dll', | 502 'ucrtbase*.dll', |
491 # DLLs needed due to source sets. | 503 'vcruntime*.dll', ] |
492 'base_i18n.dll', | 504 setup_component_dlls = set() |
493 'ipc.dll', | 505 for setup_component_dll_glob in setup_component_dll_globs: |
494 'net.dll', | 506 setup_component_partial_dlls = glob.glob( |
495 'prefs.dll', | 507 os.path.join(build_dir, setup_component_dll_glob)) |
496 'protobuf_lite.dll', | 508 if len(setup_component_partial_dlls) == 0: |
497 'url_lib.dll' ] | 509 raise Exception('Error: missing expected DLL for component build ' |
498 for setup_component_dll_glob in setup_component_dll_globs: | 510 'mini_installer: "%s"' % setup_component_dll_glob) |
499 setup_component_dlls = glob.glob(os.path.join(build_dir, | 511 setup_component_dlls.update(setup_component_partial_dlls) |
500 setup_component_dll_glob)) | 512 for setup_component_dll in setup_component_dlls: |
501 if len(setup_component_dlls) == 0: | 513 g_archive_inputs.append(setup_component_dll) |
502 raise Exception('Error: missing expected DLL for component build ' | 514 shutil.copy(setup_component_dll, installer_dir) |
503 'mini_installer: "%s"' % setup_component_dll_glob) | |
504 for setup_component_dll in setup_component_dlls: | |
505 g_archive_inputs.append(setup_component_dll) | |
506 shutil.copy(setup_component_dll, installer_dir) | |
507 | 515 |
508 # Stage all the component DLLs found in |build_dir| to the |version_dir| (for | 516 # Stage all the component DLLs to the |version_dir| (for |
509 # the version assembly to be able to refer to them below and make sure | 517 # the version assembly to be able to refer to them below and make sure |
510 # chrome.exe can find them at runtime). The component DLLs are considered to | 518 # chrome.exe can find them at runtime), except the ones that are already |
511 # be all the DLLs which have not already been added to the |version_dir| by | 519 # staged (i.e. non-component DLLs). |
512 # virtue of chrome.release. | 520 if component_runtime_deps: |
513 build_dlls = glob.glob(os.path.join(build_dir, '*.dll')) | 521 build_dlls = ParseDLLsFromDeps(build_dir, component_runtime_deps) |
522 else: | |
523 # If no component_runtime_deps was specified, every DLL in build_dir is | |
524 # considered to be a component DLL. | |
525 # TODO(jbauman): Remove when GYP is deprecated on Windows. | |
526 build_dlls = glob.glob(os.path.join(build_dir, '*.dll')) | |
514 staged_dll_basenames = [os.path.basename(staged_dll) for staged_dll in \ | 527 staged_dll_basenames = [os.path.basename(staged_dll) for staged_dll in \ |
515 glob.glob(os.path.join(version_dir, '*.dll'))] | 528 glob.glob(os.path.join(version_dir, '*.dll'))] |
516 component_dll_filenames = [] | 529 component_dll_filenames = [] |
517 for component_dll in [dll for dll in build_dlls if \ | 530 for component_dll in [dll for dll in build_dlls if \ |
518 os.path.basename(dll) not in staged_dll_basenames]: | 531 os.path.basename(dll) not in staged_dll_basenames]: |
519 component_dll_name = os.path.basename(component_dll) | 532 component_dll_name = os.path.basename(component_dll) |
520 # ash*.dll remoting_*.dll's don't belong in the archive (it doesn't depend | 533 # ash*.dll remoting_*.dll's don't belong in the archive (it doesn't depend |
521 # on them in gyp). Trying to copy them causes a build race when creating the | 534 # on them in gyp). Trying to copy them causes a build race when creating the |
522 # installer archive in component mode. See: crbug.com/180996 and | 535 # installer archive in component mode. See: crbug.com/180996 and |
523 # crbug.com/586967 | 536 # crbug.com/586967 |
(...skipping 39 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
563 staging_dir, options.output_dir, | 576 staging_dir, options.output_dir, |
564 options.enable_hidpi) | 577 options.enable_hidpi) |
565 | 578 |
566 # Now copy the remainder of the files from the build dir. | 579 # Now copy the remainder of the files from the build dir. |
567 CopyAllFilesToStagingDir(config, options.distribution, | 580 CopyAllFilesToStagingDir(config, options.distribution, |
568 staging_dir, options.build_dir, | 581 staging_dir, options.build_dir, |
569 options.enable_hidpi) | 582 options.enable_hidpi) |
570 | 583 |
571 if options.component_build == '1': | 584 if options.component_build == '1': |
572 DoComponentBuildTasks(staging_dir, options.build_dir, | 585 DoComponentBuildTasks(staging_dir, options.build_dir, |
573 options.target_arch, current_version) | 586 options.target_arch, options.setup_runtime_deps, |
587 options.component_runtime_deps, current_version) | |
574 | 588 |
575 version_numbers = current_version.split('.') | 589 version_numbers = current_version.split('.') |
576 current_build_number = version_numbers[2] + '.' + version_numbers[3] | 590 current_build_number = version_numbers[2] + '.' + version_numbers[3] |
577 prev_build_number = '' | 591 prev_build_number = '' |
578 if prev_version: | 592 if prev_version: |
579 version_numbers = prev_version.split('.') | 593 version_numbers = prev_version.split('.') |
580 prev_build_number = version_numbers[2] + '.' + version_numbers[3] | 594 prev_build_number = version_numbers[2] + '.' + version_numbers[3] |
581 | 595 |
582 # Name of the archive file built (for example - chrome.7z or | 596 # Name of the archive file built (for example - chrome.7z or |
583 # patch-<old_version>-<new_version>.7z or patch-<new_version>.7z | 597 # patch-<old_version>-<new_version>.7z or patch-<new_version>.7z |
(...skipping 42 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
626 help='Name used to prefix names of generated archives.') | 640 help='Name used to prefix names of generated archives.') |
627 parser.add_option('--enable_hidpi', default='0', | 641 parser.add_option('--enable_hidpi', default='0', |
628 help='Whether to include HiDPI resource files.') | 642 help='Whether to include HiDPI resource files.') |
629 parser.add_option('--component_build', default='0', | 643 parser.add_option('--component_build', default='0', |
630 help='Whether this archive is packaging a component build. This will ' | 644 help='Whether this archive is packaging a component build. This will ' |
631 'also turn off compression of chrome.7z into chrome.packed.7z and ' | 645 'also turn off compression of chrome.7z into chrome.packed.7z and ' |
632 'helpfully delete any old chrome.packed.7z in |output_dir|.') | 646 'helpfully delete any old chrome.packed.7z in |output_dir|.') |
633 parser.add_option('--depfile', | 647 parser.add_option('--depfile', |
634 help='Generate a depfile with the given name listing the implicit inputs ' | 648 help='Generate a depfile with the given name listing the implicit inputs ' |
635 'to the archive process that can be used with a build system.') | 649 'to the archive process that can be used with a build system.') |
650 | |
651 # TODO(jbauman): Make --component_runtime_deps and --setup_runtime_deps | |
652 # mandatory when GYP is deprecated on Windows. | |
653 parser.add_option('--component_runtime_deps', | |
654 help='A file listing runtime dependencies. This will be used to get a ' | |
655 'list of component build DLLs to archive.') | |
gab
2016/06/22 14:04:20
s/to archive/to archive in a component build/
(he
| |
656 parser.add_option('--setup_runtime_deps', | |
657 help='A file listing runtime dependencies for setup.exe. This will be ' | |
658 'used to get a list of component build DLLs to archive.') | |
636 parser.add_option('--target_arch', default='x86', | 659 parser.add_option('--target_arch', default='x86', |
637 help='Specify the target architecture for installer - this is used ' | 660 help='Specify the target architecture for installer - this is used ' |
638 'to determine which CRT runtime files to pull and package ' | 661 'to determine which CRT runtime files to pull and package ' |
639 'with the installer archive {x86|x64}.') | 662 'with the installer archive {x86|x64}.') |
640 parser.add_option('-v', '--verbose', action='store_true', dest='verbose', | 663 parser.add_option('-v', '--verbose', action='store_true', dest='verbose', |
641 default=False) | 664 default=False) |
642 | 665 |
643 options, _ = parser.parse_args() | 666 options, _ = parser.parse_args() |
644 if not options.build_dir: | 667 if not options.build_dir: |
645 parser.error('You must provide a build dir.') | 668 parser.error('You must provide a build dir.') |
(...skipping 14 matching lines...) Expand all Loading... | |
660 MINI_INSTALLER_INPUT_FILE) | 683 MINI_INSTALLER_INPUT_FILE) |
661 | 684 |
662 return options | 685 return options |
663 | 686 |
664 | 687 |
665 if '__main__' == __name__: | 688 if '__main__' == __name__: |
666 options = _ParseOptions() | 689 options = _ParseOptions() |
667 if options.verbose: | 690 if options.verbose: |
668 print sys.argv | 691 print sys.argv |
669 sys.exit(main(options)) | 692 sys.exit(main(options)) |
OLD | NEW |