meson: avoid regenerating hb-version.h unnecessarily
The file is a dependency for the library as a whole, so previously editing the Meson build files at all would force a full rebuild. This will only rebuild it if the version has changed.
This commit is contained in:
parent
ea4476d738
commit
769a21aab6
|
@ -2,7 +2,7 @@
|
||||||
|
|
||||||
"This tool is intended to be used from meson"
|
"This tool is intended to be used from meson"
|
||||||
|
|
||||||
import os, sys, shutil
|
import os, sys, shutil, re
|
||||||
|
|
||||||
if len (sys.argv) < 4:
|
if len (sys.argv) < 4:
|
||||||
sys.exit(__doc__)
|
sys.exit(__doc__)
|
||||||
|
@ -14,6 +14,15 @@ OUTPUT = sys.argv[2]
|
||||||
INPUT = sys.argv[3]
|
INPUT = sys.argv[3]
|
||||||
CURRENT_SOURCE_DIR = os.path.dirname(INPUT)
|
CURRENT_SOURCE_DIR = os.path.dirname(INPUT)
|
||||||
|
|
||||||
|
try:
|
||||||
|
with open (OUTPUT, "r") 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 (INPUT, "r", encoding='utf-8') as template:
|
||||||
with open (OUTPUT, "wb") as output:
|
with open (OUTPUT, "wb") as output:
|
||||||
output.write (template.read ()
|
output.write (template.read ()
|
||||||
|
|
Loading…
Reference in New Issue