ANDROID: Revert^3 "gen_compile_commands.py: fix path resolve with symlinks in it"

This reverts commit b41110b013.

Reason of revert: the hack in http://r.android.com/2952813
"Kleaf: Hack: Match all combinations for ROOT_DIR"
no longer works with Bazel 7.2.0 rc2 due to
https://github.com/bazelbuild/bazel/pull/22407
"[7.2.0] Preserve paths under hermetic /tmp in the sandbox".
Until we found a better solution, this patch is
reverted to fix code indexing.

Bug: 343803993
Bug: 320449031
Link: https://github.com/bazelbuild/bazel/issues/22600
Change-Id: I3ba9e924d01149e2b3bf2f051d2e56f4d2129d8a
Signed-off-by: Yifan Hong <elsk@google.com>
This commit is contained in:
Yifan Hong
2024-05-31 13:31:03 -07:00
parent 498f0f95fe
commit 8bebc33896

View File

@@ -64,7 +64,7 @@ def parse_arguments():
args = parser.parse_args()
return (args.log_level,
os.path.realpath(args.directory),
os.path.abspath(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(r'\#', '#').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))
# Use os.path.abspath() to normalize the path resolving '.' and '..' .
abs_path = os.path.abspath(os.path.join(root_directory, file_path))
if not os.path.exists(abs_path):
raise ValueError('File %s not found' % abs_path)
return {