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