| 1 |
|
| 2 |
|
| 3 |
> |
| 4 |
|
| 5 |
|
| 6 |
|
| 7 |
|
| 8 |
|
| 9 |
|
| 10 |
|
| 11 |
|
| 12 |
|
| 13 |
|
| 14 |
|
| 15 |
|
| 16 |
|
| 17 |
|
| 18 |
|
| 19 |
|
| 20 |
import os |
| 21 |
import subprocess |
| 22 |
import shutil |
| 23 |
import tempfile |
| 24 |
import sys |
| 25 |
|
| 26 |
if __name__ == "__main__": |
| 27 |
dist_root = os.environ['MESON_DIST_ROOT'] |
| 28 |
build_root = os.environ['MESON_BUILD_ROOT'] |
| 29 |
source_root = os.environ['MESON_SOURCE_ROOT'] |
| 30 |
project_version = sys.argv[1] |
| 31 |
pwd = os.environ['PWD'] |
| 32 |
tmpdir = tempfile.gettempdir() |
| 33 |
|
| 34 |
module = os.path.basename(os.path.normpath(source_root)) |
| 35 |
|
| 36 |
|
| 37 |
print('Generating pot file ...') |
| 38 |
subprocess.run(['ninja', '-C', build_root, module + '-1.0-pot'], check=True) |
| 39 |
|
| 40 |
pot_src = os.path.join(source_root, 'po', module + '-1.0.pot') |
| 41 |
|
| 42 |
|
| 43 |
|
| 44 |
with open(pot_src, 'r') as f: |
| 45 |
pot_file = f.read() |
| 46 |
|
| 47 |
pot_file = pot_file.replace(f'Project-Id-Version: {module}-1.0', |
| 48 |
f'Project-Id-Version: {module}-{project_version}', 1) |
| 49 |
|
| 50 |
print('Copying pot file into dist staging directory ...') |
| 51 |
dist_pot_with_suffix = os.path.join(dist_root, 'po', f'{module}-1.0.pot') |
| 52 |
with open(dist_pot_with_suffix, 'w') as f: |
| 53 |
f.write(pot_file) |
| 54 |
|
| 55 |
|
| 56 |
dist_pot_without_suffix = os.path.join(dist_root, 'po', f'{module}.pot') |
| 57 |
with open(dist_pot_without_suffix, 'w') as f: |
| 58 |
f.write(pot_file) |