bc1c93fbe0
The input file is by definition in the source directory, so dirname() that instead of needing the directory to be passed. Needed because a follow-up commit will change when this is called, and the source directory isn't trivially available at that point.
28 lines
703 B
Python
Executable File
28 lines
703 B
Python
Executable File
#!/usr/bin/env python3
|
|
|
|
"This tool is intended to be used from meson"
|
|
|
|
import os, sys, shutil
|
|
|
|
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)
|
|
|
|
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 src/
|
|
shutil.copyfile (OUTPUT, os.path.join (CURRENT_SOURCE_DIR, os.path.basename (OUTPUT)))
|