From: Mischa POSLAWSKY Date: Sat, 14 May 2022 13:34:50 +0000 (+0200) Subject: tools: separate script to convert perl data to json X-Git-Url: http://git.shiar.net/sheet.git/commitdiff_plain/e6b10645e7470208f5122055489c7a19733e50bc tools: separate script to convert perl data to json Replace inline code in make rules for consistency and maintainability. --- diff --git a/Makefile b/Makefile index 942727c..806e5be 100644 --- a/Makefile +++ b/Makefile @@ -86,9 +86,9 @@ data/wordlist.version.txt: force data/wordlist.%.inc.pl: tools/mkwordlist data/wordlist.version.txt $(call cmdsave,$< $*) data/word%.json: data/word%.inc.pl - $(call cmdsave,perl -MJSON=encode_json -E "print encode_json(do \$$ARGV[0])" ./$<) + $(call cmdsave,tools/mkjson $<) data/%.json: %.inc.pl - $(call cmdsave,perl -MJSON -E "print JSON->new->utf8->canonical->encode(do \$$ARGV[0])" ./$<) + $(call cmdsave,tools/mkjson $<) data/wordpairs.inc.pl: data/wordlist.version.txt tools/wordpairs >$@ diff --git a/tools/mkjson b/tools/mkjson new file mode 100755 index 0000000..6a7d948 --- /dev/null +++ b/tools/mkjson @@ -0,0 +1,7 @@ +#!/usr/bin/env perl +use 5.012; +use warnings; +use JSON; + +my $data = do "./$ARGV[0]" or die $@; +print JSON->new->utf8->canonical->encode($data);