| 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',
|
|
|