From b41110b01310dc7bb05bb3111a1cf59df2cfd04b Mon Sep 17 00:00:00 2001 From: Ulises Mendez Martinez Date: Tue, 6 Feb 2024 20:01:40 +0000 Subject: [PATCH] ANDROID: Reland "gen_compile_commands.py: fix path resolve with symlinks in it" This reverts commit 22858186da5ac2bffa67edd862c0a4b1a45941fc. Reason for revert: Re-landing after hacking Kleaf script. Bug: 320449031 Change-Id: I8aa2783b77f13859798cf7b075e3f1656038315e Signed-off-by: Ulises Mendez Martinez --- scripts/clang-tools/gen_compile_commands.py | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/scripts/clang-tools/gen_compile_commands.py b/scripts/clang-tools/gen_compile_commands.py index 180952fb91c1b..5dea4479240bc 100755 --- a/scripts/clang-tools/gen_compile_commands.py +++ b/scripts/clang-tools/gen_compile_commands.py @@ -64,7 +64,7 @@ def parse_arguments(): args = parser.parse_args() return (args.log_level, - os.path.abspath(args.directory), + os.path.realpath(args.directory), args.output, args.ar, args.paths if len(args.paths) > 0 else [args.directory]) @@ -172,8 +172,8 @@ def process_line(root_directory, command_prefix, file_path): # by Make, so this code replaces the escaped version with '#'. prefix = command_prefix.replace('\#', '#').replace('$(pound)', '#') - # Use os.path.abspath() to normalize the path resolving '.' and '..' . - abs_path = os.path.abspath(os.path.join(root_directory, file_path)) + # Return the canonical path, eliminating any symbolic links encountered in the path. + abs_path = os.path.realpath(os.path.join(root_directory, file_path)) if not os.path.exists(abs_path): raise ValueError('File %s not found' % abs_path) return {