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

Unified Diff: scripts/common/chromium_utils.py

Issue 11413207: Add a 'filter' option to zip_build to allow for build post-processing. (Closed) Base URL: http://git.chromium.org/chromium/tools/build.git@unit_test_refactor
Patch Set: Created 8 years, 1 month 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « no previous file | scripts/slave/zip_build.py » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: scripts/common/chromium_utils.py
diff --git a/scripts/common/chromium_utils.py b/scripts/common/chromium_utils.py
index a5fc2296f7add14cabec1eebac12dad3ef520b2b..3048b3c73ba922712916480092608f7ba3cac7fa 100644
--- a/scripts/common/chromium_utils.py
+++ b/scripts/common/chromium_utils.py
@@ -475,7 +475,7 @@ def CopyFileToDir(src_path, dest_dir, dest_fn=None):
def MakeZip(output_dir, archive_name, file_list, file_relative_dir,
- raise_error=True, remove_archive_directory=True):
+ raise_error=True, remove_archive_directory=True, replacements=None):
"""Packs files into a new zip archive.
Files are first copied into a directory within the output_dir named for
@@ -499,6 +499,10 @@ def MakeZip(output_dir, archive_name, file_list, file_relative_dir,
the list is not found.
remove_archive_directory: Whether to remove the archive staging directory
before copying files over to it.
+ replacements: A list of fun(path) -> path functions. For each file
+ to add, transform the path with each function in replacements in order,
+ and read data from the resulting file instead. i.e. foo.exe could actually
+ contain data from foo.asan.exe.
Returns:
A tuple consisting of (archive_dir, zip_file_path), where archive_dir
@@ -527,6 +531,17 @@ def MakeZip(output_dir, archive_name, file_list, file_relative_dir,
# These paths are relative to the file_relative_dir. We need to copy
# them over maintaining the relative directories, where applicable.
src_path = os.path.join(file_relative_dir, needed_file)
+ new_src_path = src_path
+ for func in (replacements or []):
+ new_src_path = func(src_path)
+ if new_src_path is None:
nsylvain 2012/11/28 18:55:52 Why do you break if it's None? Maybe another repl
iannucci 2012/11/29 02:19:12 The next function would get None as it's argument.
+ break
+ if new_src_path is None:
+ print 'Skipping %s' % src_path
+ continue
+ if new_src_path != src_path:
+ print 'Replacing contents of %s with %s' % (src_path, new_src_path)
+ src_path = new_src_path
dirname, basename = os.path.split(needed_file)
try:
if os.path.isdir(src_path):
@@ -535,9 +550,9 @@ def MakeZip(output_dir, archive_name, file_list, file_relative_dir,
elif dirname != '' and basename != '':
dest_dir = os.path.join(archive_dir, dirname)
MaybeMakeDirectory(dest_dir)
- CopyFileToDir(src_path, dest_dir)
+ CopyFileToDir(src_path, dest_dir, basename)
else:
- CopyFileToDir(src_path, archive_dir)
+ CopyFileToDir(src_path, archive_dir, basename)
except PathNotFound:
if raise_error:
raise
« no previous file with comments | « no previous file | scripts/slave/zip_build.py » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698