Skip to content
This repository was archived by the owner on Nov 8, 2023. It is now read-only.

Commit b41110b

Browse files
Ulises Mendez MartinezTreehugger Robot
authored andcommitted
ANDROID: Reland "gen_compile_commands.py: fix path resolve with symlinks in it"
This reverts commit 2285818. Reason for revert: Re-landing after hacking Kleaf script. Bug: 320449031 Change-Id: I8aa2783b77f13859798cf7b075e3f1656038315e Signed-off-by: Ulises Mendez Martinez <umendez@google.com>
1 parent 4323574 commit b41110b

1 file changed

Lines changed: 3 additions & 3 deletions

File tree

scripts/clang-tools/gen_compile_commands.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -64,7 +64,7 @@ def parse_arguments():
6464
args = parser.parse_args()
6565

6666
return (args.log_level,
67-
os.path.abspath(args.directory),
67+
os.path.realpath(args.directory),
6868
args.output,
6969
args.ar,
7070
args.paths if len(args.paths) > 0 else [args.directory])
@@ -172,8 +172,8 @@ def process_line(root_directory, command_prefix, file_path):
172172
# by Make, so this code replaces the escaped version with '#'.
173173
prefix = command_prefix.replace('\#', '#').replace('$(pound)', '#')
174174

175-
# Use os.path.abspath() to normalize the path resolving '.' and '..' .
176-
abs_path = os.path.abspath(os.path.join(root_directory, file_path))
175+
# Return the canonical path, eliminating any symbolic links encountered in the path.
176+
abs_path = os.path.realpath(os.path.join(root_directory, file_path))
177177
if not os.path.exists(abs_path):
178178
raise ValueError('File %s not found' % abs_path)
179179
return {

0 commit comments

Comments
 (0)