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

Unified Diff: build/gypi_to_gn.py

Issue 305013009: Handle more types of gypis in gypi_to_gn. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 6 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 | « no previous file | net/BUILD.gn » ('j') | net/BUILD.gn » ('J')
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: build/gypi_to_gn.py
diff --git a/build/gypi_to_gn.py b/build/gypi_to_gn.py
index 3d5b89916dccf2df856891975487a7d26463e43a..d52e3a0b3fdcf5b2e8149a8056b5a4751fbf6f40 100644
--- a/build/gypi_to_gn.py
+++ b/build/gypi_to_gn.py
@@ -85,25 +85,17 @@ def LoadPythonDictionary(path):
assert isinstance(file_data, dict), "%s does not eval to a dictionary" % path
+ # Flatten any variables to the top level.
+ if 'variables' in file_data:
+ file_data.update(file_data['variables'])
+ del file_data['variables']
+
# Strip any conditions.
if 'conditions' in file_data:
del file_data['conditions']
if 'target_conditions' in file_data:
del file_data['target_conditions']
- # Flatten any varaiables to the top level.
- if 'variables' in file_data:
- file_data.update(file_data['variables'])
- del file_data['variables']
-
- # If the contents of the root is a dictionary with exactly one kee
- # "variables", promote the contents of that to the top level. Some .gypi
- # files contain this and some don't depending on how they expect to be
- # embedded in a .gyp file. We don't actually care either way so collapse it
- # away.
- if len(file_data) == 1 and 'variables' in file_data:
- return file_data['variables']
-
return file_data
@@ -151,6 +143,15 @@ def main():
assert len(split) == 2, "Replacement must be of the form 'key=value'."
data = ReplaceSubstrings(data, split[0], split[1])
+ # 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',
+ # Convert these to regular variables.
+ for key in data:
+ if len(key) > 1 and key[len(key) - 1] == '%':
+ data[key[:-1]] = data[key]
+ del data[key]
+
print gn_helpers.ToGNString(data)
if __name__ == '__main__':
« no previous file with comments | « no previous file | net/BUILD.gn » ('j') | net/BUILD.gn » ('J')

Powered by Google App Engine
This is Rietveld 408576698