| 1 |
#!/usr/bin/env python3 |
| 2 |
|
| 3 |
import os, sys |
| 4 |
from pathlib import Path |
| 5 |
|
| 6 |
assert 'MESON_SOURCE_ROOT' in os.environ |
| 7 |
assert 'MESON_BUILD_ROOT' in os.environ |
| 8 |
assert 'MESON_SUBDIR' in os.environ |
| 9 |
assert 'MESONINTROSPECT' in os.environ |
| 10 |
assert 'MY_ENV' in os.environ |
| 11 |
|
| 12 |
# Environment has absolute paths and argv has relative paths when using ninja |
| 13 |
# backend and absolute paths when using vs backend. What matters is once |
| 14 |
# resolved they point to same location. |
| 15 |
env_source_root = Path(os.environ['MESON_SOURCE_ROOT']).resolve() |
| 16 |
env_build_root = Path(os.environ['MESON_BUILD_ROOT']).resolve() |
| 17 |
env_current_source_dir = Path(env_source_root, os.environ['MESON_SUBDIR']).resolve() |
| 18 |
|
| 19 |
print(sys.argv) |
| 20 |
argv_paths = [Path(i).resolve() for i in sys.argv[1:]] |
| 21 |
source_root, build_root, current_source_dir = argv_paths |
| 22 |
|
| 23 |
print(f'{source_root} == {env_source_root}') |
| 24 |
assert source_root == env_source_root |
| 25 |
print(f'{build_root} == {env_build_root}') |
| 26 |
assert build_root == env_build_root |
| 27 |
print(f'{current_source_dir} == {env_current_source_dir}') |
| 28 |
assert current_source_dir == env_current_source_dir |