Chromium Code Reviews| Index: pylib/gyp/input.py |
| diff --git a/pylib/gyp/input.py b/pylib/gyp/input.py |
| index bb853a5408ecf7c93bd38524e4d962438e63a51c..d602bccc654eefed6c4c2e8f6f39f51e228e2ba9 100644 |
| --- a/pylib/gyp/input.py |
| +++ b/pylib/gyp/input.py |
| @@ -341,7 +341,8 @@ def ProcessToolsetsInDict(data): |
| for condition in data['conditions']: |
| if type(condition) is list: |
| for condition_dict in condition[1:]: |
| - ProcessToolsetsInDict(condition_dict) |
| + if type(condition_dict) is dict: |
| + ProcessToolsetsInDict(condition_dict) |
| # TODO(mark): I don't love this name. It just means that it's going to load |
| @@ -1037,17 +1038,33 @@ def EvalCondition(condition, conditions_key, phase, variables, build_file): |
| that nothing should be used.""" |
| if type(condition) is not list: |
| raise GypError(conditions_key + ' must be a list') |
| - if len(condition) != 2 and len(condition) != 3: |
| + if len(condition) < 2: |
| # It's possible that condition[0] won't work in which case this |
| # attempt will raise its own IndexError. That's probably fine. |
| raise GypError(conditions_key + ' ' + condition[0] + |
| - ' must be length 2 or 3, not ' + str(len(condition))) |
| + ' must be at least length 2, not ' + str(len(condition))) |
| + |
| + i = 0 |
| + result = None |
| + while result == None and i < len(condition): |
|
scottmg
2014/11/14 17:09:44
what does the error look like if you mix up the co
Shezan Baig (Bloomberg)
2014/11/14 17:25:44
If there are two dicts in a row, it would treat th
|
| + cond_expr = condition[i] |
| + true_dict = condition[i + 1] |
| + if len(condition) > i + 2 and type(condition[i + 2]) is dict: |
| + false_dict = condition[i + 2] |
| + i = i + 3 |
| + else: |
| + false_dict = None |
| + i = i + 2 |
| + result = EvalSingleCondition( |
| + cond_expr, true_dict, false_dict, phase, variables, build_file) |
| + |
| + return result |
| - [cond_expr, true_dict] = condition[0:2] |
| - false_dict = None |
| - if len(condition) == 3: |
| - false_dict = condition[2] |
| +def EvalSingleCondition( |
| + cond_expr, true_dict, false_dict, phase, variables, build_file): |
| + """Returns true_dict if cond_expr evaluates to true, and false_dict |
| + otherwise.""" |
| # Do expansions on the condition itself. Since the conditon can naturally |
| # contain variable references without needing to resort to GYP expansion |
| # syntax, this is of dubious value for variables, but someone might want to |