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

Unified Diff: grit/node/base.py

Issue 118663003: Set target platform on root node earlier. (Closed) Base URL: https://grit-i18n.googlecode.com/svn/trunk
Patch Set: Remove code duplication. Created 7 years 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 | « grit/grd_reader_unittest.py ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: grit/node/base.py
diff --git a/grit/node/base.py b/grit/node/base.py
index 7541fa404058cd2d4470ab855804e2e575020f4b..b54ba79a164605b4d10f020b8e4ee9924ba329ef 100644
--- a/grit/node/base.py
+++ b/grit/node/base.py
@@ -442,6 +442,23 @@ class Node(object):
return []
@classmethod
+ def GetPlatformAssertion(cls, target_platform):
+ '''If the platform is a specific well-known platform, this returns
+ the is_xyz string representing that platform (e.g. is_linux),
+ otherwise the empty string.
+ '''
+ platform = ''
+ if target_platform == 'darwin':
+ platform = 'is_macosx'
+ elif target_platform.startswith('linux'):
+ platform = 'is_linux'
+ elif target_platform in ('cygwin', 'win32'):
+ platform = 'is_win'
+ elif target_platform in ('android', 'ios'):
+ platform = 'is_%s' % target_platform
+ return platform
+
+ @classmethod
def EvaluateExpression(cls, expr, defs, target_platform, extra_variables=None):
'''Worker for EvaluateCondition (below) and conditions in XTB files.'''
cache_dict = cls.eval_expr_cache[
@@ -452,17 +469,18 @@ class Node(object):
return symbol in defs
def pp_if(symbol):
return defs.get(symbol, False)
+ platform_assertion = Node.GetPlatformAssertion(target_platform)
variable_map = {
'defs' : defs,
'os': target_platform,
- 'is_linux': target_platform.startswith('linux'),
- 'is_macosx': target_platform == 'darwin',
- 'is_win': target_platform in ('cygwin', 'win32'),
- 'is_android': target_platform == 'android',
- 'is_ios': target_platform == 'ios',
- 'is_posix': (target_platform in ('darwin', 'linux2', 'linux3', 'sunos5',
- 'android', 'ios')
- or 'bsd' in target_platform),
+ 'is_linux': platform_assertion == 'is_linux',
+ 'is_macosx': platform_assertion == 'is_macosx',
+ 'is_win': platform_assertion == 'is_win',
+ 'is_android': platform_assertion == 'is_android',
+ 'is_ios': platform_assertion == 'is_ios',
Nico 2013/12/27 16:55:24 nit (optional, and since this is already landed be
+ # is_posix is not mutually exclusive of the others
+ 'is_posix': (target_platform in ('darwin', 'linux2', 'linux3', 'sunos5')
+ or 'bsd' in sys.platform),
Nico 2014/01/28 20:48:35 Hey, it looks like you dropped 'ios' and 'android'
Jói 2014/01/29 13:41:39 Whoops, that looks like a bad merge maybe. Not int
'pp_ifdef' : pp_ifdef,
'pp_if' : pp_if,
}
« no previous file with comments | « grit/grd_reader_unittest.py ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698