You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: refresh.template.py
+74-13Lines changed: 74 additions & 13 deletions
Original file line number
Diff line number
Diff line change
@@ -23,6 +23,7 @@
23
23
importjson
24
24
importos
25
25
importpathlib
26
+
importplatform
26
27
importre
27
28
importshlex
28
29
importsubprocess
@@ -37,19 +38,7 @@
37
38
# Implementation: skip source files we've already seen in _get_files, shortcutting a bunch of slow preprocessor runs in _get_headers and output. We'd need a threadsafe set, or one set per thread, because header finding is already multithreaded for speed (same magnitudespeed win as single-threaded set).
# As an alternative approach, you might consider trying to get the headers by inspecing the Middlemen actions in the aquery output, but I don't see a way to get just the ones actually #included--or an easy way to get the system headers--without invoking the preprocessor's header search logic.
51
-
# For more on this, see https://github.com/hedronvision/bazel-compile-commands-extractor/issues/5#issuecomment-1031148373
# We don't want to compile, but only pre-process and show all the included header files. We don't want to have the preprocessed results written to a file, so we get them printed to `stderr`.
# cl.exe expects `INCLUDE` (and normally `LIB` but that is irrelevant here) to be set so that it can find the system headers. We have no idea what the correct paths are. So in case these variables are not set, we need to infer them somehow. These variables might not be set if the user has a custom `cc_toolchain()` configured with `bazel` and does not rely on having sourced vcvarsall.bat.
87
+
environ=dict(os.environ)
88
+
if"INCLUDE"notinenviron:
89
+
# We assume the base MSVC install based based on the `cl.exe` path in our command.
# As an alternative approach, you might consider trying to get the headers by inspecing the Middlemen actions in the aquery output, but I don't see a way to get just the ones actually #included--or an easy way to get the system headers--without invoking the preprocessor's header search logic.
139
+
# For more on this, see https://github.com/hedronvision/bazel-compile-commands-extractor/issues/5#issuecomment-1031148373
# `bazel` returns paths as "posix" paths with a `/` as the separator. We want to pass the usual `\` as a path separator to `cl.exe`. But we have arguments for `cl.exe` in the form of `/EP`, so when we have arguments beginning with a `/` we should keep that arround. In the extrem we have something like `/Isome/path` where we want `/Isome\path`.
0 commit comments