use Makefile to use make -j all

This commit is contained in:
Denis Knauf 2024-08-23 19:02:34 +02:00
parent 3252093a0e
commit 1b77b1af54
3 changed files with 90 additions and 38 deletions

35
Makefile Normal file
View file

@ -0,0 +1,35 @@
FONTARTS := $(sort \
$(patsubst %.otf,%,\
$(patsubst %.woff,%,\
$(patsubst %.woff2,%,\
$(wildcard *.woff2 *.woff *.otf)\
))))
OTFS := $(patsubst %,%.otf,$(FONTARTS))
WOFFS := $(patsubst %,%.woff,$(FONTARTS))
WOFF2S := $(patsubst %,%.woff2,$(FONTARTS))
FONTS := $(OTFS) $(WOFFS) $(WOFF2S)
CACHES := $(patsubst %,%.fc,$(FONTS))
all: fonts caches
.PHONY: all
fonts: $(FONTS)
.PHONY: all
caches: $(CACHES)
.PHONY: all
%.woff: %.otf
sfnt2woff-zopfli "$<"
%.woff2: %.otf
woff2_compress "$<"
%.otf.fc: %.otf fc.format
> "$@" LANG=C LC_NUMERIC=C fc-scan --format "$$(cat fc.format)" "$<"
%.woff.fc: %.woff fc.format
> "$@" LANG=C LC_NUMERIC=C fc-scan --format "$$(cat fc.format)" "$<"
%.woff2.fc: %.woff.fc
cp "$<" "$@"

9
fc.format Normal file
View file

@ -0,0 +1,9 @@
family=%{family}
fullname=%{fullname}
postscriptname=%{postscriptname}
variable=%{variable}
slant=%{slant}
style=%{style}
weight=%{weight}
width=%{width}

View file

@ -3,6 +3,7 @@
({src ? null , srcs ? null, name ? "", pname ? "", version ? ""}:
with pkgs;
let
escapeShellArg = lib.strings.escapeShellArg;
name_ =
if "" != name
then name
@ -25,52 +26,59 @@
;;
esac
done
>"Makefile" echo ${escapeShellArg (builtins.readFile ./Makefile)}
>"fc.format" echo ${escapeShellArg (builtins.readFile ./fc.format)}
'';
buildPhase = ''
set -e
build_dir="$TMPDIR/build"
mkdir "$build_dir"
find "$source_dir" \( -name \*.otf -or -name \*.ttf -or -name \*.woff -or -name \*.woff2 \) -exec cp \{\} "$build_dir" \;
find "$source_dir" \( -name Makefile -or -name fc.format -or -name \*.otf -or -name \*.ttf -or -name \*.woff -or -name \*.woff2 \) -exec cp \{\} "$build_dir" \;
cd "$build_dir"
for s in *.otf *.ttf
for f in *.ttf
do
bn="''${s%.otf}"
bn="''${bn%.ttf}"
if ! [ -e "$bn.woff" ]
then
echo "sfnt2woff-zopfli $s => $bn.woff"
sfnt2woff-zopfli "$s"
fi
if ! [ -e "$bn.woff2" ]
then
echo "woff2_compress $s => $bn.woff2"
woff2_compress "$s"
fi
[ -f "''${f%.ttf}.otf" ] || mv "$f" "''${f%.ttf}.otf"
done
for s in *.otf *.ttf *.woff
do
fc="`dirname "$s"`/`basename "$s"`.fc"
echo "fc-scan $s"
LANG=C LC_NUMERIC=C fc-scan --format 'family=%{family}
fullname=%{fullname}
postscriptname=%{postscriptname}
variable=%{variable}
slant=%{slant}
style=%{style}
weight=%{weight}
width=%{width}
' "$s" > "$fc"
done
for s in *.woff2
do
o="`dirname "$s"`/`basename "$s" .woff2`.woff.fc"
fc="`dirname "$s"`/`basename "$s"`.fc"
cp "$o" "$fc"
done
'';
make -j all
'';
# for s in *.otf *.ttf
# do
# bn="''${s%.otf}"
# bn="''${bn%.ttf}"
# if ! [ -e "$bn.woff" ]
# then
# echo "sfnt2woff-zopfli $s => $bn.woff"
# sfnt2woff-zopfli "$s"
# fi
# if ! [ -e "$bn.woff2" ]
# then
# echo "woff2_compress $s => $bn.woff2"
# woff2_compress "$s"
# fi
# done
#
# for s in *.otf *.ttf *.woff
# do
# fc="`dirname "$s"`/`basename "$s"`.fc"
# echo "fc-scan $s"
# LANG=C LC_NUMERIC=C fc-scan --format 'family=%{family}
#fullname=%{fullname}
#postscriptname=%{postscriptname}
#variable=%{variable}
#slant=%{slant}
#style=%{style}
#weight=%{weight}
#width=%{width}
#
#' "$s" > "$fc"
# done
# for s in *.woff2
# do
# o="`dirname "$s"`/`basename "$s" .woff2`.woff.fc"
# fc="`dirname "$s"`/`basename "$s"`.fc"
# cp "$o" "$fc"
# done
# '';
installPhase = ''
cd "$TMPDIR"
mkdir -p $out/share/{doc/${name_},fonts/{opentype,truetype,WOFF,WOFF2}{,/.fc}}