From dac489a6fd2af9bf93550e57d1b44a906abf372c Mon Sep 17 00:00:00 2001 From: Snorlax Date: Sat, 3 Dec 2022 20:20:16 +0800 Subject: [PATCH] https://github.com/hedronvision/bazel-compile-commands-extractor/pull/89#discussion_r1037776844 refresh.template.py: using endwith api --- refresh.template.py | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/refresh.template.py b/refresh.template.py index 0185053..abd28a6 100644 --- a/refresh.template.py +++ b/refresh.template.py @@ -735,8 +735,7 @@ def _apple_platform_patch(compile_args: typing.List[str], environmentVariables = # 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.) # 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. # Bazel wrapps the swiftc as `external/build_bazel_rules_swift/tools/worker/worker swiftc ` and worker has been removed in apple_swift_patch - - if compile_args[0][-6:] == "swiftc": + if compile_args[0].endswith('swiftc'): compile_args[0] = _get_apple_active_swiftc() else: compile_args[0] = _get_apple_active_clang() @@ -817,7 +816,7 @@ def _get_swift_command_for_files(compile_action): compile_action.arguments = _apple_platform_patch(compile_action.arguments, compile_action.environmentVariables) # Source files is end with `.swift` - source_files = set(filter(lambda x: x[-6:] == ".swift", compile_action.arguments)) + source_files = set(filter(lambda arg: arg.endswith('.swift'), compile_action.arguments)) for source_file in source_files: _warn_if_file_doesnt_exist(source_file)