Commit f79c2e88 authored by scottmg's avatar scottmg Committed by Commit bot

Add support for create_installer_archive.py to generate a depfile

Adds functionality to create_installer_archive.py to generate a .d file
that includes all of the files that it packages into chrome[.packed].7z.
This is done by tracking the source of all the files that are copied
into the staging dir that is given to 7za to package the .7z file.

The depfile is then used in a gyp 'depfile' to correctly specify the
implicit dependencies for the mini_installer target. Previously it used
a fake output of 'xxx2.out' to cause it to rebuild every time (which is
what we're trying to avoid in this change).

Additionally, switch from a rule to an action in gyp -- gyp currently
only supports 'depfile' on actions, and as there's only one file being
built here, they're equivalent.

BUG=342974,451499

Review URL: https://codereview.chromium.org/887673003

Cr-Commit-Position: refs/heads/master@{#314015}
parent c45e09b0
...@@ -166,9 +166,10 @@ ...@@ -166,9 +166,10 @@
'process_outputs_as_sources': 1, 'process_outputs_as_sources': 1,
'message': 'Generating version information' 'message': 'Generating version information'
}, },
],
'actions': [
{ {
'rule_name': 'installer_archive', 'action_name': 'installer_archive',
'extension': 'release',
'variables': { 'variables': {
'create_installer_archive_py_path': 'create_installer_archive_py_path':
'../tools/build/win/create_installer_archive.py', '../tools/build/win/create_installer_archive.py',
...@@ -192,7 +193,7 @@ ...@@ -192,7 +193,7 @@
'component_build_flag': '', 'component_build_flag': '',
}, },
'outputs': [ 'outputs': [
'<(PRODUCT_DIR)/<(RULE_INPUT_NAME).packed.7z', '<(PRODUCT_DIR)/chrome.packed.7z',
], ],
}], }],
['disable_nacl==1', { ['disable_nacl==1', {
...@@ -239,22 +240,24 @@ ...@@ -239,22 +240,24 @@
'<(PRODUCT_DIR)/nacl_irt_x86_32.nexe', '<(PRODUCT_DIR)/nacl_irt_x86_32.nexe',
'<(PRODUCT_DIR)/nacl_irt_x86_64.nexe', '<(PRODUCT_DIR)/nacl_irt_x86_64.nexe',
'<(PRODUCT_DIR)/locales/en-US.pak', '<(PRODUCT_DIR)/locales/en-US.pak',
'mini_installer/chrome.release',
], ],
'outputs': [ 'outputs': [
# Also note that chrome.packed.7z is defined as an output in a # Also note that chrome.packed.7z is defined as an output in a
# conditional above. # conditional above.
'xxx2.out', '<(PRODUCT_DIR)/chrome.7z',
'<(PRODUCT_DIR)/<(RULE_INPUT_NAME).7z',
'<(PRODUCT_DIR)/setup.ex_', '<(PRODUCT_DIR)/setup.ex_',
'<(INTERMEDIATE_DIR)/packed_files.rc', '<(INTERMEDIATE_DIR)/packed_files.rc',
], ],
'depfile': '<(INTERMEDIATE_DIR)/installer_archive.d',
'action': [ 'action': [
'python', 'python',
'<(create_installer_archive_py_path)', '<(create_installer_archive_py_path)',
'--build_dir', '<(PRODUCT_DIR)', '--build_dir', '<(PRODUCT_DIR)',
'--staging_dir', '<(INTERMEDIATE_DIR)', '--staging_dir', '<(INTERMEDIATE_DIR)',
'--input_file', '<(RULE_INPUT_PATH)', '--input_file', 'mini_installer/chrome.release',
'--resource_file_path', '<(INTERMEDIATE_DIR)/packed_files.rc', '--resource_file_path', '<(INTERMEDIATE_DIR)/packed_files.rc',
'--depfile', '<(INTERMEDIATE_DIR)/installer_archive.d',
'<(enable_hidpi_flag)', '<(enable_hidpi_flag)',
'<(component_build_flag)', '<(component_build_flag)',
'<(target_arch_flag)', '<(target_arch_flag)',
......
...@@ -42,6 +42,9 @@ TEMP_ARCHIVE_DIR = "temp_installer_archive" ...@@ -42,6 +42,9 @@ TEMP_ARCHIVE_DIR = "temp_installer_archive"
VERSION_FILE = "VERSION" VERSION_FILE = "VERSION"
g_archive_inputs = []
def BuildVersion(build_dir): def BuildVersion(build_dir):
"""Returns the full build version string constructed from information in """Returns the full build version string constructed from information in
VERSION_FILE. Any segment not found in that file will default to '0'. VERSION_FILE. Any segment not found in that file will default to '0'.
...@@ -121,6 +124,7 @@ def CopySectionFilesToStagingDir(config, section, staging_dir, src_dir): ...@@ -121,6 +124,7 @@ def CopySectionFilesToStagingDir(config, section, staging_dir, src_dir):
for src_path in src_paths: for src_path in src_paths:
dst_path = os.path.join(dst_dir, os.path.basename(src_path)) dst_path = os.path.join(dst_dir, os.path.basename(src_path))
if not os.path.exists(dst_path): if not os.path.exists(dst_path):
g_archive_inputs.append(src_path)
shutil.copy(src_path, dst_dir) shutil.copy(src_path, dst_dir)
def GenerateDiffPatch(options, orig_file, new_file, patch_file): def GenerateDiffPatch(options, orig_file, new_file, patch_file):
...@@ -194,6 +198,44 @@ def CreateArchiveFile(options, staging_dir, current_version, prev_version): ...@@ -194,6 +198,44 @@ def CreateArchiveFile(options, staging_dir, current_version, prev_version):
lzma_exec = GetLZMAExec(options.build_dir) lzma_exec = GetLZMAExec(options.build_dir)
archive_file = os.path.join(options.output_dir, archive_file = os.path.join(options.output_dir,
options.output_name + ARCHIVE_SUFFIX) options.output_name + ARCHIVE_SUFFIX)
if options.depfile:
# If a depfile was requested, do the glob of the staging dir and generate
# a list of dependencies in .d format. We list the files that were copied
# into the staging dir, not the files that are actually in the staging dir
# because the ones in the staging dir will never be edited, and we want
# to have the build be triggered when the thing-that-was-copied-there
# changes.
def path_fixup(path):
"""Fixes path for depfile format: backslash to forward slash, and
backslash escaping for spaces."""
return path.replace('\\', '/').replace(' ', '\\ ')
# Gather the list of files in the staging dir that will be zipped up. We
# only gather this list to make sure that g_archive_inputs is complete (i.e.
# that there's not file copies that got missed).
staging_contents = []
for root, dirs, files in os.walk(os.path.join(staging_dir, CHROME_DIR)):
for filename in files:
staging_contents.append(path_fixup(os.path.join(root, filename)))
# Make sure there's an archive_input for each staging dir file.
for staging_file in staging_contents:
for archive_input in g_archive_inputs:
archive_rel = path_fixup(archive_input)
if (os.path.basename(staging_file).lower() ==
os.path.basename(archive_rel).lower()):
break
else:
raise Exception('Did not find an archive input file for "%s"' %
staging_file)
# Finally, write the depfile referencing the inputs.
with open(options.depfile, 'wb') as f:
f.write(path_fixup(os.path.relpath(archive_file, options.build_dir)) +
': \\\n')
f.write(' ' + ' \\\n '.join(path_fixup(x) for x in g_archive_inputs))
cmd = [lzma_exec, cmd = [lzma_exec,
'a', 'a',
'-t7z', '-t7z',
...@@ -350,6 +392,7 @@ def CopyIfChanged(src, target_dir): ...@@ -350,6 +392,7 @@ def CopyIfChanged(src, target_dir):
copy over it. See http://crbug.com/305877 for details.""" copy over it. See http://crbug.com/305877 for details."""
assert os.path.isdir(target_dir) assert os.path.isdir(target_dir)
dest = os.path.join(target_dir, os.path.basename(src)) dest = os.path.join(target_dir, os.path.basename(src))
g_archive_inputs.append(src)
if os.path.exists(dest): if os.path.exists(dest):
# We assume the files are OK to buffer fully into memory since we know # We assume the files are OK to buffer fully into memory since we know
# they're only 1-2M. # they're only 1-2M.
...@@ -451,6 +494,7 @@ def DoComponentBuildTasks(staging_dir, build_dir, target_arch, current_version): ...@@ -451,6 +494,7 @@ def DoComponentBuildTasks(staging_dir, build_dir, target_arch, current_version):
setup_component_dlls = glob.glob(os.path.join(build_dir, setup_component_dlls = glob.glob(os.path.join(build_dir,
setup_component_dll_glob)) setup_component_dll_glob))
for setup_component_dll in setup_component_dlls: for setup_component_dll in setup_component_dlls:
g_archive_inputs.append(setup_component_dll)
shutil.copy(setup_component_dll, installer_dir) shutil.copy(setup_component_dll, installer_dir)
# Stage all the component DLLs found in |build_dir| to the |version_dir| (for # Stage all the component DLLs found in |build_dir| to the |version_dir| (for
...@@ -471,6 +515,7 @@ def DoComponentBuildTasks(staging_dir, build_dir, target_arch, current_version): ...@@ -471,6 +515,7 @@ def DoComponentBuildTasks(staging_dir, build_dir, target_arch, current_version):
if component_dll_name.startswith('remoting_'): if component_dll_name.startswith('remoting_'):
continue continue
component_dll_filenames.append(component_dll_name) component_dll_filenames.append(component_dll_name)
g_archive_inputs.append(component_dll)
shutil.copy(component_dll, version_dir) shutil.copy(component_dll, version_dir)
# Augment {version}.manifest to include all component DLLs as part of the # Augment {version}.manifest to include all component DLLs as part of the
...@@ -574,6 +619,9 @@ def _ParseOptions(): ...@@ -574,6 +619,9 @@ def _ParseOptions():
help='Whether this archive is packaging a component build. This will ' help='Whether this archive is packaging a component build. This will '
'also turn off compression of chrome.7z into chrome.packed.7z and ' 'also turn off compression of chrome.7z into chrome.packed.7z and '
'helpfully delete any old chrome.packed.7z in |output_dir|.') 'helpfully delete any old chrome.packed.7z in |output_dir|.')
parser.add_option('--depfile',
help='Generate a depfile with the given name listing the implicit inputs '
'to the archive process that can be used with a build system.')
parser.add_option('--target_arch', default='x86', parser.add_option('--target_arch', default='x86',
help='Specify the target architecture for installer - this is used ' help='Specify the target architecture for installer - this is used '
'to determine which CRT runtime files to pull and package ' 'to determine which CRT runtime files to pull and package '
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment