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

Unified Diff: tools/gypi_to_gn.py

Issue 2023703002: Beginning work on GN build (Closed) Base URL: git@github.com:dart-lang/sdk.git@master
Patch Set: Really add //build. Add dart_bootstrap rule. Created 4 years, 7 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 | « third_party/zlib/zutil.c ('k') | tools/make_links.py » ('j') | 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 a107f94fcafd14c9883c57f4438f064fd8ded1e8..9bd890f807a752ba208c53e66a0a1e475b8495b0 100644
--- a/tools/gypi_to_gn.py
+++ b/tools/gypi_to_gn.py
@@ -128,10 +128,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:
@@ -148,6 +166,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 | « third_party/zlib/zutil.c ('k') | tools/make_links.py » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698