* [PATCH] gen_compile_commands.py: remove code for '\#' replacement
@ 2025-02-05 17:18 Masahiro Yamada
2025-02-07 21:34 ` Nathan Chancellor
0 siblings, 1 reply; 2+ messages in thread
From: Masahiro Yamada @ 2025-02-05 17:18 UTC (permalink / raw)
To: linux-kbuild
Cc: linux-kernel, Masahiro Yamada, Bill Wendling, Justin Stitt,
Nathan Chancellor, Nick Desaulniers, Nicolas Schier, llvm
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 happen.
Signed-off-by: Masahiro Yamada <masahiroy@kernel.org>
---
scripts/clang-tools/gen_compile_commands.py | 8 ++++----
1 file changed, 4 insertions(+), 4 deletions(-)
diff --git a/scripts/clang-tools/gen_compile_commands.py b/scripts/clang-tools/gen_compile_commands.py
index e4fb686dfaa9..96e6e46ad1a7 100755
--- a/scripts/clang-tools/gen_compile_commands.py
+++ b/scripts/clang-tools/gen_compile_commands.py
@@ -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))
--
2.43.0
^ permalink raw reply related [flat|nested] 2+ messages in thread* Re: [PATCH] gen_compile_commands.py: remove code for '\#' replacement
2025-02-05 17:18 [PATCH] gen_compile_commands.py: remove code for '\#' replacement Masahiro Yamada
@ 2025-02-07 21:34 ` Nathan Chancellor
0 siblings, 0 replies; 2+ messages in thread
From: Nathan Chancellor @ 2025-02-07 21:34 UTC (permalink / raw)
To: Masahiro Yamada
Cc: linux-kbuild, linux-kernel, Bill Wendling, Justin Stitt,
Nick Desaulniers, Nicolas Schier, llvm
On Thu, Feb 06, 2025 at 02:18:02AM +0900, Masahiro Yamada wrote:
> 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 happen.
>
> Signed-off-by: Masahiro Yamada <masahiroy@kernel.org>
Reviewed-by: Nathan Chancellor <nathan@kernel.org>
> ---
>
> scripts/clang-tools/gen_compile_commands.py | 8 ++++----
> 1 file changed, 4 insertions(+), 4 deletions(-)
>
> diff --git a/scripts/clang-tools/gen_compile_commands.py b/scripts/clang-tools/gen_compile_commands.py
> index e4fb686dfaa9..96e6e46ad1a7 100755
> --- a/scripts/clang-tools/gen_compile_commands.py
> +++ b/scripts/clang-tools/gen_compile_commands.py
> @@ -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))
> --
> 2.43.0
>
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2025-02-07 21:34 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2025-02-05 17:18 [PATCH] gen_compile_commands.py: remove code for '\#' replacement Masahiro Yamada
2025-02-07 21:34 ` Nathan Chancellor
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox