Chromium Code Reviews| OLD | NEW |
|---|---|
| 1 # Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 # Copyright (c) 2012 The Chromium Authors. All rights reserved. |
| 2 # Use of this source code is governed by a BSD-style license that can be | 2 # Use of this source code is governed by a BSD-style license that can be |
| 3 # found in the LICENSE file. | 3 # found in the LICENSE file. |
| 4 | 4 |
| 5 """ Set of basic operations/utilities that are used by the build. """ | 5 """ Set of basic operations/utilities that are used by the build. """ |
| 6 | 6 |
| 7 from contextlib import contextmanager | 7 from contextlib import contextmanager |
| 8 import ast | 8 import ast |
| 9 import base64 | 9 import base64 |
| 10 import cStringIO | 10 import cStringIO |
| (...skipping 1987 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 1998 | 1998 |
| 1999 def GetSlaveNamesForBuilder(builders, builder_name): | 1999 def GetSlaveNamesForBuilder(builders, builder_name): |
| 2000 """Returns a list of slave hostnames for the given builder name.""" | 2000 """Returns a list of slave hostnames for the given builder name.""" |
| 2001 slaves = [] | 2001 slaves = [] |
| 2002 pool_names = builders['builders'][builder_name]['slave_pools'] | 2002 pool_names = builders['builders'][builder_name]['slave_pools'] |
| 2003 for pool_name in pool_names: | 2003 for pool_name in pool_names: |
| 2004 slaves.extend(builders['slave_pools'][pool_name]['slaves']) | 2004 slaves.extend(builders['slave_pools'][pool_name]['slaves']) |
| 2005 return slaves | 2005 return slaves |
| 2006 | 2006 |
| 2007 def IsClangWinBuild(build_dir, target): | 2007 def IsClangWinBuild(build_dir, target): |
| 2008 """Check if a ninja build has been build with Clang on Windows. | 2008 """Check if a ninja build has been build with Clang on Windows.""" |
| 2009 | |
| 2010 This checks the build.ninja file from the build directory to see which | |
| 2011 compiler has been used for a build. | |
| 2012 """ | |
| 2013 # TODO(sebmarchand): Make this works for gn builds, currently only the gyp one | |
| 2014 # is supported. | |
| 2015 if not IsWindows(): | 2009 if not IsWindows(): |
| 2016 return False | 2010 return False |
| 2017 build_file = os.path.join(build_dir, target, 'build.ninja') | 2011 |
| 2018 if not os.path.isfile(build_file): | 2012 gn_file = os.path.join(build_dir, target, 'args.gn') |
| 2013 if not os.path.isfile(gn_file): | |
| 2014 print 'WARNING: Unable to find the args.gn file.' | |
| 2019 return False | 2015 return False |
| 2020 # Matches e.g. "cl_x86 = path/to/clang-cl.exe" | 2016 # Matches e.g. "gn_arg = value" |
| 2021 clang_cl_re = re.compile( | 2017 gn_arg_re = re.compile(r'^(?P<flag>[^= ]+)\s*=\s*(?P<value>[^ \n]+)$', |
| 2022 r'^cl_x\d\d\s+\=\s+(?P<compiler_path>[^ ]+)\s.*$', | 2018 re.VERBOSE) |
|
Nico
2016/08/25 15:14:15
i don't think you're using any of re.VERBOSE's fea
Sébastien Marchand
2016/08/25 15:16:08
Done.
| |
| 2023 re.VERBOSE) | 2019 for line in open(gn_file): |
| 2024 for line in open(build_file): | 2020 m = gn_arg_re.match(line) |
| 2025 m = clang_cl_re.match(line) | 2021 if m and m.group('flag') == 'is_clang': |
| 2026 if m: | 2022 return m.group('value') == 'true' |
| 2027 return 'clang' in m.group('compiler_path') | |
| 2028 return False | 2023 return False |
| OLD | NEW |