Bug 836208 - Part 2: Make |mach build some/Makefile| start one level up. r=glandium

This commit is contained in:
Nick Alexander 2013-03-05 10:45:43 -08:00
Родитель 52d3dfad77
Коммит e8d7344d2f
2 изменённых файлов: 20 добавлений и 3 удалений

Просмотреть файл

@ -119,6 +119,8 @@ class TestResolveTargetToMake(unittest.TestCase):
def test_top_level(self):
self.assertResolve('package', (None, 'package'))
# Makefile handling shouldn't affect top-level targets.
self.assertResolve('Makefile', (None, 'Makefile'))
def test_regular_file(self):
self.assertResolve('test-dir/with/file', ('test-dir/with', 'file'))
@ -129,6 +131,14 @@ class TestResolveTargetToMake(unittest.TestCase):
self.assertResolve('test-dir/without/with/file', ('test-dir/without/with', 'file'))
self.assertResolve('test-dir/without/with/without/file', ('test-dir/without/with', 'without/file'))
def test_Makefile(self):
self.assertResolve('test-dir/with/Makefile', ('test-dir', 'with/Makefile'))
self.assertResolve('test-dir/with/without/Makefile', ('test-dir/with', 'without/Makefile'))
self.assertResolve('test-dir/with/without/with/Makefile', ('test-dir/with', 'without/with/Makefile'))
self.assertResolve('test-dir/without/Makefile', ('test-dir', 'without/Makefile'))
self.assertResolve('test-dir/without/with/Makefile', ('test-dir', 'without/with/Makefile'))
self.assertResolve('test-dir/without/with/without/Makefile', ('test-dir/without/with', 'without/Makefile'))
if __name__ == '__main__':
main()

Просмотреть файл

@ -162,8 +162,13 @@ def resolve_target_to_make(topobjdir, target):
A directory resolves to the nearest directory at or above
containing a Makefile, and target `None`.
A file resolves to the nearest directory at or above the file
containing a Makefile, and an appropriate target.
A regular (non-Makefile) file resolves to the nearest directory at
or above the file containing a Makefile, and an appropriate
target.
A Makefile resolves to the nearest parent strictly above the
Makefile containing a different Makefile, and an appropriate
target.
'''
if os.path.isabs(target):
print('Absolute paths for make targets are not allowed.')
@ -200,7 +205,9 @@ def resolve_target_to_make(topobjdir, target):
while True:
make_path = os.path.join(topobjdir, reldir, 'Makefile')
if os.path.exists(make_path):
# We append to target every iteration, so the check below
# happens exactly once.
if target != 'Makefile' and os.path.exists(make_path):
return (reldir, target)
target = os.path.join(os.path.basename(reldir), target)