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 |
| (...skipping 445 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 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 # Copies component build DLLs and generates required config files and manifests | 461 # 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 | 462 # in order for chrome.exe and setup.exe to be able to find those DLLs at |
| 463 # run-time. | 463 # run-time. |
| 464 # 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 |
| 465 # an official build. | 465 # an official build. |
| 466 def DoComponentBuildTasks(staging_dir, build_dir, target_arch, current_version): | 466 def DoComponentBuildTasks(staging_dir, build_dir, target_arch, runtime_deps, |
| 467 current_version): | |
| 467 # Get the required directories for the upcoming operations. | 468 # Get the required directories for the upcoming operations. |
| 468 chrome_dir = os.path.join(staging_dir, CHROME_DIR) | 469 chrome_dir = os.path.join(staging_dir, CHROME_DIR) |
| 469 version_dir = os.path.join(chrome_dir, current_version) | 470 version_dir = os.path.join(chrome_dir, current_version) |
| 470 installer_dir = os.path.join(version_dir, 'Installer') | 471 installer_dir = os.path.join(version_dir, 'Installer') |
| 471 # |installer_dir| is technically only created post-install, but we need it | 472 # |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. | 473 # now to add setup.exe's config and manifest to the archive. |
| 473 if not os.path.exists(installer_dir): | 474 if not os.path.exists(installer_dir): |
| 474 os.mkdir(installer_dir) | 475 os.mkdir(installer_dir) |
| 475 | 476 |
| 476 # Explicitly list the component DLLs setup.exe depends on (this list may | 477 # Explicitly list the component DLLs setup.exe depends on (this list may |
| (...skipping 10 matching lines...) Expand all Loading... | |
| 487 'icuuc.dll', | 488 'icuuc.dll', |
| 488 'msvc*.dll', | 489 'msvc*.dll', |
| 489 'ucrtbase*.dll', | 490 'ucrtbase*.dll', |
| 490 'vcruntime*.dll', | 491 'vcruntime*.dll', |
| 491 # DLLs needed due to source sets. | 492 # DLLs needed due to source sets. |
| 492 'base_i18n.dll', | 493 'base_i18n.dll', |
| 493 'ipc.dll', | 494 'ipc.dll', |
| 494 'net.dll', | 495 'net.dll', |
| 495 'prefs.dll', | 496 'prefs.dll', |
| 496 'protobuf_lite.dll', | 497 'protobuf_lite.dll', |
| 497 'url_lib.dll' ] | 498 'url_lib.dll' ] |
|
gab
2016/06/17 18:27:11
This write_runtime_deps thing is awesome :-). Can
| |
| 498 for setup_component_dll_glob in setup_component_dll_globs: | 499 for setup_component_dll_glob in setup_component_dll_globs: |
| 499 setup_component_dlls = glob.glob(os.path.join(build_dir, | 500 setup_component_dlls = glob.glob(os.path.join(build_dir, |
| 500 setup_component_dll_glob)) | 501 setup_component_dll_glob)) |
| 501 if len(setup_component_dlls) == 0: | 502 if len(setup_component_dlls) == 0: |
| 502 raise Exception('Error: missing expected DLL for component build ' | 503 raise Exception('Error: missing expected DLL for component build ' |
| 503 'mini_installer: "%s"' % setup_component_dll_glob) | 504 'mini_installer: "%s"' % setup_component_dll_glob) |
| 504 for setup_component_dll in setup_component_dlls: | 505 for setup_component_dll in setup_component_dlls: |
| 505 g_archive_inputs.append(setup_component_dll) | 506 g_archive_inputs.append(setup_component_dll) |
| 506 shutil.copy(setup_component_dll, installer_dir) | 507 shutil.copy(setup_component_dll, installer_dir) |
| 507 | 508 |
| 508 # Stage all the component DLLs found in |build_dir| to the |version_dir| (for | 509 # Stage all the component DLLs found in |build_dir| to the |version_dir| (for |
| 509 # the version assembly to be able to refer to them below and make sure | 510 # 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 | 511 # chrome.exe can find them at runtime). The component DLLs are considered to |
| 511 # be all the DLLs which have not already been added to the |version_dir| by | 512 # be all the DLLs which have not already been added to the |version_dir| by |
| 512 # virtue of chrome.release. | 513 # virtue of chrome.release. |
|
gab
2016/06/17 18:27:11
Update comment:
# Stage all the DLLs listed in |r
| |
| 513 build_dlls = glob.glob(os.path.join(build_dir, '*.dll')) | 514 if runtime_deps: |
| 515 build_dlls = set() | |
| 516 args = open(runtime_deps).read() | |
| 517 for l in args.splitlines(): | |
| 518 if os.path.splitext(l)[1] == ".dll": | |
| 519 build_dlls.add(os.path.join(build_dir, l)) | |
| 520 else: | |
| 521 build_dlls = glob.glob(os.path.join(build_dir, '*.dll')) | |
|
gab
2016/06/17 18:27:11
When would |runtime_deps| ever not be specified? W
jbauman
2016/06/17 19:51:24
Do we currently want to continue supporting gyp wi
| |
| 514 staged_dll_basenames = [os.path.basename(staged_dll) for staged_dll in \ | 522 staged_dll_basenames = [os.path.basename(staged_dll) for staged_dll in \ |
| 515 glob.glob(os.path.join(version_dir, '*.dll'))] | 523 glob.glob(os.path.join(version_dir, '*.dll'))] |
| 516 component_dll_filenames = [] | 524 component_dll_filenames = [] |
| 517 for component_dll in [dll for dll in build_dlls if \ | 525 for component_dll in [dll for dll in build_dlls if \ |
| 518 os.path.basename(dll) not in staged_dll_basenames]: | 526 os.path.basename(dll) not in staged_dll_basenames]: |
| 519 component_dll_name = os.path.basename(component_dll) | 527 component_dll_name = os.path.basename(component_dll) |
| 520 # ash*.dll remoting_*.dll's don't belong in the archive (it doesn't depend | 528 # 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 | 529 # 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 | 530 # installer archive in component mode. See: crbug.com/180996 and |
| 523 # crbug.com/586967 | 531 # crbug.com/586967 |
| 524 if (component_dll_name.startswith('remoting_') or | 532 if (component_dll_name.startswith('remoting_') or |
| 525 component_dll_name.startswith('ash')): | 533 component_dll_name.startswith('ash')): |
| 526 continue | 534 continue |
|
gab
2016/06/17 18:27:11
rm 528-534
| |
| 527 | 535 |
| 528 component_dll_filenames.append(component_dll_name) | 536 component_dll_filenames.append(component_dll_name) |
| 529 g_archive_inputs.append(component_dll) | 537 g_archive_inputs.append(component_dll) |
| 530 shutil.copy(component_dll, version_dir) | 538 shutil.copy(component_dll, version_dir) |
| 531 | 539 |
| 532 # Augment {version}.manifest to include all component DLLs as part of the | 540 # Augment {version}.manifest to include all component DLLs as part of the |
| 533 # assembly it constitutes, which will allow dependents of this assembly to | 541 # assembly it constitutes, which will allow dependents of this assembly to |
| 534 # find these DLLs. | 542 # find these DLLs. |
| 535 version_assembly_dll_additions = [] | 543 version_assembly_dll_additions = [] |
| 536 for dll_filename in component_dll_filenames: | 544 for dll_filename in component_dll_filenames: |
| (...skipping 26 matching lines...) Expand all Loading... | |
| 563 staging_dir, options.output_dir, | 571 staging_dir, options.output_dir, |
| 564 options.enable_hidpi) | 572 options.enable_hidpi) |
| 565 | 573 |
| 566 # Now copy the remainder of the files from the build dir. | 574 # Now copy the remainder of the files from the build dir. |
| 567 CopyAllFilesToStagingDir(config, options.distribution, | 575 CopyAllFilesToStagingDir(config, options.distribution, |
| 568 staging_dir, options.build_dir, | 576 staging_dir, options.build_dir, |
| 569 options.enable_hidpi) | 577 options.enable_hidpi) |
| 570 | 578 |
| 571 if options.component_build == '1': | 579 if options.component_build == '1': |
| 572 DoComponentBuildTasks(staging_dir, options.build_dir, | 580 DoComponentBuildTasks(staging_dir, options.build_dir, |
| 573 options.target_arch, current_version) | 581 options.target_arch, options.runtime_deps, |
| 582 current_version) | |
| 574 | 583 |
| 575 version_numbers = current_version.split('.') | 584 version_numbers = current_version.split('.') |
| 576 current_build_number = version_numbers[2] + '.' + version_numbers[3] | 585 current_build_number = version_numbers[2] + '.' + version_numbers[3] |
| 577 prev_build_number = '' | 586 prev_build_number = '' |
| 578 if prev_version: | 587 if prev_version: |
| 579 version_numbers = prev_version.split('.') | 588 version_numbers = prev_version.split('.') |
| 580 prev_build_number = version_numbers[2] + '.' + version_numbers[3] | 589 prev_build_number = version_numbers[2] + '.' + version_numbers[3] |
| 581 | 590 |
| 582 # Name of the archive file built (for example - chrome.7z or | 591 # Name of the archive file built (for example - chrome.7z or |
| 583 # patch-<old_version>-<new_version>.7z or patch-<new_version>.7z | 592 # 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.') | 635 help='Name used to prefix names of generated archives.') |
| 627 parser.add_option('--enable_hidpi', default='0', | 636 parser.add_option('--enable_hidpi', default='0', |
| 628 help='Whether to include HiDPI resource files.') | 637 help='Whether to include HiDPI resource files.') |
| 629 parser.add_option('--component_build', default='0', | 638 parser.add_option('--component_build', default='0', |
| 630 help='Whether this archive is packaging a component build. This will ' | 639 help='Whether this archive is packaging a component build. This will ' |
| 631 'also turn off compression of chrome.7z into chrome.packed.7z and ' | 640 'also turn off compression of chrome.7z into chrome.packed.7z and ' |
| 632 'helpfully delete any old chrome.packed.7z in |output_dir|.') | 641 'helpfully delete any old chrome.packed.7z in |output_dir|.') |
| 633 parser.add_option('--depfile', | 642 parser.add_option('--depfile', |
| 634 help='Generate a depfile with the given name listing the implicit inputs ' | 643 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.') | 644 'to the archive process that can be used with a build system.') |
| 645 parser.add_option('--runtime_deps', | |
| 646 help='A file listing runtime dependencies. This will be used to get a ' | |
| 647 'list of component build DLLs to archive.') | |
|
gab
2016/06/17 18:27:11
Make this a required option given comment above.
| |
| 636 parser.add_option('--target_arch', default='x86', | 648 parser.add_option('--target_arch', default='x86', |
| 637 help='Specify the target architecture for installer - this is used ' | 649 help='Specify the target architecture for installer - this is used ' |
| 638 'to determine which CRT runtime files to pull and package ' | 650 'to determine which CRT runtime files to pull and package ' |
| 639 'with the installer archive {x86|x64}.') | 651 'with the installer archive {x86|x64}.') |
| 640 parser.add_option('-v', '--verbose', action='store_true', dest='verbose', | 652 parser.add_option('-v', '--verbose', action='store_true', dest='verbose', |
| 641 default=False) | 653 default=False) |
| 642 | 654 |
| 643 options, _ = parser.parse_args() | 655 options, _ = parser.parse_args() |
| 644 if not options.build_dir: | 656 if not options.build_dir: |
| 645 parser.error('You must provide a build dir.') | 657 parser.error('You must provide a build dir.') |
| (...skipping 14 matching lines...) Expand all Loading... | |
| 660 MINI_INSTALLER_INPUT_FILE) | 672 MINI_INSTALLER_INPUT_FILE) |
| 661 | 673 |
| 662 return options | 674 return options |
| 663 | 675 |
| 664 | 676 |
| 665 if '__main__' == __name__: | 677 if '__main__' == __name__: |
| 666 options = _ParseOptions() | 678 options = _ParseOptions() |
| 667 if options.verbose: | 679 if options.verbose: |
| 668 print sys.argv | 680 print sys.argv |
| 669 sys.exit(main(options)) | 681 sys.exit(main(options)) |
| OLD | NEW |