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 import copy | 7 import copy |
8 import errno | 8 import errno |
9 import fnmatch | 9 import fnmatch |
10 import glob | 10 import glob |
(...skipping 973 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
984 path = os.path.join(os.path.dirname(__file__), '..', '..', | 984 path = os.path.join(os.path.dirname(__file__), '..', '..', |
985 'masters/*/' + cue) | 985 'masters/*/' + cue) |
986 filenames = [] | 986 filenames = [] |
987 if include_public: | 987 if include_public: |
988 filenames += glob.glob(path) | 988 filenames += glob.glob(path) |
989 if include_internal: | 989 if include_internal: |
990 filenames += glob.glob(path_internal) | 990 filenames += glob.glob(path_internal) |
991 return [os.path.abspath(os.path.dirname(f)) for f in filenames] | 991 return [os.path.abspath(os.path.dirname(f)) for f in filenames] |
992 | 992 |
993 | 993 |
| 994 def ParsePythonCfg(cfg_filepath): |
| 995 """Retrieves data from a python config file.""" |
| 996 if not os.path.exists(cfg_filepath): |
| 997 return None |
| 998 base_path = os.path.dirname(os.path.abspath(cfg_filepath)) |
| 999 old_sys_path = sys.path |
| 1000 sys.path = sys.path + [base_path] |
| 1001 old_path = os.getcwd() |
| 1002 try: |
| 1003 os.chdir(base_path) |
| 1004 local_vars = {} |
| 1005 execfile(os.path.join(cfg_filepath), local_vars) |
| 1006 del local_vars['__builtins__'] |
| 1007 return local_vars |
| 1008 finally: |
| 1009 os.chdir(old_path) |
| 1010 sys.path = old_sys_path |
| 1011 |
| 1012 |
994 def RunSlavesCfg(slaves_cfg): | 1013 def RunSlavesCfg(slaves_cfg): |
995 """Runs slaves.cfg in a consistent way.""" | 1014 """Runs slaves.cfg in a consistent way.""" |
996 if not os.path.exists(slaves_cfg): | 1015 if not os.path.exists(slaves_cfg): |
997 return [] | 1016 return [] |
998 slaves_path = os.path.dirname(os.path.abspath(slaves_cfg)) | 1017 slaves_path = os.path.dirname(os.path.abspath(slaves_cfg)) |
999 old_sys_path = sys.path | 1018 old_sys_path = sys.path |
1000 sys.path = sys.path + [slaves_path] | 1019 sys.path = sys.path + [slaves_path] |
1001 try: | 1020 try: |
1002 old_path = os.getcwd() | 1021 old_path = os.getcwd() |
1003 try: | 1022 try: |
(...skipping 156 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1160 'This is almost certainly incorrect.' % (build_dir, platform_key)) | 1179 'This is almost certainly incorrect.' % (build_dir, platform_key)) |
1161 if use_out: | 1180 if use_out: |
1162 legacy_path = 'out' | 1181 legacy_path = 'out' |
1163 else: | 1182 else: |
1164 legacy_path = legacy_paths[platform_key] | 1183 legacy_path = legacy_paths[platform_key] |
1165 build_dir = os.path.join(os.path.dirname(build_dir), legacy_path) | 1184 build_dir = os.path.join(os.path.dirname(build_dir), legacy_path) |
1166 print >> sys.stderr, ('Assuming you meant "%s"' % build_dir) | 1185 print >> sys.stderr, ('Assuming you meant "%s"' % build_dir) |
1167 bad = True | 1186 bad = True |
1168 | 1187 |
1169 return (build_dir, bad) | 1188 return (build_dir, bad) |
OLD | NEW |