test cases/unit/35 dist script/replacer.py
raw| 1 | #!/usr/bin/env python3 |
| 2 | |
| 3 | import os |
| 4 | import pathlib |
| 5 | import sys |
| 6 | |
| 7 | if len(sys.argv) < 3: |
| 8 | sys.exit('usage: replacer.py <pattern> <replacement>') |
| 9 | |
| 10 | source_root = pathlib.Path(os.environ['MESON_DIST_ROOT']) |
| 11 | |
| 12 | modfile = source_root / 'prog.c' |
| 13 | |
| 14 | contents = modfile.read_text(encoding='utf-8') |
| 15 | contents = contents.replace(sys.argv[1], sys.argv[2]) |
| 16 | modfile.write_text(contents, encoding='utf-8') |