diff options
author | Daniel Baumann <daniel.baumann@progress-linux.org> | 2024-04-07 19:33:14 +0000 |
---|---|---|
committer | Daniel Baumann <daniel.baumann@progress-linux.org> | 2024-04-07 19:33:14 +0000 |
commit | 36d22d82aa202bb199967e9512281e9a53db42c9 (patch) | |
tree | 105e8c98ddea1c1e4784a60a5a6410fa416be2de /gfx/harfbuzz/src/gen-hb-version.py | |
parent | Initial commit. (diff) | |
download | firefox-esr-36d22d82aa202bb199967e9512281e9a53db42c9.tar.xz firefox-esr-36d22d82aa202bb199967e9512281e9a53db42c9.zip |
Adding upstream version 115.7.0esr.upstream/115.7.0esr
Signed-off-by: Daniel Baumann <daniel.baumann@progress-linux.org>
Diffstat (limited to 'gfx/harfbuzz/src/gen-hb-version.py')
-rwxr-xr-x | gfx/harfbuzz/src/gen-hb-version.py | 40 |
1 files changed, 40 insertions, 0 deletions
diff --git a/gfx/harfbuzz/src/gen-hb-version.py b/gfx/harfbuzz/src/gen-hb-version.py new file mode 100755 index 0000000000..06018edfcf --- /dev/null +++ b/gfx/harfbuzz/src/gen-hb-version.py @@ -0,0 +1,40 @@ +#!/usr/bin/env python3 + +"This tool is intended to be used from meson" + +import os, sys, shutil, re + +if len (sys.argv) < 4: + sys.exit(__doc__) + +version = sys.argv[1] +major, minor, micro = version.split (".") + +OUTPUT = sys.argv[2] +INPUT = sys.argv[3] +CURRENT_SOURCE_DIR = os.path.dirname(INPUT) + +try: + with open (OUTPUT, "r", encoding='utf-8') as old_output: + for line in old_output: + old_version = re.match (r"#define HB_VERSION_STRING \"(\d.\d.\d)\"", line) + if old_version and old_version[1] == version: + sys.exit () +except IOError: + pass + +with open (INPUT, "r", encoding='utf-8') as template: + with open (OUTPUT, "wb") as output: + output.write (template.read () + .replace ("@HB_VERSION_MAJOR@", major) + .replace ("@HB_VERSION_MINOR@", minor) + .replace ("@HB_VERSION_MICRO@", micro) + .replace ("@HB_VERSION@", version) + .encode ()) + +# copy it also to the source tree, but only if it has changed +baseline_filename = os.path.join (CURRENT_SOURCE_DIR, os.path.basename (OUTPUT)) +with open(baseline_filename, "rb") as baseline: + with open(OUTPUT, "rb") as generated: + if baseline.read() != generated.read(): + shutil.copyfile (OUTPUT, baseline_filename) |