|
7 | 7 | import shutil
|
8 | 8 | import subprocess
|
9 | 9 | import sys
|
10 |
| -import tempfile |
11 | 10 | from logging import getLogger
|
12 | 11 | from typing import *
|
13 | 12 |
|
@@ -44,22 +43,17 @@ def _is_gcc(self) -> bool:
|
44 | 43 |
|
45 | 44 | @functools.lru_cache(maxsize=None)
|
46 | 45 | def _cplusplus_list_depending_files(path: pathlib.Path, *, CXX: pathlib.Path, joined_CXXFLAGS: str) -> List[pathlib.Path]:
|
47 |
| - # Using /dev/stdout is acceptable because Library Chcker doesn't work on Windows. |
48 | 46 | is_windows = (platform.uname().system == 'Windows')
|
49 |
| - with tempfile.TemporaryDirectory() as temp_dir: |
50 |
| - temp_file = pathlib.Path(temp_dir) / 'dependencies.txt' |
51 |
| - command = [str(CXX), *shlex.split(joined_CXXFLAGS), '-MD', '-MF', str(temp_file), '-MM', str(path)] |
52 |
| - try: |
53 |
| - subprocess.check_call(command) |
54 |
| - except subprocess.CalledProcessError: |
55 |
| - logger.error("failed to analyze dependencies with %s: %s (hint: Please check #include directives of the file and its dependencies. The paths must exist, must not contain '\\', and must be case-sensitive.)", CXX, str(path)) |
56 |
| - print(f'::warning file={str(path)}::failed to analyze dependencies', file=sys.stderr) |
57 |
| - raise |
58 |
| - with open(temp_file, 'rb') as fp: |
59 |
| - data = fp.read() |
60 |
| - logger.debug('dependencies of %s: %s', str(path), repr(data)) |
61 |
| - makefile_rule = shlex.split(data.decode().strip().replace('\\\n', '').replace('\\\r\n', ''), posix=not is_windows) |
62 |
| - return [pathlib.Path(path).resolve() for path in makefile_rule[1:]] |
| 47 | + command = [str(CXX), *shlex.split(joined_CXXFLAGS), '-MM', str(path)] |
| 48 | + try: |
| 49 | + data = subprocess.check_output(command) |
| 50 | + except subprocess.CalledProcessError: |
| 51 | + logger.error("failed to analyze dependencies with %s: %s (hint: Please check #include directives of the file and its dependencies. The paths must exist, must not contain '\\', and must be case-sensitive.)", CXX, str(path)) |
| 52 | + print(f'::warning file={str(path)}::failed to analyze dependencies', file=sys.stderr) |
| 53 | + raise |
| 54 | + logger.debug('dependencies of %s: %s', str(path), repr(data)) |
| 55 | + makefile_rule = shlex.split(data.decode().strip().replace('\\\n', '').replace('\\\r\n', ''), posix=not is_windows) |
| 56 | + return [pathlib.Path(path).resolve() for path in makefile_rule[1:]] |
63 | 57 |
|
64 | 58 |
|
65 | 59 | @functools.lru_cache(maxsize=None)
|
|
0 commit comments