]> granicus.if.org Git - graphviz/commitdiff
remove generation of ps.h and commit generated output instead
authorMatthew Fernandez <matthew.fernandez@gmail.com>
Sat, 9 Oct 2021 21:24:03 +0000 (14:24 -0700)
committerMatthew Fernandez <matthew.fernandez@gmail.com>
Sun, 10 Oct 2021 19:16:30 +0000 (12:16 -0700)
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
awk/stringize.awk [deleted file]
plugin/core/CMakeLists.txt
plugin/core/Makefile.am
plugin/core/gvplugin_core.vcxproj
plugin/core/ps.h [new file with mode: 0644]
plugin/core/ps.txt [deleted file]
plugin/lasi/Makefile.am
plugin/lasi/gvrender_lasi.cpp

index c7291a7d2a71d1c026303faee78129aa7cc49fc7..a043d8ec388b4590a41ee880e53b333854171539 100644 (file)
@@ -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 (executable)
index 65ba7d1..0000000
+++ /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"); }
index 0fd75b88a30b8ba84def94532af9c1e98134a26e..6fa4ec130f9ca31a7e95d4a3a3f8d011a56b6fc0 100644 (file)
@@ -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
index 3cad8cc4f4bdb8266f3fb13f43a09a0d4380b619..5c0c7beafab00e1efc93432df86ee1809a68f425 100644 (file)
@@ -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
index 0b37995ea4ccf86c08b6f4bee05b28b19df80f6f..619dc3c5140bd911e34f28029e5fc70b56a41ada 100644 (file)
@@ -69,9 +69,6 @@
       <TargetMachine>MachineX86</TargetMachine>
       <AdditionalDependencies>cgraph.lib;gvc.lib;xdot.lib;%(AdditionalDependencies)</AdditionalDependencies>
     </Link>
-    <PreBuildEvent>
-      <Command>awk -f $(SolutionDir)awk\stringize.awk ps.txt &gt; ps.h</Command>
-    </PreBuildEvent>
   </ItemDefinitionGroup>
   <ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">
     <ClCompile>
@@ -91,9 +88,6 @@
       <TargetMachine>MachineX86</TargetMachine>
       <AdditionalDependencies>cgraph.lib;gvc.lib;xdot.lib;%(AdditionalDependencies)</AdditionalDependencies>
     </Link>
-    <PreBuildEvent>
-      <Command>awk -f $(SolutionDir)awk\stringize.awk ps.txt &gt; ps.h</Command>
-    </PreBuildEvent>
   </ItemDefinitionGroup>
   <ItemGroup>
     <ClInclude Include="ps.h" />
diff --git a/plugin/core/ps.h b/plugin/core/ps.h
new file mode 100644 (file)
index 0000000..048e7c9
--- /dev/null
@@ -0,0 +1,182 @@
+#pragma once
+
+#include <stddef.h>
+
+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 (file)
index de6a639..0000000
+++ /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
index ce615cfba1081d4f7786d65a3813cebdaea29e3b..bf59158f178a587c8ff4b11831af7b8745d71361 100644 (file)
@@ -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
-
index 670847b7236330f568ecb6452367ce42c0d7449c..0534ab7c62c93a04923314d9811ec21e6255d73a 100644 (file)
@@ -22,7 +22,7 @@
 #include <cgraph/agxbuf.h>
 #include <common/const.h>
 #include <common/utils.h>
-#include <ps.h>
+#include "../core/ps.h"
 
 using namespace LASi;
 using namespace std;