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 1242 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
1253 path = os.path.join(BUILD_DIR, 'masters/*/' + cue) | 1253 path = os.path.join(BUILD_DIR, 'masters/*/' + cue) |
1254 filenames = [] | 1254 filenames = [] |
1255 if include_public: | 1255 if include_public: |
1256 filenames += glob.glob(path) | 1256 filenames += glob.glob(path) |
1257 if include_internal: | 1257 if include_internal: |
1258 filenames += glob.glob(path_internal) | 1258 filenames += glob.glob(path_internal) |
1259 return [os.path.abspath(os.path.dirname(f)) for f in filenames] | 1259 return [os.path.abspath(os.path.dirname(f)) for f in filenames] |
1260 | 1260 |
1261 | 1261 |
1262 def MasterPath(mastername, include_public=True, include_internal=True): | 1262 def MasterPath(mastername, include_public=True, include_internal=True): |
1263 path = os.path.join(BUILD_DIR, 'masters', 'master.%s' % mastername) | 1263 if not mastername.startswith('master.'): |
ghost stip (do not use)
2015/10/21 16:26:06
weird. that should be for a user-facing util, not
| |
1264 path_internal = os.path.join( | 1264 mastername = 'master.' + mastername |
1265 BUILD_DIR, os.pardir, 'build_internal', 'masters', | 1265 |
1266 'master.%s' % mastername) | 1266 for inc, base in ( |
1267 if include_public and os.path.isdir(path): | 1267 (include_public, env.Build), |
1268 return path | 1268 (include_internal, env.BuildInternal)): |
1269 if include_internal and os.path.isdir(path_internal): | 1269 if inc and base: |
1270 return path_internal | 1270 path = os.path.join(base, 'masters', mastername) |
1271 if os.path.isdir(path): | |
1272 return path | |
1271 raise LookupError('Path for master %s not found' % mastername) | 1273 raise LookupError('Path for master %s not found' % mastername) |
1272 | 1274 |
1273 | 1275 |
1274 def ListMastersWithSlaves(include_public=True, include_internal=True): | 1276 def ListMastersWithSlaves(include_public=True, include_internal=True): |
1275 masters_path = ListMasters('builders.pyl', include_public, include_internal) | 1277 masters_path = ListMasters('builders.pyl', include_public, include_internal) |
1276 masters_path.extend(ListMasters('slaves.cfg', include_public, | 1278 masters_path.extend(ListMasters('slaves.cfg', include_public, |
1277 include_internal)) | 1279 include_internal)) |
1278 return masters_path | 1280 return masters_path |
1279 | 1281 |
1280 | 1282 |
(...skipping 85 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
1366 yield | 1368 yield |
1367 finally: | 1369 finally: |
1368 os.chdir(old_cwd) | 1370 os.chdir(old_cwd) |
1369 | 1371 |
1370 | 1372 |
1371 def ParsePythonCfg(cfg_filepath, fail_hard=False): | 1373 def ParsePythonCfg(cfg_filepath, fail_hard=False): |
1372 """Retrieves data from a python config file.""" | 1374 """Retrieves data from a python config file.""" |
1373 if not os.path.exists(cfg_filepath): | 1375 if not os.path.exists(cfg_filepath): |
1374 return None | 1376 return None |
1375 | 1377 |
1376 # Execute 'slaves.sfg' in the master path environment. | 1378 # Execute 'slaves.cfg' in the master path environment. |
1377 with MasterEnvironment(os.path.dirname(os.path.abspath(cfg_filepath))): | 1379 with MasterEnvironment(os.path.dirname(os.path.abspath(cfg_filepath))): |
1378 try: | 1380 try: |
1379 local_vars = {} | 1381 local_vars = {} |
1380 execfile(os.path.join(cfg_filepath), local_vars) | 1382 execfile(os.path.join(cfg_filepath), local_vars) |
1381 del local_vars['__builtins__'] | 1383 del local_vars['__builtins__'] |
1382 return local_vars | 1384 return local_vars |
1383 except Exception as e: | 1385 except Exception as e: |
1384 # pylint: disable=C0323 | 1386 # pylint: disable=C0323 |
1385 print >>sys.stderr, 'An error occurred while parsing %s: %s' % ( | 1387 print >>sys.stderr, 'An error occurred while parsing %s: %s' % ( |
1386 cfg_filepath, e) | 1388 cfg_filepath, e) |
(...skipping 541 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
1928 return False | 1930 return False |
1929 # Matches e.g. "cl_x86 = path/to/clang-cl.exe" | 1931 # Matches e.g. "cl_x86 = path/to/clang-cl.exe" |
1930 clang_cl_re = re.compile( | 1932 clang_cl_re = re.compile( |
1931 r'^cl_x\d\d\s+\=\s+(?P<compiler_path>[^ ]+)\s.*$', | 1933 r'^cl_x\d\d\s+\=\s+(?P<compiler_path>[^ ]+)\s.*$', |
1932 re.VERBOSE) | 1934 re.VERBOSE) |
1933 for line in open(build_file): | 1935 for line in open(build_file): |
1934 m = clang_cl_re.match(line) | 1936 m = clang_cl_re.match(line) |
1935 if m: | 1937 if m: |
1936 return 'clang' in m.group('compiler_path') | 1938 return 'clang' in m.group('compiler_path') |
1937 return False | 1939 return False |
OLD | NEW |