Skip to content

Commit 7a0ed6d

Browse files
cpsauerxinzhengzhang
authored andcommitted
Remove xcrun-based clang finding
Not needed, since clangd will just discover the system default one way or another.
1 parent 22317ce commit 7a0ed6d

File tree

1 file changed

+2
-23
lines changed

1 file changed

+2
-23
lines changed

refresh.template.py

Lines changed: 2 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -683,25 +683,6 @@ def _get_apple_DEVELOPER_DIR():
683683
# Traditionally stored in DEVELOPER_DIR environment variable, but not provided by Bazel. See https://github.com/bazelbuild/bazel/issues/12852
684684

685685

686-
@functools.lru_cache(maxsize=None)
687-
def _get_apple_active_clang():
688-
"""Get path to xcode-select'd clang version."""
689-
return subprocess.check_output(
690-
('xcrun', '--find', 'clang'),
691-
encoding=locale.getpreferredencoding()
692-
).rstrip()
693-
# Unless xcode-select has been invoked (like for a beta) we'd expect, e.g., '/Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/clang' or '/Library/Developer/CommandLineTools/usr/bin/clang'.
694-
695-
696-
@functools.lru_cache(maxsize=None)
697-
def _get_apple_active_swiftc():
698-
"""Get path to xcode-select'd swiftc version."""
699-
return subprocess.check_output(
700-
('xcrun', '--find', 'swiftc'),
701-
encoding=locale.getpreferredencoding()
702-
).rstrip()
703-
704-
705686
def _apple_swift_patch(compile_args: typing.List[str]):
706687
"""De-Bazel(rule_swift) the command into something sourcekit-lsp can parse."""
707688

@@ -736,10 +717,8 @@ def _apple_platform_patch(compile_args: typing.List[str], environmentVariables =
736717
# Bazel wraps the compiler as `external/local_config_cc/wrapped_clang` and exports that wrapped compiler in the proto. However, we need a clang call that clangd can introspect. (See notes in "how clangd uses compile_commands.json" in ImplementationReadme.md for more.)
737718
# Removing the wrapper is also important because Bazel's Xcode (but not CommandLineTools) wrapper crashes if you don't specify particular environment variables (replaced below). We'd need the wrapper to be invokable by clangd's --query-driver if we didn't remove the wrapper.
738719
# Bazel wrapps the swiftc as `external/build_bazel_rules_swift/tools/worker/worker swiftc ` and worker has been removed in apple_swift_patch
739-
if compile_args[0].endswith('swiftc'):
740-
compile_args[0] = _get_apple_active_swiftc()
741-
else:
742-
compile_args[0] = _get_apple_active_clang()
720+
if not compile_args[0].endswith('swiftc'):
721+
compile_args[0] = 'clang'
743722

744723
# We have to manually substitute out Bazel's macros so clang can parse the command
745724
# Code this mirrors is in https://github.com/bazelbuild/bazel/blob/master/tools/osx/crosstool/wrapped_clang.cc

0 commit comments

Comments
 (0)