1 # Copyright 2013 The Chromium Authors. All rights reserved.
2 # Use of this source code is governed by a BSD-style license that can be
3 # found in the LICENSE file.
13 def memoize(default
=None):
14 """This decorator caches the return value of a parameterless pure function"""
17 @functools.wraps(func
)
21 val
.append(ret
if ret
is not None else default
)
22 if logging
.getLogger().isEnabledFor(logging
.INFO
):
23 print '%s -> %r' % (func
.__name
__, val
[0])
31 return sys
.platform
in ['win32', 'cygwin']
36 return sys
.platform
.startswith(('linux', 'freebsd'))
41 return sys
.platform
== 'darwin'
46 """Parses and returns GYP_DEFINES env var as a dictionary."""
47 return dict(arg
.split('=', 1)
48 for arg
in shlex
.split(os
.environ
.get('GYP_DEFINES', '')))
51 def gyp_msvs_version():
52 return os
.environ
.get('GYP_MSVS_VERSION', '')
57 Returns a string which is the distributed build engine in use (if any).
58 Possible values: 'goma', 'ib', ''
60 if 'goma' in gyp_defines():
63 if 'CHROME_HEADLESS' in os
.environ
:
64 return 'ib' # use (win and !goma and headless) as approximation of ib
70 Returns a string representing the platform this build is targetted for.
71 Possible values: 'win', 'mac', 'linux', 'ios', 'android'
73 if 'OS' in gyp_defines():
74 if 'android' in gyp_defines()['OS']:
77 return gyp_defines()['OS']
89 Returns a string representing the build engine (not compiler) to use.
90 Possible values: 'make', 'ninja', 'xcode', 'msvs', 'scons'
92 if 'GYP_GENERATORS' in os
.environ
:
93 # for simplicity, only support the first explicit generator
94 generator
= os
.environ
['GYP_GENERATORS'].split(',')[0]
95 if generator
.endswith('-android'):
96 return generator
.split('-')[0]
97 elif generator
.endswith('-ninja'):
102 if platform() == 'android':
103 # Good enough for now? Do any android bots use make?
105 elif platform() == 'ios':
114 assert False, 'Don\'t know what builder we\'re using!'