From e6b10645e7470208f5122055489c7a19733e50bc Mon Sep 17 00:00:00 2001 From: Mischa POSLAWSKY Date: Sat, 14 May 2022 15:34:50 +0200 Subject: [PATCH] tools: separate script to convert perl data to json Replace inline code in make rules for consistency and maintainability. --- Makefile | 4 ++-- tools/mkjson | 7 +++++++ 2 files changed, 9 insertions(+), 2 deletions(-) create mode 100755 tools/mkjson 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); -- 2.30.0