3 "This tool is intended to be used from meson"
5 import os, sys, shutil, re
11 major, minor, micro = version.split (".")
15 CURRENT_SOURCE_DIR = os.path.dirname(INPUT)
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:
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)
35 # copy it also to src/
36 shutil.copyfile (OUTPUT, os.path.join (CURRENT_SOURCE_DIR, os.path.basename (OUTPUT)))