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 794 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 805 cur_dir = start_dir | 805 cur_dir = start_dir |
| 806 found_path = os.path.join(cur_dir, desired_path) | 806 found_path = os.path.join(cur_dir, desired_path) |
| 807 while not os.path.exists(found_path): | 807 while not os.path.exists(found_path): |
| 808 last_dir = cur_dir | 808 last_dir = cur_dir |
| 809 cur_dir = os.path.dirname(cur_dir) | 809 cur_dir = os.path.dirname(cur_dir) |
| 810 if last_dir == cur_dir: | 810 if last_dir == cur_dir: |
| 811 raise PathNotFound('Unable to find %s above %s' % | 811 raise PathNotFound('Unable to find %s above %s' % |
| 812 (desired_path, start_dir)) | 812 (desired_path, start_dir)) |
| 813 found_path = os.path.join(cur_dir, desired_path) | 813 found_path = os.path.join(cur_dir, desired_path) |
| 814 # Strip the entire original desired path from the end of the one found | 814 # Strip the entire original desired path from the end of the one found |
| 815 # and remove a trailing path separator, if present. | 815 # and remove a trailing path separator, if present (unless it's |
| 816 # filesystem/drive root). | |
| 816 found_path = found_path[:len(found_path) - len(desired_path)] | 817 found_path = found_path[:len(found_path) - len(desired_path)] |
| 817 if found_path.endswith(os.sep): | 818 if found_path.endswith(os.sep) and os.path.dirname(found_path) != found_path: |
|
estaab
2016/06/14 16:57:36
This changes the behavior of this function so if s
Paweł Hajdan Jr.
2016/06/15 07:59:10
Yup. FWIW, Windows might also be funny - I'll defi
| |
| 818 found_path = found_path[:len(found_path) - 1] | 819 found_path = found_path[:len(found_path) - 1] |
| 819 return found_path | 820 return found_path |
| 820 | 821 |
| 821 | 822 |
| 822 def FindUpward(start_dir, *desired_list): | 823 def FindUpward(start_dir, *desired_list): |
| 823 """Returns a path to the desired directory or file, searching upward. | 824 """Returns a path to the desired directory or file, searching upward. |
| 824 | 825 |
| 825 Searches within start_dir and within all its parents looking for the desired | 826 Searches within start_dir and within all its parents looking for the desired |
| 826 directory or file, which may be given in one or more path components. Returns | 827 directory or file, which may be given in one or more path components. Returns |
| 827 the full path to the desired object, or raises PathNotFound if it wasn't | 828 the full path to the desired object, or raises PathNotFound if it wasn't |
| (...skipping 1191 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 2019 return False | 2020 return False |
| 2020 # Matches e.g. "cl_x86 = path/to/clang-cl.exe" | 2021 # Matches e.g. "cl_x86 = path/to/clang-cl.exe" |
| 2021 clang_cl_re = re.compile( | 2022 clang_cl_re = re.compile( |
| 2022 r'^cl_x\d\d\s+\=\s+(?P<compiler_path>[^ ]+)\s.*$', | 2023 r'^cl_x\d\d\s+\=\s+(?P<compiler_path>[^ ]+)\s.*$', |
| 2023 re.VERBOSE) | 2024 re.VERBOSE) |
| 2024 for line in open(build_file): | 2025 for line in open(build_file): |
| 2025 m = clang_cl_re.match(line) | 2026 m = clang_cl_re.match(line) |
| 2026 if m: | 2027 if m: |
| 2027 return 'clang' in m.group('compiler_path') | 2028 return 'clang' in m.group('compiler_path') |
| 2028 return False | 2029 return False |
| OLD | NEW |