gn_helper: find correct directory for //

gn finds // by searching .gn in parent directories.

To support out dir is not 2 directories from root (i.e. out/Default),
search .gn in parent directory for '//' location.

tools/licenses/licenses.py runs 'gn gen' in out/Default/$tmp.
for such case, '//' should be '../../..', or fail to import '//path'

Change-Id: I6e5ccbe93cb5e51704f31d4eb558c03560286865
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/tools/depot_tools/+/6051636
Reviewed-by: Philipp Wollermann <philwo@google.com>
Commit-Queue: Fumitoshi Ukai <ukai@google.com>
Reviewed-by: Takuto Ikuta <tikuta@chromium.org>
This commit is contained in:
Fumitoshi Ukai
2024-11-27 04:20:40 +00:00
committed by LUCI CQ
parent c0796a593a
commit fd5161870a
2 changed files with 16 additions and 1 deletions

View File

@@ -36,6 +36,7 @@ class GnHelperTest(trial_dir.TestCase):
super().tearDown()
def test_lines(self):
write('.gn', '')
out_dir = os.path.join('out', 'dir')
# Make sure nested import directives work. This is based on the
# reclient test.
@@ -52,6 +53,7 @@ class GnHelperTest(trial_dir.TestCase):
])
def test_args(self):
write('.gn', '')
out_dir = os.path.join('out', 'dir')
# Make sure nested import directives work. This is based on the
# reclient test.
@@ -68,6 +70,7 @@ class GnHelperTest(trial_dir.TestCase):
])
def test_args_spaces(self):
write('.gn', '')
out_dir = os.path.join('out', 'dir')
# Make sure nested import directives work. This is based on the
# reclient test.