From 96136309542ef71101600335147fcd19253a5fde Mon Sep 17 00:00:00 2001 From: Matthew Fernandez Date: Sat, 9 Oct 2021 14:24:03 -0700 Subject: [PATCH] remove generation of ps.h and commit generated output instead The generation of ps.h from ps.txt was trivial and ps.txt was no easier to edit or update than the resulting generated header. Removing it and using a static source instead accelerates all three builds, increases portability and moves towards dropping the dependency on Awk. Related to #2118. --- .gitignore | 2 - awk/stringize.awk | 15 --- plugin/core/CMakeLists.txt | 8 -- plugin/core/Makefile.am | 10 +- plugin/core/gvplugin_core.vcxproj | 6 - plugin/core/ps.h | 182 ++++++++++++++++++++++++++++++ plugin/core/ps.txt | 171 ---------------------------- plugin/lasi/Makefile.am | 13 +-- plugin/lasi/gvrender_lasi.cpp | 2 +- 9 files changed, 185 insertions(+), 224 deletions(-) delete mode 100755 awk/stringize.awk create mode 100644 plugin/core/ps.h delete mode 100644 plugin/core/ps.txt diff --git a/.gitignore b/.gitignore index c7291a7d2..a043d8ec3 100644 --- a/.gitignore +++ b/.gitignore @@ -152,8 +152,6 @@ lib/common/htmlparse.output lib/common/svgcolor_lib lib/expr/exparse.c lib/vpsc/pairingheap/.dirstamp -plugin/core/ps.h -plugin/lasi/ps.h plugin/xlib/vimdot ## Binaries diff --git a/awk/stringize.awk b/awk/stringize.awk deleted file mode 100755 index 65ba7d154..000000000 --- a/awk/stringize.awk +++ /dev/null @@ -1,15 +0,0 @@ -# -# /************************************************************************* -# * Copyright (c) 2011 AT&T Intellectual Property -# * All rights reserved. This program and the accompanying materials -# * are made available under the terms of the Eclipse Public License v1.0 -# * which accompanies this distribution, and is available at -# * http://www.eclipse.org/legal/epl-v10.html -# * -# * Contributors: Details at http://www.graphviz.org/ -# *************************************************************************/ - -BEGIN { s = ARGV[1]; gsub (".*/", "", s); gsub("\\.","_",s); printf("static const char *%s[] = {\n",s); } -/^#/ { print $0; next; } - { gsub("\\\\","&&",$0); printf("\"%s\",\n",$0); } -END { printf("(char*)0 };\n"); } diff --git a/plugin/core/CMakeLists.txt b/plugin/core/CMakeLists.txt index 0fd75b88a..6fa4ec130 100644 --- a/plugin/core/CMakeLists.txt +++ b/plugin/core/CMakeLists.txt @@ -1,11 +1,3 @@ -# Generate ps.h from ps.txt -add_custom_command( - OUTPUT ps.h - DEPENDS ${CMAKE_CURRENT_SOURCE_DIR}/ps.txt - COMMAND ${AWK_EXECUTABLE} -v RS="\\r*\\n" -f ${TOP_SOURCE_DIR}/awk/stringize.awk - ${CMAKE_CURRENT_SOURCE_DIR}/ps.txt > ${CMAKE_CURRENT_BINARY_DIR}/ps.h -) - add_library(gvplugin_core SHARED # Header files ps.h diff --git a/plugin/core/Makefile.am b/plugin/core/Makefile.am index 3cad8cc4f..5c0c7beaf 100644 --- a/plugin/core/Makefile.am +++ b/plugin/core/Makefile.am @@ -31,8 +31,7 @@ libgvplugin_core_C_la_SOURCES = \ gvrender_core_vml.c \ gvrender_core_pov.c \ gvrender_core_pic.c \ - gvloadimage_core.c \ - ps.txt + gvloadimage_core.c libgvplugin_core_la_LDFLAGS = -version-info @GVPLUGIN_VERSION_INFO@ libgvplugin_core_la_SOURCES = $(libgvplugin_core_C_la_SOURCES) @@ -41,11 +40,6 @@ libgvplugin_core_la_LIBADD = $(top_builddir)/lib/gvc/libgvc.la \ $(top_builddir)/lib/cdt/libcdt.la \ $(top_builddir)/lib/xdot/libxdot.la -gvrender_core_ps.o gvrender_core_ps.lo: ps.h - -ps.h : $(srcdir)/ps.txt - $(AWK) -f $(top_srcdir)/awk/stringize.awk $(srcdir)/ps.txt > ps.h - if WITH_WIN32 libgvplugin_core_la_LDFLAGS += -no-undefined libgvplugin_core_la_LIBADD += $(top_builddir)/lib/cgraph/libcgraph.la @@ -56,5 +50,3 @@ libgvplugin_core_la_LDFLAGS += -Wl,-exported_symbol,_gvplugin_core_LTX_library endif EXTRA_DIST = ps.h gvplugin_core.vcxproj* - -DISTCLEANFILES = ps.h diff --git a/plugin/core/gvplugin_core.vcxproj b/plugin/core/gvplugin_core.vcxproj index 0b37995ea..619dc3c51 100644 --- a/plugin/core/gvplugin_core.vcxproj +++ b/plugin/core/gvplugin_core.vcxproj @@ -69,9 +69,6 @@ MachineX86 cgraph.lib;gvc.lib;xdot.lib;%(AdditionalDependencies) - - awk -f $(SolutionDir)awk\stringize.awk ps.txt > ps.h - @@ -91,9 +88,6 @@ MachineX86 cgraph.lib;gvc.lib;xdot.lib;%(AdditionalDependencies) - - awk -f $(SolutionDir)awk\stringize.awk ps.txt > ps.h - diff --git a/plugin/core/ps.h b/plugin/core/ps.h new file mode 100644 index 000000000..048e7c985 --- /dev/null +++ b/plugin/core/ps.h @@ -0,0 +1,182 @@ +#pragma once + +#include + +static const char *ps_txt[] = { + "%%BeginProlog", + "/DotDict 200 dict def", + "DotDict begin", + "", + "/setupLatin1 {", + "mark", + "/EncodingVector 256 array def", + " EncodingVector 0", + "", + "ISOLatin1Encoding 0 255 getinterval putinterval", + "EncodingVector 45 /hyphen put", + "", + "% Set up ISO Latin 1 character encoding", + "/starnetISO {", + " dup dup findfont dup length dict begin", + " { 1 index /FID ne { def }{ pop pop } ifelse", + " } forall", + " /Encoding EncodingVector def", + " currentdict end definefont", + "} def", + "/Times-Roman starnetISO def", + "/Times-Italic starnetISO def", + "/Times-Bold starnetISO def", + "/Times-BoldItalic starnetISO def", + "/Helvetica starnetISO def", + "/Helvetica-Oblique starnetISO def", + "/Helvetica-Bold starnetISO def", + "/Helvetica-BoldOblique starnetISO def", + "/Courier starnetISO def", + "/Courier-Oblique starnetISO def", + "/Courier-Bold starnetISO def", + "/Courier-BoldOblique starnetISO def", + "cleartomark", + "} bind def", + "", + "%%BeginResource: procset graphviz 0 0", + "/coord-font-family /Times-Roman def", + "/default-font-family /Times-Roman def", + "/coordfont coord-font-family findfont 8 scalefont def", + "", + "/InvScaleFactor 1.0 def", + "/set_scale {", + " dup 1 exch div /InvScaleFactor exch def", + " scale", + "} bind def", + "", + "% styles", + "/solid { [] 0 setdash } bind def", + "/dashed { [9 InvScaleFactor mul dup ] 0 setdash } bind def", + "/dotted { [1 InvScaleFactor mul 6 InvScaleFactor mul] 0 setdash } bind " + "def", + "/invis {/fill {newpath} def /stroke {newpath} def /show {pop newpath} " + "def} bind def", + "/bold { 2 setlinewidth } bind def", + "/filled { } bind def", + "/unfilled { } bind def", + "/rounded { } bind def", + "/diagonals { } bind def", + "/tapered { } bind def", + "", + "% hooks for setting color ", + "/nodecolor { sethsbcolor } bind def", + "/edgecolor { sethsbcolor } bind def", + "/graphcolor { sethsbcolor } bind def", + "/nopcolor {pop pop pop} bind def", + "", + "/beginpage { % i j npages", + " /npages exch def", + " /j exch def", + " /i exch def", + " /str 10 string def", + " npages 1 gt {", + " gsave", + " coordfont setfont", + " 0 0 moveto", + " (\\() show i str cvs show (,) show j str cvs show " + "(\\)) show", + " grestore", + " } if", + "} bind def", + "", + "/set_font {", + " findfont exch", + " scalefont setfont", + "} def", + "", + "% draw text fitted to its expected width", + "/alignedtext { % width text", + " /text exch def", + " /width exch def", + " gsave", + " width 0 gt {", + " [] 0 setdash", + " text stringwidth pop width exch sub text length div 0 " + "text ashow", + " } if", + " grestore", + "} def", + "", + "/boxprim { % xcorner ycorner xsize ysize", + " 4 2 roll", + " moveto", + " 2 copy", + " exch 0 rlineto", + " 0 exch rlineto", + " pop neg 0 rlineto", + " closepath", + "} bind def", + "", + "/ellipse_path {", + " /ry exch def", + " /rx exch def", + " /y exch def", + " /x exch def", + " matrix currentmatrix", + " newpath", + " x y translate", + " rx ry scale", + " 0 0 1 0 360 arc", + " setmatrix", + "} bind def", + "", + "/endpage { showpage } bind def", + "/showpage { } def", + "", + "/layercolorseq", + " [ % layer color sequence - darkest to lightest", + " [0 0 0]", + " [.2 .8 .8]", + " [.4 .8 .8]", + " [.6 .8 .8]", + " [.8 .8 .8]", + " ]", + "def", + "", + "/layerlen layercolorseq length def", + "", + "/setlayer {/maxlayer exch def /curlayer exch def", + " layercolorseq curlayer 1 sub layerlen mod get", + " aload pop sethsbcolor", + " /nodecolor {nopcolor} def", + " /edgecolor {nopcolor} def", + " /graphcolor {nopcolor} def", + "} bind def", + "", + "/onlayer { curlayer ne {invis} if } def", + "", + "/onlayers {", + " /myupper exch def", + " /mylower exch def", + " curlayer mylower lt", + " curlayer myupper gt", + " or", + " {invis} if", + "} def", + "", + "/curlayer 0 def", + "", + "%%EndResource", + "%%EndProlog", + "%%BeginSetup", + "14 default-font-family set_font", + "% /arrowlength 10 def", + "% /arrowwidth 5 def", + "", + "% make sure pdfmark is harmless for PS-interpreters other than Distiller", + "/pdfmark where {pop} {userdict /pdfmark /cleartomark load put} ifelse", + "% make '<<' and '>>' safe on PS Level 1 devices", + "/languagelevel where {pop languagelevel}{1} ifelse", + "2 lt {", + " userdict (<<) cvn ([) cvn load put", + " userdict (>>) cvn ([) cvn load put", + "} if", + "", + "%%EndSetup", + NULL, +}; diff --git a/plugin/core/ps.txt b/plugin/core/ps.txt deleted file mode 100644 index de6a639f5..000000000 --- a/plugin/core/ps.txt +++ /dev/null @@ -1,171 +0,0 @@ -%%BeginProlog -/DotDict 200 dict def -DotDict begin - -/setupLatin1 { -mark -/EncodingVector 256 array def - EncodingVector 0 - -ISOLatin1Encoding 0 255 getinterval putinterval -EncodingVector 45 /hyphen put - -% Set up ISO Latin 1 character encoding -/starnetISO { - dup dup findfont dup length dict begin - { 1 index /FID ne { def }{ pop pop } ifelse - } forall - /Encoding EncodingVector def - currentdict end definefont -} def -/Times-Roman starnetISO def -/Times-Italic starnetISO def -/Times-Bold starnetISO def -/Times-BoldItalic starnetISO def -/Helvetica starnetISO def -/Helvetica-Oblique starnetISO def -/Helvetica-Bold starnetISO def -/Helvetica-BoldOblique starnetISO def -/Courier starnetISO def -/Courier-Oblique starnetISO def -/Courier-Bold starnetISO def -/Courier-BoldOblique starnetISO def -cleartomark -} bind def - -%%BeginResource: procset graphviz 0 0 -/coord-font-family /Times-Roman def -/default-font-family /Times-Roman def -/coordfont coord-font-family findfont 8 scalefont def - -/InvScaleFactor 1.0 def -/set_scale { - dup 1 exch div /InvScaleFactor exch def - scale -} bind def - -% styles -/solid { [] 0 setdash } bind def -/dashed { [9 InvScaleFactor mul dup ] 0 setdash } bind def -/dotted { [1 InvScaleFactor mul 6 InvScaleFactor mul] 0 setdash } bind def -/invis {/fill {newpath} def /stroke {newpath} def /show {pop newpath} def} bind def -/bold { 2 setlinewidth } bind def -/filled { } bind def -/unfilled { } bind def -/rounded { } bind def -/diagonals { } bind def -/tapered { } bind def - -% hooks for setting color -/nodecolor { sethsbcolor } bind def -/edgecolor { sethsbcolor } bind def -/graphcolor { sethsbcolor } bind def -/nopcolor {pop pop pop} bind def - -/beginpage { % i j npages - /npages exch def - /j exch def - /i exch def - /str 10 string def - npages 1 gt { - gsave - coordfont setfont - 0 0 moveto - (\() show i str cvs show (,) show j str cvs show (\)) show - grestore - } if -} bind def - -/set_font { - findfont exch - scalefont setfont -} def - -% draw text fitted to its expected width -/alignedtext { % width text - /text exch def - /width exch def - gsave - width 0 gt { - [] 0 setdash - text stringwidth pop width exch sub text length div 0 text ashow - } if - grestore -} def - -/boxprim { % xcorner ycorner xsize ysize - 4 2 roll - moveto - 2 copy - exch 0 rlineto - 0 exch rlineto - pop neg 0 rlineto - closepath -} bind def - -/ellipse_path { - /ry exch def - /rx exch def - /y exch def - /x exch def - matrix currentmatrix - newpath - x y translate - rx ry scale - 0 0 1 0 360 arc - setmatrix -} bind def - -/endpage { showpage } bind def -/showpage { } def - -/layercolorseq - [ % layer color sequence - darkest to lightest - [0 0 0] - [.2 .8 .8] - [.4 .8 .8] - [.6 .8 .8] - [.8 .8 .8] - ] -def - -/layerlen layercolorseq length def - -/setlayer {/maxlayer exch def /curlayer exch def - layercolorseq curlayer 1 sub layerlen mod get - aload pop sethsbcolor - /nodecolor {nopcolor} def - /edgecolor {nopcolor} def - /graphcolor {nopcolor} def -} bind def - -/onlayer { curlayer ne {invis} if } def - -/onlayers { - /myupper exch def - /mylower exch def - curlayer mylower lt - curlayer myupper gt - or - {invis} if -} def - -/curlayer 0 def - -%%EndResource -%%EndProlog -%%BeginSetup -14 default-font-family set_font -% /arrowlength 10 def -% /arrowwidth 5 def - -% make sure pdfmark is harmless for PS-interpreters other than Distiller -/pdfmark where {pop} {userdict /pdfmark /cleartomark load put} ifelse -% make '<<' and '>>' safe on PS Level 1 devices -/languagelevel where {pop languagelevel}{1} ifelse -2 lt { - userdict (<<) cvn ([) cvn load put - userdict (>>) cvn ([) cvn load put -} if - -%%EndSetup diff --git a/plugin/lasi/Makefile.am b/plugin/lasi/Makefile.am index ce615cfba..bf59158f1 100644 --- a/plugin/lasi/Makefile.am +++ b/plugin/lasi/Makefile.am @@ -23,19 +23,13 @@ endif libgvplugin_lasi_C_la_SOURCES = \ gvplugin_lasi.c \ gvrender_lasi.cpp \ - gvloadimage_lasi.c \ - $(top_srcdir)/plugin/core/ps.txt + gvloadimage_lasi.c libgvplugin_lasi_la_LDFLAGS = -version-info @GVPLUGIN_VERSION_INFO@ libgvplugin_lasi_la_SOURCES = $(libgvplugin_lasi_C_la_SOURCES) libgvplugin_lasi_la_LIBADD = \ $(top_builddir)/lib/gvc/libgvc.la @LASI_LIBS@ @PANGOCAIRO_LIBS@ @MATH_LIBS@ -gvrender_lasi.o gvrender_lasi.lo: ps.h - -ps.h : $(top_srcdir)/plugin/core/ps.txt - $(AWK) -f $(top_srcdir)/awk/stringize.awk $(top_srcdir)/plugin/core/ps.txt > ps.h - if WITH_WIN32 libgvplugin_lasi_la_LDFLAGS += -no-undefined endif @@ -43,8 +37,3 @@ endif if WITH_DARWIN9 libgvplugin_lasi_la_LDFLAGS += -Wl,-exported_symbol,_gvplugin_lasi_LTX_library endif - -EXTRA_DIST = ps.h - -DISTCLEANFILES = ps.h - diff --git a/plugin/lasi/gvrender_lasi.cpp b/plugin/lasi/gvrender_lasi.cpp index 670847b72..0534ab7c6 100644 --- a/plugin/lasi/gvrender_lasi.cpp +++ b/plugin/lasi/gvrender_lasi.cpp @@ -22,7 +22,7 @@ #include #include #include -#include +#include "../core/ps.h" using namespace LASi; using namespace std; -- 2.40.0