Commit 90efe2b9 authored by Masahiro Yamada's avatar Masahiro Yamada
Browse files

gen_compile_commands.py: remove code for '\#' replacement



Since commit 9564a8cf ("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: default avatarMasahiro Yamada <masahiroy@kernel.org>
Reviewed-by: default avatarNathan Chancellor <nathan@kernel.org>
parent e966ad0e
Loading
Loading
Loading
Loading
+4 −4
Original line number Diff line number Diff line
@@ -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))