Skip to content

Commit 22317ce

Browse files
committed
Remove enable_swift flag
1 parent b58d05d commit 22317ce

File tree

2 files changed

+3
-11
lines changed

2 files changed

+3
-11
lines changed

refresh.template.py

Lines changed: 1 addition & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -922,19 +922,14 @@ def _get_commands(target: str, flags: str):
922922
Try adding them as flags in your refresh_compile_commands rather than targets.
923923
In a moment, Bazel will likely fail to parse.""")
924924

925-
support_mnemonics = ["Objc", "Cpp"]
926-
if {enable_swift}:
927-
support_mnemonics += ["Swift"]
928-
mnemonics_string = '|'.join(support_mnemonics)
929-
930925
# First, query Bazel's C-family compile actions for that configured target
931926
aquery_args = [
932927
'bazel',
933928
'aquery',
934929
# Aquery docs if you need em: https://docs.bazel.build/versions/master/aquery.html
935930
# Aquery output proto reference: https://github.com/bazelbuild/bazel/blob/master/src/main/protobuf/analysis_v2.proto
936931
# 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.
937-
f"mnemonic('({mnemonics_string})Compile',deps({target}))",
932+
f"mnemonic('(Objc|Cpp|Swift)Compile',deps({target}))",
938933
# 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.
939934
'--output=jsonproto',
940935
# 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.

refresh_compile_commands.bzl

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -63,7 +63,6 @@ def refresh_compile_commands(
6363
targets = None,
6464
exclude_headers = None,
6565
exclude_external_sources = False,
66-
enable_swift = False,
6766
**kwargs): # For the other common attributes. Tags, compatible_with, etc. https://docs.bazel.build/versions/main/be/common-definitions.html#common-attributes.
6867
# Convert the various, acceptable target shorthands into the dictionary format
6968
# In Python, `type(x) == y` is an antipattern, but [Starlark doesn't support inheritance](https://bazel.build/rules/language), so `isinstance` doesn't exist, and this is the correct way to switch on type.
@@ -76,7 +75,7 @@ def refresh_compile_commands(
7675

7776
# Generate runnable python script from template
7877
script_name = name + ".py"
79-
_expand_template(name = script_name, labels_to_flags = targets, exclude_headers = exclude_headers, exclude_external_sources = exclude_external_sources, enable_swift = enable_swift, **kwargs)
78+
_expand_template(name = script_name, labels_to_flags = targets, exclude_headers = exclude_headers, exclude_external_sources = exclude_external_sources, **kwargs)
8079
native.py_binary(name = name, srcs = [script_name], **kwargs)
8180

8281
def _expand_template_impl(ctx):
@@ -91,8 +90,7 @@ def _expand_template_impl(ctx):
9190
" {target_flag_pairs}": "\n".join([" {},".format(pair) for pair in ctx.attr.labels_to_flags.items()]),
9291
" {windows_default_include_paths}": "\n".join([" %r," % path for path in find_cpp_toolchain(ctx).built_in_include_directories]), # find_cpp_toolchain is from https://docs.bazel.build/versions/main/integrating-with-rules-cc.html
9392
"{exclude_headers}": '"' + str(ctx.attr.exclude_headers) + '"',
94-
"{exclude_external_sources}": str(ctx.attr.exclude_external_sources),
95-
"{enable_swift}": str(ctx.attr.enable_swift),
93+
"{exclude_external_sources}": str(ctx.attr.exclude_external_sources)
9694
},
9795
)
9896
return DefaultInfo(files = depset([script]))
@@ -102,7 +100,6 @@ _expand_template = rule(
102100
"labels_to_flags": attr.string_dict(mandatory = True), # string keys instead of label_keyed because Bazel doesn't support parsing wildcard target patterns (..., *, :all) in BUILD attributes.
103101
"exclude_external_sources": attr.bool(default = False),
104102
"exclude_headers": attr.string(values = ["all", "external", ""]), # "" needed only for compatibility with Bazel < 3.6.0
105-
"enable_swift": attr.bool(default = False),
106103
"_script_template": attr.label(allow_single_file = True, default = "refresh.template.py"),
107104
"_cc_toolchain": attr.label(default = "@bazel_tools//tools/cpp:current_cc_toolchain"), # For Windows INCLUDE. If this were eliminated, for example by the resolution of https://github.com/clangd/clangd/issues/123, we'd be able to just use a macro and skylib's expand_template rule: https://github.com/bazelbuild/bazel-skylib/pull/330
108105
},

0 commit comments

Comments
 (0)