| "This tool is intended to be used from meson" |
| import os, sys, shutil, re |
| major, minor, micro = version.split (".") |
| CURRENT_SOURCE_DIR = os.path.dirname(INPUT) |
| with open (OUTPUT, "r") as old_output: |
| old_version = re.match (r"#define HB_VERSION_STRING \"(\d.\d.\d)\"", line) |
| if old_version and old_version[1] == version: |
| 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) |
| shutil.copyfile (OUTPUT, os.path.join (CURRENT_SOURCE_DIR, os.path.basename (OUTPUT))) |