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

Unified Diff: tools/gypi_to_gn.py

Issue 2187153003: Fuchsia: Builds run_vm_tests and a wrapper program for running it. (Closed) Base URL: https://chromium.googlesource.com/external/github.com/dart-lang/sdk/@master
Patch Set: Created 4 years, 5 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 | « runtime/vm/BUILD.gn ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: tools/gypi_to_gn.py
diff --git a/tools/gypi_to_gn.py b/tools/gypi_to_gn.py
index 1aa092c6453d6d1350cb65fb4fbb997a5f5fb444..ca62a12b72433f77e56d9c8379bba022a8562564 100755
--- a/tools/gypi_to_gn.py
+++ b/tools/gypi_to_gn.py
@@ -129,10 +129,28 @@ def ReplaceSubstrings(values, search_for, replace_with):
# Assume everything else is unchanged.
return values
+def KeepOnly(values, filters):
+ """Recursively filters out strings not ending in "f" from "values"""
+
+ if isinstance(values, list):
+ return [v for v in values if v.endswith(tuple(filters))]
+
+ if isinstance(values, dict):
+ result = {}
+ for key, value in values.items():
+ new_key = KeepOnly(key, filters)
+ new_value = KeepOnly(value, filters)
+ result[new_key] = new_value
+ return result
+
+ return values
+
def main():
parser = OptionParser()
parser.add_option("-r", "--replace", action="append",
help="Replaces substrings. If passed a=b, replaces all substrs a with b.")
+ parser.add_option("-k", "--keep_only", default = [], action="append",
+ help="Keeps only files ending with the listed strings.")
(options, args) = parser.parse_args()
if len(args) != 1:
@@ -149,6 +167,9 @@ def main():
assert len(split) == 2, "Replacement must be of the form 'key=value'."
data = ReplaceSubstrings(data, split[0], split[1])
+ if options.keep_only != []:
+ data = KeepOnly(data, options.keep_only)
+
# Sometimes .gypi files use the GYP syntax with percents at the end of the
# variable name (to indicate not to overwrite a previously-defined value):
# 'foo%': 'bar',
« no previous file with comments | « runtime/vm/BUILD.gn ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698