Under Ubuntu 20.04, whose inkscape is version 0.92.5, conversion of
cpu/SimpleWrite.svg --> .pdf fails with a crashing message from inkscape,
"Error 134".
Ubuntu 20.04's rsvg-convert accepts the SVG and generates a good-looking
PDF from it.
Although using such an old rsvg-convert might end up in a poor looking
PDF, it is much better than ending up in a fatal build error.
Add fallback commands to run rsvg-convert in case of such crashes.
Add the same fallback to modern version of inkscape. This can mitigate
potential instability of inkscape run as a CLI tool, similar to the one
commit f307e19f2be0 ("Prevent inkscape from interacting with desktop
manager") had worked around.
Rather than cluttering the recipe with additional ifdef's, define a
macro SVG_TO_PDF_COMMAND beforehand and use it in the recipe.
Signed-off-by: Akira Yokosawa <[email protected]>
---
I have no idea what's wrong in SimpleWrite.svg against the old inkscape
at the moment.
---
Makefile | 24 ++++++++++++++----------
1 file changed, 14 insertions(+), 10 deletions(-)
diff --git a/Makefile b/Makefile
index 762df051..337f34aa 100644
--- a/Makefile
+++ b/Makefile
@@ -498,6 +498,19 @@ endif
sh plot.sh && \
cd ../../..
+ifdef RSVG_CONVERT
+ FALLBACK_RSVG_CONVERT = || (cat $<i | rsvg-convert $(RSVG_FMT_OPT) > $@ &&
echo "$< --> $(suffix $@) (fallback rsvg-convert)")
+endif
+ifeq ($(RSVG_CONVERT_GOOD),1)
+ SVG_TO_PDF_COMMAND = cat $<i | rsvg-convert $(RSVG_FMT_OPT) > $@
+else
+ ifeq ($(INKSCAPE_ONE),0)
+ SVG_TO_PDF_COMMAND = inkscape --export-pdf=$@ $<i > /dev/null 2>&1
$(FALLBACK_RSVG_CONVERT)
+ else
+ SVG_TO_PDF_COMMAND = $(ISOLATE_INKSCAPE) inkscape -o $@ $<i > /dev/null
2>&1 $(FALLBACK_RSVG_CONVERT)
+ endif
+endif
+
$(PDFTARGETS_OF_SVG): $(FIXSVGFONTS)
$(PDFTARGETS_OF_SVG): %.pdf: %.svg
@echo "$< --> $(suffix $@) $(SVG_PDF_CONVERTER)"
@@ -529,16 +542,7 @@ endif
ifeq ($(RECOMMEND_LIBERATIONMONO),1)
$(info Nice-to-have font family 'Liberation Mono' not found. See #9 in
FAQ-BUILD.txt)
endif
-
-ifeq ($(RSVG_CONVERT_GOOD),1)
- @cat $<i | rsvg-convert $(RSVG_FMT_OPT) > $@
-else
- ifeq ($(INKSCAPE_ONE),0)
- @inkscape --export-pdf=$@ $<i > /dev/null 2>&1
- else
- @$(ISOLATE_INKSCAPE) inkscape -o $@ $<i > /dev/null 2>&1
- endif
-endif
+ @$(SVG_TO_PDF_COMMAND)
@rm -f $<i
ifeq ($(chkpagegroup),on)
ifndef QPDF
--
2.43.0