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
_get_files.extensions_to_language_args= { # Note that clangd fails on the --language or -ObjC or -ObjC++ forms. See https://github.com/clangd/clangd/issues/1173#issuecomment-1226847416
"""De-Bazel the command into something clangd can parse.
699
712
700
713
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.
# 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.)
707
720
# 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.
708
-
compile_args[0] ='clang'
721
+
722
+
# rules_swift add a worker for wrapping if enable --persistent_worker flag (https://bazel.build/remote/persistent)
# We need to remove it (build_bazel_rules_swift/tools/worker/worker)
725
+
whilelen(compile_args) >0and (notcompile_args[0].endswith('clang')) and (notcompile_args[0].endswith('swiftc')):
726
+
compile_args.pop(0)
727
+
728
+
assertlen(compile_args), "Compiler not found in CMD"
729
+
ifcompile_args[0].endswith('swiftc'):
730
+
compile_args[0] ='swiftc'
731
+
else:
732
+
compile_args[0] ='clang'
709
733
710
734
# We have to manually substitute out Bazel's macros so clang can parse the command
711
735
# Code this mirrors is in https://github.com/bazelbuild/bazel/blob/master/tools/osx/crosstool/wrapped_clang.cc
712
736
# Not complete--we're just swapping out the essentials, because there seems to be considerable turnover in the hacks they have in the wrapper.
713
737
compile_args= [argforargincompile_argsifnotarg.startswith('DEBUG_PREFIX_MAP_PWD') orarg=='OSO_PREFIX_MAP_PWD'] # No need for debug prefix maps if compiling in place, not that we're compiling anyway.
738
+
# Remove -Xwrapped-swift introduced by rules_swift
# Aquery docs if you need em: https://docs.bazel.build/versions/master/aquery.html
862
888
# Aquery output proto reference: https://github.com/bazelbuild/bazel/blob/master/src/main/protobuf/analysis_v2.proto
863
889
# One bummer, not described in the docs, is that aquery filters over *all* actions for a given target, rather than just those that would be run by a build to produce a given output. This mostly isn't a problem, but can sometimes surface extra, unnecessary, misconfigured actions. Chris has emailed the authors to discuss and filed an issue so anyone reading this could track it: https://github.com/bazelbuild/bazel/issues/14156.
# We switched to jsonproto instead of proto because of https://github.com/bazelbuild/bazel/issues/13404. We could change back when fixed--reverting most of the commit that added this line and tweaking the build file to depend on the target in that issue. That said, it's kinda nice to be free of the dependency, unless (OPTIMNOTE) jsonproto becomes a performance bottleneck compated to binary protos.
866
892
'--output=jsonproto',
867
893
# We'll disable artifact output for efficiency, since it's large and we don't use them. Small win timewise, but dramatically less json output from aquery.
0 commit comments