Mercurial > hgrepos > Python2 > PyMuPDF
comparison mupdf-source/thirdparty/harfbuzz/src/gen-hb-version.py @ 2:b50eed0cc0ef upstream
ADD: MuPDF v1.26.7: the MuPDF source as downloaded by a default build of PyMuPDF 1.26.4.
The directory name has changed: no version number in the expanded directory now.
| author | Franz Glasner <fzglas.hg@dom66.de> |
|---|---|
| date | Mon, 15 Sep 2025 11:43:07 +0200 |
| parents | |
| children |
comparison
equal
deleted
inserted
replaced
| 1:1d09e1dec1d9 | 2:b50eed0cc0ef |
|---|---|
| 1 #!/usr/bin/env python3 | |
| 2 | |
| 3 "This tool is intended to be used from meson" | |
| 4 | |
| 5 import os, sys, shutil, re | |
| 6 | |
| 7 if len (sys.argv) < 4: | |
| 8 sys.exit(__doc__) | |
| 9 | |
| 10 version = sys.argv[1] | |
| 11 major, minor, micro = version.split (".") | |
| 12 | |
| 13 OUTPUT = sys.argv[2] | |
| 14 INPUT = sys.argv[3] | |
| 15 CURRENT_SOURCE_DIR = os.path.dirname(INPUT) | |
| 16 | |
| 17 try: | |
| 18 with open (OUTPUT, "r", encoding='utf-8') as old_output: | |
| 19 for line in old_output: | |
| 20 old_version = re.match (r"#define HB_VERSION_STRING \"(\d.\d.\d)\"", line) | |
| 21 if old_version and old_version[1] == version: | |
| 22 sys.exit () | |
| 23 except IOError: | |
| 24 pass | |
| 25 | |
| 26 with open (INPUT, "r", encoding='utf-8') as template: | |
| 27 with open (OUTPUT, "wb") as output: | |
| 28 output.write (template.read () | |
| 29 .replace ("@HB_VERSION_MAJOR@", major) | |
| 30 .replace ("@HB_VERSION_MINOR@", minor) | |
| 31 .replace ("@HB_VERSION_MICRO@", micro) | |
| 32 .replace ("@HB_VERSION@", version) | |
| 33 .encode ()) | |
| 34 | |
| 35 # copy it also to the source tree, but only if it has changed | |
| 36 baseline_filename = os.path.join (CURRENT_SOURCE_DIR, os.path.basename (OUTPUT)) | |
| 37 with open(baseline_filename, "rb") as baseline: | |
| 38 with open(OUTPUT, "rb") as generated: | |
| 39 if baseline.read() != generated.read(): | |
| 40 shutil.copyfile (OUTPUT, baseline_filename) |
