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

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

Issue 12326117: Fix create_installer_archive.py to be more flexible with output directory names (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: apply same x64 changes to the gypi file Created 7 years, 9 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 | « chrome/installer/mini_installer.gypi ('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 334 matching lines...) Expand 10 before | Expand all | Expand 10 after
345 345
346 modified_manifest_file = open( 346 modified_manifest_file = open(
347 os.path.join(output_dir, manifest_name), 'w') 347 os.path.join(output_dir, manifest_name), 'w')
348 modified_manifest_file.write(''.join(manifest_lines)) 348 modified_manifest_file.write(''.join(manifest_lines))
349 modified_manifest_file.close() 349 modified_manifest_file.close()
350 350
351 351
352 # Copy the relevant CRT DLLs to |build_dir|. We copy DLLs from all versions 352 # Copy the relevant CRT DLLs to |build_dir|. We copy DLLs from all versions
353 # of VS installed to make sure we have the correct CRT version, unused DLLs 353 # of VS installed to make sure we have the correct CRT version, unused DLLs
354 # should not conflict with the others anyways. 354 # should not conflict with the others anyways.
355 def CopyVisualStudioRuntimeDLLs(build_dir): 355 def CopyVisualStudioRuntimeDLLs(build_dir, target_arch):
356 is_debug = os.path.basename(build_dir) == 'Debug' 356 is_debug = os.path.basename(build_dir).startswith('Debug')
357 if not is_debug and os.path.basename(build_dir) != 'Release': 357 if not is_debug and not os.path.basename(build_dir).startswith('Release'):
358 print ("Warning: could not determine build configuration from " 358 print ("Warning: could not determine build configuration from "
359 "output directory, assuming Release build.") 359 "output directory, assuming Release build.")
360 360
361 crt_dlls = [] 361 crt_dlls = []
362 if is_debug: 362 if is_debug:
363 crt_dlls = glob.glob( 363 crt_dlls = glob.glob(
364 "C:/Program Files (x86)/Microsoft Visual Studio */VC/redist/" 364 "C:/Program Files (x86)/Microsoft Visual Studio */VC/redist/"
365 "Debug_NonRedist/x86/Microsoft.*.DebugCRT/*.dll") 365 "Debug_NonRedist/" + target_arch + "/Microsoft.*.DebugCRT/*.dll")
366 else: 366 else:
367 crt_dlls = glob.glob( 367 crt_dlls = glob.glob(
368 "C:/Program Files (x86)/Microsoft Visual Studio */VC/redist/x86/" 368 "C:/Program Files (x86)/Microsoft Visual Studio */VC/redist/" + \
369 "Microsoft.*.CRT/*.dll") 369 target_arch + "/Microsoft.*.CRT/*.dll")
370 370
371 # Also handle the case where someone is building using only winsdk and 371 # Also handle the case where someone is building using only winsdk and
372 # doesn't have Visual Studio installed. 372 # doesn't have Visual Studio installed.
373 if not crt_dlls: 373 if not crt_dlls:
374 # On a 64-bit system, 32-bit dlls are in SysWOW64 (don't ask). 374 if target_arch == 'x64':
375 if os.access("C:/Windows/SysWOW64", os.F_OK): 375 # check we are are on a 64bit system by existance of WOW64 dir
robertshield 2013/02/27 00:48:31 nit: existance -> existence
Will Harris 2013/02/27 01:16:08 Done.
376 sys_dll_dir = "C:/Windows/SysWOW64" 376 if os.access("C:/Windows/SysWOW64", os.F_OK):
377 sys_dll_dir = "C:/Windows/System32"
378 else:
379 # only support packaging of 64bit installer on 64bit system
380 print ("Warning: could not find x64 CRT DLLs on x86 system")
robertshield 2013/02/27 00:48:31 If we hit this, will the resulting installer packa
Will Harris 2013/02/27 01:16:08 install package is useful - on line 393 a second w
377 else: 381 else:
378 sys_dll_dir = "C:/Windows/System32" 382 # On a 64-bit system, 32-bit dlls are in SysWOW64 (don't ask).
383 if os.access("C:/Windows/SysWOW64", os.F_OK):
384 sys_dll_dir = "C:/Windows/SysWOW64"
385 else:
386 sys_dll_dir = "C:/Windows/System32"
379 387
380 if is_debug: 388 if is_debug:
381 crt_dlls = glob.glob(os.path.join(sys_dll_dir, "msvc*0d.dll")) 389 crt_dlls = glob.glob(os.path.join(sys_dll_dir, "msvc*0d.dll"))
382 else: 390 else:
383 crt_dlls = glob.glob(os.path.join(sys_dll_dir, "msvc*0.dll")) 391 crt_dlls = glob.glob(os.path.join(sys_dll_dir, "msvc*0.dll"))
384 392
385 if not crt_dlls: 393 if not crt_dlls:
386 print ("Warning: could not find CRT DLLs to copy to build dir - target " 394 print ("Warning: could not find CRT DLLs to copy to build dir - target "
387 "may not run on a system that doesn't have those DLLs.") 395 "may not run on a system that doesn't have those DLLs.")
388 396
389 for dll in crt_dlls: 397 for dll in crt_dlls:
390 shutil.copy(dll, build_dir) 398 shutil.copy(dll, build_dir)
391 399
392 400
393 # Copies component build DLLs and generates required config files and manifests 401 # Copies component build DLLs and generates required config files and manifests
394 # in order for chrome.exe and setup.exe to be able to find those DLLs at 402 # in order for chrome.exe and setup.exe to be able to find those DLLs at
395 # run-time. 403 # run-time.
396 # This is meant for developer builds only and should never be used to package 404 # This is meant for developer builds only and should never be used to package
397 # an official build. 405 # an official build.
398 def DoComponentBuildTasks(staging_dir, build_dir, current_version): 406 def DoComponentBuildTasks(staging_dir, build_dir, target_arch, current_version):
399 # Get the required directories for the upcoming operations. 407 # Get the required directories for the upcoming operations.
400 chrome_dir = os.path.join(staging_dir, CHROME_DIR) 408 chrome_dir = os.path.join(staging_dir, CHROME_DIR)
401 version_dir = os.path.join(chrome_dir, current_version) 409 version_dir = os.path.join(chrome_dir, current_version)
402 installer_dir = os.path.join(version_dir, 'Installer') 410 installer_dir = os.path.join(version_dir, 'Installer')
403 # |installer_dir| is technically only created post-install, but we need it 411 # |installer_dir| is technically only created post-install, but we need it
404 # now to add setup.exe's config and manifest to the archive. 412 # now to add setup.exe's config and manifest to the archive.
405 if not os.path.exists(installer_dir): 413 if not os.path.exists(installer_dir):
406 os.mkdir(installer_dir) 414 os.mkdir(installer_dir)
407 415
408 # Copy the VS CRT DLLs to |build_dir|. This must be done before the general 416 # Copy the VS CRT DLLs to |build_dir|. This must be done before the general
409 # copy step below to ensure the CRT DLLs are added to the archive and marked 417 # copy step below to ensure the CRT DLLs are added to the archive and marked
410 # as a dependency in the exe manifests generated below. 418 # as a dependency in the exe manifests generated below.
411 CopyVisualStudioRuntimeDLLs(build_dir) 419 CopyVisualStudioRuntimeDLLs(build_dir, target_arch)
412 420
413 # Copy all the DLLs in |build_dir| to the version directory. Simultaneously 421 # Copy all the DLLs in |build_dir| to the version directory. Simultaneously
414 # build a list of their names to mark them as dependencies of chrome.exe and 422 # build a list of their names to mark them as dependencies of chrome.exe and
415 # setup.exe later. 423 # setup.exe later.
416 dlls = glob.glob(os.path.join(build_dir, '*.dll')) 424 dlls = glob.glob(os.path.join(build_dir, '*.dll'))
417 dll_names = [] 425 dll_names = []
418 for dll in dlls: 426 for dll in dlls:
419 shutil.copy(dll, version_dir) 427 shutil.copy(dll, version_dir)
420 dll_names.append(os.path.splitext(os.path.basename(dll))[0]) 428 dll_names.append(os.path.splitext(os.path.basename(dll))[0])
421 429
(...skipping 85 matching lines...) Expand 10 before | Expand all | Expand 10 after
507 CopyAllFilesToStagingDir(config, options.distribution, 515 CopyAllFilesToStagingDir(config, options.distribution,
508 staging_dir, options.output_dir, 516 staging_dir, options.output_dir,
509 options.enable_hidpi, options.enable_touch_ui) 517 options.enable_hidpi, options.enable_touch_ui)
510 518
511 # Now copy the remainder of the files from the build dir. 519 # Now copy the remainder of the files from the build dir.
512 CopyAllFilesToStagingDir(config, options.distribution, 520 CopyAllFilesToStagingDir(config, options.distribution,
513 staging_dir, options.build_dir, 521 staging_dir, options.build_dir,
514 options.enable_hidpi, options.enable_touch_ui) 522 options.enable_hidpi, options.enable_touch_ui)
515 523
516 if options.component_build == '1': 524 if options.component_build == '1':
517 DoComponentBuildTasks(staging_dir, options.build_dir, current_version) 525 DoComponentBuildTasks(staging_dir, options.build_dir,
526 options.target_arch, current_version)
518 527
519 version_numbers = current_version.split('.') 528 version_numbers = current_version.split('.')
520 current_build_number = version_numbers[2] + '.' + version_numbers[3] 529 current_build_number = version_numbers[2] + '.' + version_numbers[3]
521 prev_build_number = '' 530 prev_build_number = ''
522 if prev_version: 531 if prev_version:
523 version_numbers = prev_version.split('.') 532 version_numbers = prev_version.split('.')
524 prev_build_number = version_numbers[2] + '.' + version_numbers[3] 533 prev_build_number = version_numbers[2] + '.' + version_numbers[3]
525 534
526 # Name of the archive file built (for example - chrome.7z or 535 # Name of the archive file built (for example - chrome.7z or
527 # patch-<old_version>-<new_version>.7z or patch-<new_version>.7z 536 # patch-<old_version>-<new_version>.7z or patch-<new_version>.7z
(...skipping 40 matching lines...) Expand 10 before | Expand all | Expand 10 after
568 help='Name used to prefix names of generated archives.') 577 help='Name used to prefix names of generated archives.')
569 parser.add_option('--enable_hidpi', default='0', 578 parser.add_option('--enable_hidpi', default='0',
570 help='Whether to include HiDPI resource files.') 579 help='Whether to include HiDPI resource files.')
571 parser.add_option('--enable_touch_ui', default='0', 580 parser.add_option('--enable_touch_ui', default='0',
572 help='Whether to include resource files from the "TOUCH" section of the ' 581 help='Whether to include resource files from the "TOUCH" section of the '
573 'input file.') 582 'input file.')
574 parser.add_option('--component_build', default='0', 583 parser.add_option('--component_build', default='0',
575 help='Whether this archive is packaging a component build. This will ' 584 help='Whether this archive is packaging a component build. This will '
576 'also turn off compression of chrome.7z into chrome.packed.7z and ' 585 'also turn off compression of chrome.7z into chrome.packed.7z and '
577 'helpfully delete any old chrome.packed.7z in |output_dir|.') 586 'helpfully delete any old chrome.packed.7z in |output_dir|.')
587 parser.add_option('--target_arch', default='x86',
588 help='Specify the target architecture for installer - this is used '
589 'to determine which CRT runtime files to pull and package '
590 'with the installer archive {x86|x64}.')
578 591
579 options, _ = parser.parse_args() 592 options, _ = parser.parse_args()
580 if not options.build_dir: 593 if not options.build_dir:
581 parser.error('You must provide a build dir.') 594 parser.error('You must provide a build dir.')
582 595
583 options.build_dir = os.path.normpath(options.build_dir) 596 options.build_dir = os.path.normpath(options.build_dir)
584 597
585 if not options.staging_dir: 598 if not options.staging_dir:
586 parser.error('You must provide a staging dir.') 599 parser.error('You must provide a staging dir.')
587 600
588 if not options.input_file: 601 if not options.input_file:
589 parser.error('You must provide an input file') 602 parser.error('You must provide an input file')
590 603
591 if not options.output_dir: 604 if not options.output_dir:
592 options.output_dir = options.build_dir 605 options.output_dir = options.build_dir
593 606
594 if not options.resource_file_path: 607 if not options.resource_file_path:
595 options.resource_file_path = os.path.join(options.build_dir, 608 options.resource_file_path = os.path.join(options.build_dir,
596 MINI_INSTALLER_INPUT_FILE) 609 MINI_INSTALLER_INPUT_FILE)
597 610
598 return options 611 return options
599 612
600 613
601 if '__main__' == __name__: 614 if '__main__' == __name__:
602 print sys.argv 615 print sys.argv
603 sys.exit(main(_ParseOptions())) 616 sys.exit(main(_ParseOptions()))
OLDNEW
« no previous file with comments | « chrome/installer/mini_installer.gypi ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698