gen_compile_commands.py: remove code for '\#' replacement
authorMasahiro Yamada <masahiroy@kernel.org>
Wed, 5 Feb 2025 17:18:02 +0000 (02:18 +0900)
committerMasahiro Yamada <masahiroy@kernel.org>
Sat, 15 Mar 2025 12:16:21 +0000 (21:16 +0900)
Since commit 9564a8cf422d ("Kbuild: fix # escaping in .cmd files for
future Make"), '#' in the build command is replaced with $(pound) rather
than '\#'.

Calling .replace(r'\#', '#') is only necessary when this tool is used
to parse .*.cmd files generated by Linux 4.16 or earlier, which is
unlikely to happen.

Signed-off-by: Masahiro Yamada <masahiroy@kernel.org>
Reviewed-by: Nathan Chancellor <nathan@kernel.org>
scripts/clang-tools/gen_compile_commands.py

index e4fb686dfaa9f0ee49fadb43c6e4404fcd5ac8f3..96e6e46ad1a702cb0fad5d524a9a02d222b236ec 100755 (executable)
@@ -167,10 +167,10 @@ def process_line(root_directory, command_prefix, file_path):
             root_directory or file_directory.
     """
     # The .cmd files are intended to be included directly by Make, so they
-    # escape the pound sign '#', either as '\#' or '$(pound)' (depending on the
-    # kernel version). The compile_commands.json file is not interepreted
-    # by Make, so this code replaces the escaped version with '#'.
-    prefix = command_prefix.replace(r'\#', '#').replace('$(pound)', '#')
+    # escape the pound sign '#' as '$(pound)'. The compile_commands.json file
+    # is not interepreted by Make, so this code replaces the escaped version
+    # with '#'.
+    prefix = command_prefix.replace('$(pound)', '#')
 
     # Return the canonical path, eliminating any symbolic links encountered in the path.
     abs_path = os.path.realpath(os.path.join(root_directory, file_path))