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

Unified Diff: isolate_merge.py

Issue 11048019: Add everything from src/tools/isolate r159537. (Closed) Base URL: https://git.chromium.org/chromium/tools/swarm_client.git@master
Patch Set: Ensure --similarity is sticky Created 8 years, 2 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « isolate.py ('k') | list_test_cases.py » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: isolate_merge.py
diff --git a/isolate_merge.py b/isolate_merge.py
new file mode 100755
index 0000000000000000000000000000000000000000..cab86d65c4a81485f285f5373b4a27967dedacb7
--- /dev/null
+++ b/isolate_merge.py
@@ -0,0 +1,68 @@
+#!/usr/bin/env python
+# Copyright (c) 2012 The Chromium Authors. All rights reserved.
+# Use of this source code is governed by a BSD-style license that can be
+# found in the LICENSE file.
+
+"""Merges multiple OS-specific gyp dependency lists into one that works on all
+of them.
+
+The logic is relatively simple. Takes the current conditions, add more
+condition, find the strict subset. Done.
+"""
+
+import logging
+import sys
+
+from isolate import Configs, DEFAULT_OSES, eval_content, extract_comment
+from isolate import load_isolate_as_config, union, convert_map_to_isolate_dict
+from isolate import reduce_inputs, invert_map, print_all
+import run_test_cases
+
+
+def load_isolates(items, default_oses):
+ """Parses each .isolate file and returns the merged results.
+
+ It only loads what load_isolate_as_config() can process.
+
+ Return values:
+ files: dict(filename, set(OS where this filename is a dependency))
+ dirs: dict(dirame, set(OS where this dirname is a dependency))
+ oses: set(all the OSes referenced)
+ """
+ configs = Configs(default_oses, None)
+ for item in items:
+ logging.debug('loading %s' % item)
+ with open(item, 'r') as f:
+ content = f.read()
+ new_config = load_isolate_as_config(
+ eval_content(content), extract_comment(content), default_oses)
+ logging.debug('has OSes: %s' % ','.join(k for k in new_config.per_os if k))
+ configs = union(configs, new_config)
+ logging.debug('Total OSes: %s' % ','.join(k for k in configs.per_os if k))
+ return configs
+
+
+def main(args=None):
+ parser = run_test_cases.OptionParserWithLogging(
+ usage='%prog <options> [file1] [file2] ...')
+ parser.add_option(
+ '-o', '--output', help='Output to file instead of stdout')
+ parser.add_option(
+ '--os', default=','.join(DEFAULT_OSES),
+ help='Inject the list of OSes, default: %default')
+
+ options, args = parser.parse_args(args)
+
+ configs = load_isolates(args, options.os.split(','))
+ data = convert_map_to_isolate_dict(
+ *reduce_inputs(*invert_map(configs.flatten())))
+ if options.output:
+ with open(options.output, 'wb') as f:
+ print_all(configs.file_comment, data, f)
+ else:
+ print_all(configs.file_comment, data, sys.stdout)
+ return 0
+
+
+if __name__ == '__main__':
+ sys.exit(main())
« no previous file with comments | « isolate.py ('k') | list_test_cases.py » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698