chiark / gitweb /
wip library generation
authorIan Jackson <ijackson@chiark.greenend.org.uk>
Sun, 13 Sep 2020 22:46:50 +0000 (23:46 +0100)
committerIan Jackson <ijackson@chiark.greenend.org.uk>
Sun, 13 Sep 2020 22:47:03 +0000 (23:47 +0100)
Signed-off-by: Ian Jackson <ijackson@chiark.greenend.org.uk>
Makefile
library/wikimedia.toml
usvg-processor [new file with mode: 0755]

index fd74ab40a646104e780846840d7c2648c95e1c79..befb0926ea9683935fd952b9d750e719ecb5217d 100644 (file)
--- a/Makefile
+++ b/Makefile
@@ -8,11 +8,11 @@
 
 SHELL=/bin/bash
 
-default: debug
+default: debug libraries
 
 CARGO ?= cargo
 CARGO_TARGET_DIR ?= target
-USVG ?= USVG
+USVG ?= usvg
 
 ifneq (,$(wildcard(../Cargo.nail)))
 NAILING_CARGO = nailing-cargo
@@ -23,7 +23,7 @@ BUNDLE_SOURCES_DIR = ../bundle-sources
 BUNDLE_SOURCES = ../Build/bundle-sources/target/debug/bundle-rust-sources
 
 USVG_BINARY = ../resvg/target/release/usvg
-USVG = $(NAILING_CARGO) -- $(USVG)
+USVG = $(NAILING_CARGO) --- $(USVG_BINARY)
 # To build usvg
 # zealot:resvg$ nailing-cargo build -p usvg --release
 
@@ -34,6 +34,12 @@ $(BUNDLE_SOURCES):
 endif
 endif
 
+include $(wildcard library/*/files.make)
+
+LIBRARY_PROCESS_SVG = ./usvg-processor $@ $^ '$(USVG)'
+
+libraries: $(LIBRARY_FILES)
+
 debug release:: %: $(CARGO_TARGET_DIR)/%/server templates/script.js extra-%
        @echo Built $@.
 .PHONY: $(CARGO_TARGET_DIR)/debug/server
index cb17ecda7f78fe4d0773193868338d0ac34a027f..d09b80b88d2a82480c1fad71ae949bf94d869740 100644 (file)
@@ -18,7 +18,7 @@ data_url_hashprefix = true
 outline.Circle = { }
 size = [45]
 scale = 0.20
-shift = [22.5, 22.5]
+centre = [22.5, 22.5]
 category = "chess"
 stem_prefix = "Chess_"
 files = """
diff --git a/usvg-processor b/usvg-processor
new file mode 100755 (executable)
index 0000000..51e8284
--- /dev/null
@@ -0,0 +1,25 @@
+#!/usr/bin/perl -w
+
+use strict;
+
+die unless @ARGV == 4;
+our ($out, $in, $lic, $usvg) = @ARGV;
+
+open STDOUT, '>', "$out.tmp" or die $!;
+open L, '<', $lic or die $!;
+open STDIN, "<", $in or die $!;
+
+sub add_lic () {
+  while (<L>) {
+    next unless m{^\s*SPDX-License-Identifier:\s+(\S.*?)\s*$};
+    print "<!-- $out $1, see $lic-->\n" or die $!;
+    return;
+  }
+  die "no spdx in $lic ?";
+}
+
+add_lic();
+
+flush STDOUT or die $!;
+$!=0; $?=0; system qw(sh -ec), "exec $usvg -c -" and die "exec usvg: $? $!";
+rename "$out.tmp", $out or die $!;