| 1 |
subdirfiles = files('subdirfile.txt') |
| 2 |
assert(fs.exists('subdirfile.txt'), 'Subdir file lookup is broken.') |
| 3 |
assert(fs.is_samepath(meson.project_source_root(), '..'), 'is_samepath not detecting same directory') |
| 4 |
assert(fs.is_samepath(meson.project_build_root(), meson.current_build_dir() / '..'), 'is_samepath not detecting same directory') |
| 5 |
|
| 6 |
assert(fs.is_samepath(subdirfiles[0], 'subdirfile.txt'), 'is_samepath not detecting same directory when using File and str') |
| 7 |
|
| 8 |
# More relative_to to test subdir/builddir components |
| 9 |
|
| 10 |
build_to_src = fs.relative_to(meson.current_source_dir(), meson.current_build_dir()) |
| 11 |
src_to_build = fs.relative_to(meson.current_build_dir(), meson.current_source_dir()) |
| 12 |
|
| 13 |
btgt = executable('btgt', 'btgt.c') |
| 14 |
ctgt = fs.copyfile('subdirfile.txt') |
| 15 |
|
| 16 |
if build_machine.system() == 'windows' |
| 17 |
# Test that CustomTarget works |
| 18 |
assert(fs.relative_to('subdirfile.txt', ctgt) == '..\\@0@\\subdirfile.txt'.format(build_to_src)) |
| 19 |
assert(fs.relative_to(ctgt, 'subdirfile.txt') == '..\\@0@\\subdirfile.txt'.format(src_to_build)) |
| 20 |
# Test that CustomTargetIndex works |
| 21 |
assert(fs.relative_to('subdirfile.txt', ctgt[0]) == '..\\@0@\\subdirfile.txt'.format(build_to_src)) |
| 22 |
assert(fs.relative_to(ctgt[0], 'subdirfile.txt') == '..\\@0@\\subdirfile.txt'.format(src_to_build)) |
| 23 |
# Test that BuildTarget works |
| 24 |
assert(fs.relative_to('subdirfile.txt', btgt) == '..\\@0@\\subdirfile.txt'.format(build_to_src)) |
| 25 |
assert(fs.relative_to(btgt, 'subdirfile.txt') == '..\\@0@\\@1@'.format(src_to_build, fs.name(btgt.full_path()))) |
| 26 |
else |
| 27 |
# Test that CustomTarget works |
| 28 |
assert(fs.relative_to('subdirfile.txt', ctgt) == '../@0@/subdirfile.txt'.format(build_to_src)) |
| 29 |
assert(fs.relative_to(ctgt, 'subdirfile.txt') == '../@0@/subdirfile.txt'.format(src_to_build)) |
| 30 |
# Test that CustomTargetIndex works |
| 31 |
assert(fs.relative_to('subdirfile.txt', ctgt[0]) == '../@0@/subdirfile.txt'.format(build_to_src)) |
| 32 |
assert(fs.relative_to(ctgt[0], 'subdirfile.txt') == '../@0@/subdirfile.txt'.format(src_to_build)) |
| 33 |
# Test that BuildTarget works |
| 34 |
assert(fs.relative_to('subdirfile.txt', btgt) == '../@0@/subdirfile.txt'.format(build_to_src)) |
| 35 |
assert(fs.relative_to(btgt, 'subdirfile.txt') == '../@0@/@1@'.format(src_to_build, fs.name(btgt.full_path()))) |
| 36 |
endif |