-
Notifications
You must be signed in to change notification settings - Fork 0
/
justfile
103 lines (81 loc) · 2.77 KB
/
justfile
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
FONTS_DIR_ABS := join(justfile_directory(), 'fonts')
BUILD_DIR := join(justfile_directory(), 'build')
PACKAGE_DIR := join(justfile_directory(), 'package')
VENV_DIR := join(justfile_directory(), 'venv')
FONTFORGE_EXE := env_var_or_default('FONTFORGE_EXE', 'fontforge')
_default:
@just --justfile {{ justfile() }} --list
# list all font names
_list *target:
#!/usr/bin/env bash
set -euo pipefail
# just pass target to this recipe and it will either find all fonts or return target
if [[ -z "{{ target }}" ]]; then
for i in {{ FONTS_DIR_ABS }}/*; do
if [[ -d "$i" && -f "$i"/README.md ]]; then
echo "$(basename "$i")"
fi
done
else
echo "{{ target }}"
fi
# create venv if it does not exist
_venv:
#!/usr/bin/env bash
if [[ ! -d "{{ VENV_DIR }}" ]]; then
echo Creating python virtualenv
python3 -m venv "{{ VENV_DIR }}"
# TODO this should probably be a requirements.txt file
# install generator script dependency
source "{{ VENV_DIR }}"/bin/activate
pip install drawsvg
fi
# build assets for fonts, required only when generator.py script was modified
assets *target: _venv
#!/usr/bin/env bash
set -euo pipefail
FONTS="$(just --justfile {{ justfile() }} _list "{{ target }}" | xargs)"
source "{{ VENV_DIR }}"/bin/activate
for i in $FONTS; do
if [[ -f "{{ FONTS_DIR_ABS }}/$i"/generator.py ]]; then
echo "Generating assets for '$i'"
python3 "{{ FONTS_DIR_ABS }}/$i/generator.py"
fi
done
# build the fonts
build *target:
#!/usr/bin/env bash
set -euo pipefail
# clean build dir
mkdir -p "{{ BUILD_DIR }}"
rm -f "{{ BUILD_DIR }}/*"
FONTS="$(just --justfile {{ justfile() }} _list "{{ target }}" | xargs)"
# print fontforge version for log
"{{ FONTFORGE_EXE }}" -quiet -version | head -n 1
# run build module
for i in $FONTS; do
echo "Building font '$i'"
"{{ FONTFORGE_EXE }}" -quiet -lang=py -script "{{ FONTS_DIR_ABS }}/$i/build.py"
done
# package the fonts in zip archives
package *target: (build target)
#!/usr/bin/env bash
set -euo pipefail
# clean build dir
mkdir -p "{{ PACKAGE_DIR }}"
rm -f "{{PACKAGE_DIR }}"/*
FONTS="$(just --justfile {{ justfile() }} _list "{{ target }}" | xargs)"
# move to package build dir
cd "{{ PACKAGE_DIR }}"
if command -v 7za &>/dev/null; then
_7ZIP=7za
else
_7ZIP=7z
fi
# package each font
for i in $FONTS; do
echo "Packaging font $i"
"$_7ZIP" a "Compacity${i^}.zip" "{{ BUILD_DIR }}/Compacity${i^}"* >/dev/null
done
# package all the fonts for the CI
"$_7ZIP" a CompacityFonts.zip "{{ BUILD_DIR }}"/* >/dev/null