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
# While we're supporting the WORKSPACE, we need to load rules_python through its WORKSPACE mechanism because the (currently unstable) bzlmod APIs differ just enough that loads would fail if you tried to support both at the same time.
9
+
# But this is how you'd load rules_python from bzlmod:
10
+
# bazel_dep(name = "rules_python", version = "0.27.1")
Copy file name to clipboardExpand all lines: refresh.template.py
+37-63
Original file line number
Diff line number
Diff line change
@@ -11,20 +11,13 @@
11
11
"""
12
12
13
13
14
-
# This file requires python 3.6, which is enforced by check_python_version.template.py
15
-
# 3.6 backwards compatibility required by @zhanyong-wan in https://github.com/hedronvision/bazel-compile-commands-extractor/issues/111.
16
-
# 3.7 backwards compatibility required by @lummax in https://github.com/hedronvision/bazel-compile-commands-extractor/pull/27.
17
-
# ^ Try to contact before upgrading.
18
-
# When adding things could be cleaner if we had a higher minimum version, please add a comment with MIN_PY=3.<v>.
19
-
# Similarly, when upgrading, please search for that MIN_PY= tag.
20
-
21
-
22
14
importconcurrent.futures
23
15
importenum
24
-
importfunctools# MIN_PY=3.9: Replace `functools.lru_cache(maxsize=None)` with `functools.cache`.
16
+
importfunctools
25
17
importitertools
26
18
importjson
27
19
importlocale
20
+
importorjson# orjson is much faster than the standard library's json module (1.9 seconds vs 6.6 seconds for a ~140 MB file). See https://github.com/hedronvision/bazel-compile-commands-extractor/pull/118
28
21
importos
29
22
importpathlib
30
23
importre
@@ -35,7 +28,7 @@
35
28
importtempfile
36
29
importtime
37
30
importtypes
38
-
importtyping# MIN_PY=3.9: Switch e.g. typing.List[str] -> list[str]
cache_last_modified=os.path.getmtime(cache_file_path) # Do before opening just as a basic hedge against concurrent write, even though we won't handle the concurrent delete case perfectly.
# Unless xcode-select has been invoked (like for a beta) we'd expect, e.g., '/Applications/Xcode.app/Contents/Developer' or '/Library/Developer/CommandLineTools'.
718
700
# Traditionally stored in DEVELOPER_DIR environment variable, but not provided by Bazel. See https://github.com/bazelbuild/bazel/issues/12852
"""De-Bazel the command into something clangd can parse.
723
705
724
706
This function has fixes specific to Apple platforms, but you should call it on all platforms. It'll determine whether the fixes should be applied or not.
# Process each action from Bazelisms -> file paths and their clang commands
1089
1069
# Threads instead of processes because most of the execution time is farmed out to subprocesses. No need to sidestep the GIL. Might change after https://github.com/clangd/clangd/issues/123 resolved
1090
-
withconcurrent.futures.ThreadPoolExecutor(
1091
-
max_workers=min(32, (os.cpu_count() or1) +4) # Backport. Default in MIN_PY=3.8. See "using very large resources implicitly on many-core machines" in https://docs.python.org/3/library/concurrent.futures.html#concurrent.futures.ThreadPoolExecutor
log_error(f">>> //external already exists, but it isn't a {'junction'ifis_windowselse'symlink'}. //external is reserved by Bazel and needed for this tool. Please rename or delete your existing //external and rerun. More details in the README if you want them.") # Don't auto delete in case the user has something important there.
1246
1222
sys.exit(1)
1247
1223
1248
1224
# Normalize the path for matching
1249
1225
# First, workaround a gross case where Windows readlink returns extended path, starting with \\?\, causing the match to fail
0 commit comments