summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorRasmus Andersson <rasmus@notion.se>2020-04-04 23:05:03 +0300
committerRasmus Andersson <rasmus@notion.se>2020-04-04 23:05:03 +0300
commitcd4e4bca3af550cda62d27ce0b3c1f5ca4b39974 (patch)
tree6d40643fabc888788337b4ec01b46e65461897b0
parent4519bffb7cd52ce60f4b8e2e7c6ee547c9df78a2 (diff)
downloadinter-cd4e4bca3af550cda62d27ce0b3c1f5ca4b39974.tar.xz
Fixes an issue with missing git hash in version metadata of built fonts. Closes #234
-rw-r--r--Makefile16
-rwxr-xr-xinit.sh6
-rwxr-xr-xmisc/fontbuild2
-rw-r--r--misc/fontbuildlib/info.py35
-rw-r--r--misc/tools/common.py15
5 files changed, 27 insertions, 47 deletions
diff --git a/Makefile b/Makefile
index ee2e1660a..2f3851e96 100644
--- a/Makefile
+++ b/Makefile
@@ -46,9 +46,11 @@ web: all_web
all_const: all_otf all_ttf all_web
all_const_hinted: all_ttf_hinted all_web_hinted
-var: \
+var: var_text var_display
+var_text: \
$(FONTDIR)/var/Inter.var.woff2 \
- $(FONTDIR)/var/Inter.var.otf \
+ $(FONTDIR)/var/Inter.var.otf
+var_display: \
$(FONTDIR)/var/InterDisplay.var.woff2 \
$(FONTDIR)/var/InterDisplay.var.otf
all_var: \
@@ -73,7 +75,7 @@ all_var: \
# all_var_hinted: $(FONTDIR)/var-hinted/Inter.var.otf $(FONTDIR)/var-hinted/Inter.var.woff2
# .PHONY: all_var_hinted
-.PHONY: all_const all_const_hinted var all_var
+.PHONY: all_const all_const_hinted var var_text var_display all_var
export PATH := $(PWD)/build/venv/bin:$(PATH)
@@ -97,23 +99,23 @@ build/%.woff: build/%.ttf
# VF OTF from UFO
-$(FONTDIR)/var/Inter.var.otf: $(all_ufo_masters) version.txt
+$(FONTDIR)/var/Inter.var.otf: $(all_ufo_masters_text) version.txt
misc/fontbuild compile-var -o $@ $(FONTBUILD_FLAGS) build/ufo/Inter.designspace
$(FONTDIR)/var/Inter-V.var.otf: $(FONTDIR)/var/Inter.var.otf
misc/fontbuild rename --family "Inter V" -o $@ $<
-$(FONTDIR)/var/Inter-%.var.otf: build/ufo/Inter-%.designspace $(all_ufo_masters) version.txt
+$(FONTDIR)/var/Inter-%.var.otf: build/ufo/Inter-%.designspace $(all_ufo_masters_text) version.txt
misc/fontbuild compile-var -o $@ $(FONTBUILD_FLAGS) $<
misc/tools/fix-vf-meta.py $@
-$(FONTDIR)/var/InterDisplay.var.otf: $(all_display_ufo_masters) version.txt
+$(FONTDIR)/var/InterDisplay.var.otf: $(all_ufo_masters_display) version.txt
misc/fontbuild compile-var -o $@ $(FONTBUILD_FLAGS) build/ufo/InterDisplay.designspace
$(FONTDIR)/var/InterDisplay-V.var.otf: $(FONTDIR)/var/InterDisplay.var.otf
misc/fontbuild rename --family "Inter Display V" -o $@ $<
-$(FONTDIR)/var/InterDisplay-%.var.otf: build/ufo/InterDisplay-%.designspace $(all_display_ufo_masters) version.txt
+$(FONTDIR)/var/InterDisplay-%.var.otf: build/ufo/InterDisplay-%.designspace $(all_ufo_masters_display) version.txt
misc/fontbuild compile-var -o $@ $(FONTBUILD_FLAGS) $<
misc/tools/fix-vf-meta.py $@
diff --git a/init.sh b/init.sh
index 8ff2821fa..406a5eada 100755
--- a/init.sh
+++ b/init.sh
@@ -454,9 +454,13 @@ else
echo ")" >> "$GEN_MAKE_FILE"
echo -e "\t@touch \"\$@\"" >> "$GEN_MAKE_FILE"
done
- echo -n "all_ufo_masters :=" >> "$GEN_MAKE_FILE"
+ echo -n "all_ufo_masters_text :=" >> "$GEN_MAKE_FILE"
for style in "${master_styles[@]}"; do
echo -n " build/ufo/Inter-${style}.ufo" >> "$GEN_MAKE_FILE"
+ done
+ echo "" >> "$GEN_MAKE_FILE"
+ echo -n "all_ufo_masters_display :=" >> "$GEN_MAKE_FILE"
+ for style in "${master_styles[@]}"; do
echo -n " build/ufo/InterDisplay-${style}.ufo" >> "$GEN_MAKE_FILE"
done
echo "" >> "$GEN_MAKE_FILE"
diff --git a/misc/fontbuild b/misc/fontbuild
index ea9f48f5d..0bc87a599 100755
--- a/misc/fontbuild
+++ b/misc/fontbuild
@@ -21,7 +21,7 @@ from glyphsLib.interpolation import apply_instance_data
from fontbuildlib import FontBuilder
from fontbuildlib.util import mkdirs, loadTTFont
-from fontbuildlib.info import setFontInfo, updateFontVersion
+from fontbuildlib.info import setFontInfo
from fontbuildlib.name import setFamilyName, renameStylesGoogleFonts
log = logging.getLogger(__name__)
diff --git a/misc/fontbuildlib/info.py b/misc/fontbuildlib/info.py
index f135f1585..c4236f600 100644
--- a/misc/fontbuildlib/info.py
+++ b/misc/fontbuildlib/info.py
@@ -1,39 +1,11 @@
import subprocess
import re
+import sys
from datetime import datetime
from common import getGitHash, getVersion
from .util import readTextFile, BASEDIR, pjoin
-_gitHash = None
-def getGitHash():
- global _gitHash
- if _gitHash is None:
- _gitHash = ''
- try:
- _gitHash = subprocess.check_output(
- ['git', '-C', BASEDIR, 'rev-parse', '--short', 'HEAD'],
- stderr=subprocess.STDOUT,
- **_enc_kwargs
- ).strip()
- except:
- try:
- # git rev-parse --short HEAD > githash.txt
- _gitHash = readTextFile(pjoin(BASEDIR, 'githash.txt')).strip()
- except:
- pass
- return _gitHash
-
-
-_version = None
-def getVersion():
- global _version
- if _version is None:
- _version = readTextFile(pjoin(BASEDIR, 'version.txt')).strip()
- return _version
-
-
-
def updateFontVersion(font, dummy, isVF):
if dummy:
version = "1.0"
@@ -41,8 +13,11 @@ def updateFontVersion(font, dummy, isVF):
now = datetime(2016, 1, 1, 0, 0, 0, 0)
else:
version = getVersion()
- buildtag = getGitHash()
+ buildtag, buildtagErrs = getGitHash()
now = datetime.utcnow()
+ if buildtag == "" or len(buildtagErrs) > 0:
+ buildtag = "src"
+ print("warning: getGitHash() failed: %r" % buildtagErrs, file=sys.stderr)
versionMajor, versionMinor = [int(num) for num in version.split(".")]
font.info.version = version
font.info.versionMajor = versionMajor
diff --git a/misc/tools/common.py b/misc/tools/common.py
index 8f25f1989..33114673d 100644
--- a/misc/tools/common.py
+++ b/misc/tools/common.py
@@ -36,23 +36,22 @@ def readTextFile(filename):
_gitHash = None
-def getGitHash():
+_gitHashErrs = []
+def getGitHash(): # returns tuple (hash :string, errors :string[])
global _gitHash
if _gitHash is None:
_gitHash = ''
+ args = ['git', '-C', BASEDIR, 'rev-parse', '--short', 'HEAD']
try:
- _gitHash = subprocess.check_output(
- ['git', '-C', BASEDIR, 'rev-parse', '--short', 'HEAD'],
- stderr=subprocess.STDOUT,
- **_enc_kwargs
- ).strip()
+ _gitHash = subprocess.check_output(args, stderr=subprocess.STDOUT, **_enc_kwargs).strip()
except:
+ _gitHashErrs.append(sys.exc_info()[0])
try:
# git rev-parse --short HEAD > githash.txt
_gitHash = readTextFile(pjoin(BASEDIR, 'githash.txt')).strip()
except:
- pass
- return _gitHash
+ _gitHashErrs.append(sys.exc_info()[0])
+ return (_gitHash, _gitHashErrs)
_version = None