+++ /dev/null
-#
-# /*************************************************************************
-# * 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/
-# *************************************************************************/
-#
-# Convert SVG-1.1 color data to same RGBA format used in color_names.
-# See svgcolor_names for input format.
-#
-# All colors assumed opaque, so A = 255 in all colors
-BEGIN {
- FS = "[ ,()]*";
-}
-/^[ ]*$/ { next; }
-/^#/ { next; }
-{
- printf ("/svg/%s %s %s %s 255\n", $1, $5, $6, $7);
-}
add_definitions(-DGVC_EXPORTS)
-if(CYGWIN)
- set(AWK_OPTIONS, -v RS="\\r*\\n")
-endif()
-
# Generate colortbl.h from sources
add_custom_command(
OUTPUT svgcolor_lib
- DEPENDS ${CMAKE_CURRENT_SOURCE_DIR}/svgcolor_names
- ${CMAKE_SOURCE_DIR}/awk/svgcolor.awk
- COMMAND ${AWK_EXECUTABLE} ${AWK_OPTIONS} -f
- ${CMAKE_SOURCE_DIR}/awk/svgcolor.awk
+ MAIN_DEPENDENCY ${CMAKE_CURRENT_SOURCE_DIR}/svgcolor_names
+ DEPENDS ${CMAKE_CURRENT_SOURCE_DIR}/make_svgcolor_lib.py
+ COMMAND ${Python3_EXECUTABLE} ${CMAKE_CURRENT_SOURCE_DIR}/make_svgcolor_lib.py
${CMAKE_CURRENT_SOURCE_DIR}/svgcolor_names
- >${CMAKE_CURRENT_BINARY_DIR}/svgcolor_lib
+ ${CMAKE_CURRENT_BINARY_DIR}/svgcolor_lib
COMMENT "generate SVG color library"
)
add_custom_command(
brewer_lib : $(top_srcdir)/lib/common/brewer_colors $(top_srcdir)/awk/brewer.awk
$(AWK) -f $(top_srcdir)/awk/brewer.awk $(top_srcdir)/lib/common/brewer_colors > brewer_lib
-if WITH_CYGWIN
-AWK_OPTIONS=-v RS="\r*\n"
-endif
-
-svgcolor_lib : $(top_srcdir)/lib/common/svgcolor_names $(top_srcdir)/awk/svgcolor.awk
- $(AWK) $(AWK_OPTIONS) -f $(top_srcdir)/awk/svgcolor.awk $(top_srcdir)/lib/common/svgcolor_names > svgcolor_lib
+svgcolor_lib: $(top_srcdir)/lib/common/svgcolor_names \
+ $(top_srcdir)/lib/common/make_svgcolor_lib.py
+ python3 $(top_srcdir)/lib/common/make_svgcolor_lib.py "$<" "$@"
htmllex.o htmllex.lo: htmllex.c htmllex.h htmlparse.h
htmlparse.o htmlparse.lo: htmlparse.c htmlparse.h
htmlparse.c htmlparse.h \
entities.html entities.tcl \
brewer_colors brewer_lib svgcolor_names svgcolor_lib \
- color_names color_lib colortbl.h
+ color_names color_lib colortbl.h \
+ make_svgcolor_lib.py
--- /dev/null
+#!/usr/bin/python3
+
+"""
+svgcolor_names → svgcolor_lib generator
+"""
+
+import argparse
+import re
+import sys
+from typing import List
+
+def main(args: List[str]) -> int:
+ """entry point"""
+
+ # parse command line arguments
+ parser = argparse.ArgumentParser(description=__doc__)
+ parser.add_argument("input", type=argparse.FileType("rt"),
+ help="input SVG data")
+ parser.add_argument("output", type=argparse.FileType("wt"),
+ help="output color table entries")
+ options = parser.parse_args(args[1:])
+
+ for line in options.input:
+
+ # skip comments and empty lines
+ if line.startswith("#") or line.strip() == "":
+ continue
+
+ # split the line into columns
+ items = re.split(r"[ \t,()]+", line)
+ assert len(items) == 8, f"unexpected line {line}"
+
+ # write this as a color table entry
+ options.output.write(f"/svg/{items[0]} {items[4]} {items[5]} {items[6]} 255\n")
+
+ return 0
+
+
+if __name__ == "__main__":
+ sys.exit(main(sys.argv))
</Link>
<PreBuildEvent>
<Command>win_bison -dy -Wno-yacc common\htmlparse.y -o common\htmlparse.c
-awk -f $(SolutionDir)awk\svgcolor.awk common\svgcolor_names > common\svgcolor_lib
+python common\make_svgcolor_lib.py common\svgcolor_names common\svgcolor_lib
awk -f $(SolutionDir)awk\brewer.awk common\brewer_colors > common\brewer_lib
type common\brewer_lib common\svgcolor_lib common\color_names | sort /L C > color_lib
awk -f $(SolutionDir)awk\colortbl.awk color_lib > common\colortbl.h</Command>
</Link>
<PreBuildEvent>
<Command>win_bison -dy -Wno-yacc common\htmlparse.y -o common\htmlparse.c
-awk -f $(SolutionDir)awk\svgcolor.awk common\svgcolor_names > common\svgcolor_lib
+python common\make_svgcolor_lib.py common\svgcolor_names common\svgcolor_lib
awk -f $(SolutionDir)awk\brewer.awk common\brewer_colors > common\brewer_lib
type common\brewer_lib common\svgcolor_lib common\color_names | sort /L C > color_lib
awk -f $(SolutionDir)awk\colortbl.awk color_lib > common\colortbl.h</Command>