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

Unified Diff: build/android/gyp/util/build_utils.py

Issue 377803003: Change FileArg syntax (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@gn-resources
Patch Set: Rebase Created 6 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 | « no previous file | build/android/gyp/write_build_config.py » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: build/android/gyp/util/build_utils.py
diff --git a/build/android/gyp/util/build_utils.py b/build/android/gyp/util/build_utils.py
index 9ceb3fff18381fc3d87f2524bb9d593399fa5a29..f4a43a753ed1ef9eaa85ef457652661b10d616ed 100644
--- a/build/android/gyp/util/build_utils.py
+++ b/build/android/gyp/util/build_utils.py
@@ -8,6 +8,7 @@ import fnmatch
import json
import os
import pipes
+import re
import shlex
import shutil
import subprocess
@@ -315,7 +316,7 @@ def ExpandFileArgs(args):
"""Replaces file-arg placeholders in args.
These placeholders have the form:
- @(filename:key1:key2:...:keyn)
+ @FileArg(filename:key1:key2:...:keyn)
The value of such a placeholder is calculated by reading 'filename' as json.
And then extracting the value at [key1][key2]...[keyn].
@@ -327,19 +328,16 @@ def ExpandFileArgs(args):
"""
new_args = list(args)
file_jsons = dict()
+ r = re.compile('@FileArg\((.*?)\)')
for i, arg in enumerate(args):
- start = arg.find('@(')
- if start < 0:
+ match = r.search(arg)
+ if not match:
continue
- end = arg[start:].find(')')
- if end < 0:
- continue
- end += start
- if '@(' in arg[end:]:
- raise Exception('Only one file-lookup-expansion is allowed in each arg.')
+ if match.end() != len(arg):
+ raise Exception('Unexpected characters after FileArg: ' + arg)
- lookup_path = arg[start + 2:end].split(':')
+ lookup_path = match.group(1).split(':')
file_path = lookup_path[0]
if not file_path in file_jsons:
file_jsons[file_path] = ReadJson(file_path)
@@ -348,6 +346,7 @@ def ExpandFileArgs(args):
for k in lookup_path[1:]:
expansion = expansion[k]
- new_args[i] = arg[:start] + str(expansion) + arg[end + 1:]
+ new_args[i] = arg[:match.start()] + str(expansion)
+
return new_args
« no previous file with comments | « no previous file | build/android/gyp/write_build_config.py » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698