mirror of
https://chromium.googlesource.com/chromium/tools/depot_tools.git
synced 2026-01-11 10:41:31 +00:00
gn_helper: handle absolute path import
Bug: 393209409 Change-Id: Ic26b4502ab1744c7af7c0b06de2e4d1b9f2d3980 Reviewed-on: https://chromium-review.googlesource.com/c/chromium/tools/depot_tools/+/6217699 Commit-Queue: Fumitoshi Ukai <ukai@google.com> Reviewed-by: Takuto Ikuta <tikuta@chromium.org> Reviewed-by: Philipp Wollermann <philwo@google.com> Auto-Submit: Fumitoshi Ukai <ukai@google.com> Reviewed-by: Dirk Pranke <dpranke@google.com>
This commit is contained in:
18
gn_helper.py
18
gn_helper.py
@@ -34,7 +34,25 @@ def _gn_lines(output_dir, path):
|
||||
import_path = os.path.normpath(
|
||||
os.path.join(_find_root(output_dir),
|
||||
raw_import_path[2:]))
|
||||
elif raw_import_path.startswith('/'):
|
||||
# GN uses "/"-prefix as absolute path,
|
||||
# https://gn.googlesource.com/gn/+/main/docs/reference.md#labels
|
||||
# e.g.
|
||||
# /usr/local/foo:bar
|
||||
# /C:/Program Files/MyLibs:bar
|
||||
# but Win32's absolute path doesn't have "/"-prefix.
|
||||
if sys.platform.startswith('win32'):
|
||||
import_path = raw_import_path[1:]
|
||||
else:
|
||||
import_path = raw_import_path
|
||||
if not os.path.isabs(import_path):
|
||||
raise Exception('Wrong absolute path for import %s' %
|
||||
raw_import_path)
|
||||
else:
|
||||
if os.path.isabs(raw_import_path):
|
||||
raise Execption(
|
||||
'Absolute path "%s" should start with "/" in GN' %
|
||||
raw_import_path)
|
||||
import_path = os.path.normpath(
|
||||
os.path.join(os.path.dirname(path), raw_import_path))
|
||||
yield from _gn_lines(output_dir, import_path)
|
||||
|
||||
Reference in New Issue
Block a user