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 317 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 328 raise ValueError('could not find {0} in the manifest:\n{1}'.format( | 328 raise ValueError('could not find {0} in the manifest:\n{1}'.format( |
| 329 insert_before, ''.join(manifest_lines))) | 329 insert_before, ''.join(manifest_lines))) |
| 330 manifest_lines.insert(insert_index, inserted_string) | 330 manifest_lines.insert(insert_index, inserted_string) |
| 331 | 331 |
| 332 modified_manifest_file = open( | 332 modified_manifest_file = open( |
| 333 os.path.join(output_dir, manifest_name), 'w') | 333 os.path.join(output_dir, manifest_name), 'w') |
| 334 modified_manifest_file.write(''.join(manifest_lines)) | 334 modified_manifest_file.write(''.join(manifest_lines)) |
| 335 modified_manifest_file.close() | 335 modified_manifest_file.close() |
| 336 | 336 |
| 337 | 337 |
| 338 # Copy the relevant CRT DLLs to |build_dir|. We copy DLLs from all versions | |
| 339 # of VS installed to make sure we have the correct CRT version, unused DLLs | |
| 340 # should not conflict with the others anyways. | |
| 341 def CopyVisualStudioRuntimeDLLs(build_dir): | |
| 342 is_debug = build_dir.endswith('Debug/') | |
|
robertshield
2012/05/22 02:39:59
is the trailing slash guaranteed to be present? If
gab
2012/05/22 15:44:46
Yes, see [1] below.
| |
| 343 if not is_debug and not build_dir.endswith('Release/'): | |
| 344 print ("Warning: could not determine build configuration from " | |
| 345 "output directory, assuming Release build.") | |
| 346 | |
| 347 crt_dlls = [] | |
| 348 if is_debug: | |
| 349 crt_dlls = glob.glob( | |
| 350 "C:/Program Files (x86)/Microsoft Visual Studio */VC/redist/" | |
| 351 "Debug_NonRedist/x86/Microsoft.*.DebugCRT/*.dll") | |
| 352 else: | |
| 353 crt_dlls = glob.glob( | |
| 354 "C:/Program Files (x86)/Microsoft Visual Studio */VC/redist/x86/" | |
| 355 "Microsoft.*.CRT/*.dll") | |
| 356 | |
| 357 # Also handle the case where someone is building using only winsdk and | |
| 358 # doesn't have Visual Studio installed. | |
| 359 if not crt_dlls: | |
| 360 # On a 64-bit system, 32-bit dlls are in SysWOW64 (don't ask). | |
|
robertshield
2012/05/22 02:39:59
indeed :-)
gab
2012/05/22 15:44:46
Aaaah! Thanks for clarifying :)!
| |
| 361 if os.access("C:/Windows/SysWOW64", os.F_OK): | |
| 362 sys_dll_dir = "C:/Windows/SysWOW64" | |
| 363 else: | |
| 364 sys_dll_dir = "C:/Windows/System32" | |
| 365 | |
| 366 if is_debug: | |
| 367 crt_dlls = glob.glob(sys_dll_dir + "/msvc*0d.dll") | |
| 368 else: | |
| 369 crt_dlls = glob.glob(sys_dll_dir + "/msvc*0.dll") | |
| 370 | |
| 371 if not crt_dlls: | |
| 372 print ("Warning: could not find CRT DLLs to copy to build dir - target " | |
| 373 "may not run on a system that doesn't have those DLLs.") | |
| 374 | |
| 375 for dll in crt_dlls: | |
| 376 shutil.copy(dll, build_dir) | |
| 377 | |
| 378 | |
| 338 # Copies component build DLLs and generates required config files and manifests | 379 # Copies component build DLLs and generates required config files and manifests |
| 339 # in order for chrome.exe and setup.exe to be able to find those DLLs at | 380 # in order for chrome.exe and setup.exe to be able to find those DLLs at |
| 340 # run-time. | 381 # run-time. |
| 341 # This is meant for developer builds only and should never be used to package | 382 # This is meant for developer builds only and should never be used to package |
| 342 # an official build. | 383 # an official build. |
| 343 def DoComponentBuildTasks(staging_dir, build_dir, current_version): | 384 def DoComponentBuildTasks(staging_dir, build_dir, current_version): |
| 344 # Get the required directories for the upcoming operations. | 385 # Get the required directories for the upcoming operations. |
| 345 chrome_dir = os.path.join(staging_dir, CHROME_DIR) | 386 chrome_dir = os.path.join(staging_dir, CHROME_DIR) |
| 346 version_dir = os.path.join(chrome_dir, current_version) | 387 version_dir = os.path.join(chrome_dir, current_version) |
| 347 installer_dir = os.path.join(version_dir, 'Installer') | 388 installer_dir = os.path.join(version_dir, 'Installer') |
| 348 # |installer_dir| is technically only created post-install, but we need it | 389 # |installer_dir| is technically only created post-install, but we need it |
| 349 # now to add setup.exe's config and manifest to the archive. | 390 # now to add setup.exe's config and manifest to the archive. |
| 350 if not os.path.exists(installer_dir): | 391 if not os.path.exists(installer_dir): |
| 351 os.mkdir(installer_dir) | 392 os.mkdir(installer_dir) |
| 352 | 393 |
| 353 # Copy the relevant CRT DLLs to |build_dir|. We copy DLLs from all versions | 394 CopyVisualStudioRuntimeDLLs(build_dir) |
|
gab
2012/05/22 15:44:46
optional: Add a comment as to why this needs to be
| |
| 354 # of VS installed to make sure we have the correct CRT version, unused DLLs | |
| 355 # should not conflict with the others anyways. | |
| 356 crt_dlls = [] | |
| 357 if build_dir.endswith('Debug/'): | |
| 358 crt_dlls = glob.glob( | |
| 359 "C:/Program Files (x86)/Microsoft Visual Studio */VC/redist/" | |
| 360 "Debug_NonRedist/x86/Microsoft.*.DebugCRT/*.dll") | |
| 361 elif build_dir.endswith('Release/'): | |
| 362 crt_dlls = glob.glob( | |
| 363 "C:/Program Files (x86)/Microsoft Visual Studio */VC/redist/x86/" | |
| 364 "Microsoft.*.CRT/*.dll") | |
| 365 else: | |
| 366 print ("Warning: CRT DLLs not copied, could not determine build " | |
| 367 "configuration from output directory.") | |
| 368 | |
| 369 for dll in crt_dlls: | |
| 370 shutil.copy(dll, build_dir) | |
| 371 | 395 |
| 372 # Copy all the DLLs in |build_dir| to the version directory. Simultaneously | 396 # Copy all the DLLs in |build_dir| to the version directory. Simultaneously |
| 373 # build a list of their names to mark them as dependencies of chrome.exe and | 397 # build a list of their names to mark them as dependencies of chrome.exe and |
| 374 # setup.exe later. | 398 # setup.exe later. |
| 375 dlls = glob.glob(os.path.join(build_dir, '*.dll')) | 399 dlls = glob.glob(os.path.join(build_dir, '*.dll')) |
| 376 dll_names = [] | 400 dll_names = [] |
| 377 for dll in dlls: | 401 for dll in dlls: |
| 378 shutil.copy(dll, version_dir) | 402 shutil.copy(dll, version_dir) |
| 379 dll_names.append(os.path.splitext(os.path.basename(dll))[0]) | 403 dll_names.append(os.path.splitext(os.path.basename(dll))[0]) |
| 380 | 404 |
| (...skipping 149 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 530 parser.add_option('--enable_metro', default='0', | 554 parser.add_option('--enable_metro', default='0', |
| 531 help='Whether to include resource files from the "METRO" section of the ' | 555 help='Whether to include resource files from the "METRO" section of the ' |
| 532 'input file.') | 556 'input file.') |
| 533 parser.add_option('--component_build', default='0', | 557 parser.add_option('--component_build', default='0', |
| 534 help='Whether this archive is packaging a component build.') | 558 help='Whether this archive is packaging a component build.') |
| 535 | 559 |
| 536 options, args = parser.parse_args() | 560 options, args = parser.parse_args() |
| 537 if not options.build_dir: | 561 if not options.build_dir: |
| 538 parser.error('You must provide a build dir.') | 562 parser.error('You must provide a build dir.') |
| 539 elif not options.build_dir.endswith('/'): | 563 elif not options.build_dir.endswith('/'): |
| 540 options.build_dir += '/' | 564 options.build_dir += '/' |
|
gab
2012/05/22 15:44:46
[1]
| |
| 541 | 565 |
| 542 if not options.staging_dir: | 566 if not options.staging_dir: |
| 543 parser.error('You must provide a staging dir.') | 567 parser.error('You must provide a staging dir.') |
| 544 | 568 |
| 545 if not options.input_file: | 569 if not options.input_file: |
| 546 parser.error('You must provide an input file') | 570 parser.error('You must provide an input file') |
| 547 | 571 |
| 548 if not options.output_dir: | 572 if not options.output_dir: |
| 549 options.output_dir = options.build_dir | 573 options.output_dir = options.build_dir |
| 550 | 574 |
| 551 if not options.resource_file_path: | 575 if not options.resource_file_path: |
| 552 options.resource_file_path = os.path.join(options.build_dir, | 576 options.resource_file_path = os.path.join(options.build_dir, |
| 553 MINI_INSTALLER_INPUT_FILE) | 577 MINI_INSTALLER_INPUT_FILE) |
| 554 | 578 |
| 555 return options | 579 return options |
| 556 | 580 |
| 557 | 581 |
| 558 if '__main__' == __name__: | 582 if '__main__' == __name__: |
| 559 print sys.argv | 583 print sys.argv |
| 560 sys.exit(main(_ParseOptions())) | 584 sys.exit(main(_ParseOptions())) |
| OLD | NEW |