Brad Bishop | 1a4b7ee | 2018-12-16 17:11:34 -0800 | [diff] [blame^] | 1 | From 57f6b661d7865e8cecd17be36fab68f7f8447998 Mon Sep 17 00:00:00 2001 |
Brad Bishop | 316dfdd | 2018-06-25 12:45:53 -0400 | [diff] [blame] | 2 | From: Rico Tzschichholz <ricotz@ubuntu.com> |
| 3 | Date: Wed, 6 Sep 2017 18:52:55 +0200 |
| 4 | Subject: [PATCH] libvaladoc: Allow disabling the graphviz dependency of |
Brad Bishop | 1a4b7ee | 2018-12-16 17:11:34 -0800 | [diff] [blame^] | 5 | |
Brad Bishop | 316dfdd | 2018-06-25 12:45:53 -0400 | [diff] [blame] | 6 | valadoc |
| 7 | |
| 8 | https://bugzilla.gnome.org/show_bug.cgi?id=787375 |
| 9 | Signed-off-by: Alexander Kanavin <alex.kanavin@gmail.com> |
| 10 | Upstream-Status: Submitted [bugzilla link above] |
Brad Bishop | 1a4b7ee | 2018-12-16 17:11:34 -0800 | [diff] [blame^] | 11 | |
Brad Bishop | 316dfdd | 2018-06-25 12:45:53 -0400 | [diff] [blame] | 12 | --- |
| 13 | configure.ac | 60 +++++++++++++++++++---------------- |
| 14 | libvaladoc/Makefile.am | 25 +++++++++++---- |
| 15 | libvaladoc/html/basicdoclet.vala | 8 +++++ |
| 16 | libvaladoc/html/htmlmarkupwriter.vala | 4 +++ |
| 17 | 4 files changed, 63 insertions(+), 34 deletions(-) |
| 18 | |
| 19 | diff --git a/configure.ac b/configure.ac |
Brad Bishop | 1a4b7ee | 2018-12-16 17:11:34 -0800 | [diff] [blame^] | 20 | index 730c72d..af81986 100644 |
Brad Bishop | 316dfdd | 2018-06-25 12:45:53 -0400 | [diff] [blame] | 21 | --- a/configure.ac |
| 22 | +++ b/configure.ac |
Brad Bishop | 1a4b7ee | 2018-12-16 17:11:34 -0800 | [diff] [blame^] | 23 | @@ -119,34 +119,38 @@ PKG_CHECK_MODULES(GMODULE, gmodule-2.0 >= $GLIB_REQUIRED) |
Brad Bishop | 316dfdd | 2018-06-25 12:45:53 -0400 | [diff] [blame] | 24 | AC_SUBST(GMODULE_CFLAGS) |
| 25 | AC_SUBST(GMODULE_LIBS) |
| 26 | |
| 27 | -PKG_CHECK_MODULES(LIBGVC, libgvc >= $LIBGVC_REQUIRED) |
| 28 | -AC_MSG_CHECKING([for CGRAPH]) |
| 29 | -cgraph_tmp_LIBADD="$LIBADD" |
| 30 | -cgraph_tmp_CFLAGS="$CFLAGS" |
| 31 | -LIBADD="$LIBADD $LIBGVC_LIBS" |
| 32 | -CFLAGS="$CFLAGS $LIBGVC_CFLAGS" |
| 33 | -AC_RUN_IFELSE( |
| 34 | - [AC_LANG_SOURCE([ |
| 35 | - #include <gvc.h> |
| 36 | - |
| 37 | - int main(void) { |
| 38 | - #ifdef WITH_CGRAPH |
| 39 | - return 0; |
| 40 | - #else |
| 41 | - return -1; |
| 42 | - #endif |
| 43 | - } |
| 44 | - ])], [ |
| 45 | - AC_MSG_RESULT([yes]) |
| 46 | - VALAFLAGS="$VALAFLAGS -D WITH_CGRAPH" |
| 47 | - have_cgraph=yes |
| 48 | - ], [ |
| 49 | - AC_MSG_RESULT([no]) |
| 50 | - have_cgraph=no |
| 51 | - ] |
| 52 | -) |
| 53 | -LIBADD="$cgraph_tmp_LIBADD" |
| 54 | -CFLAGS="$cgraph_tmp_CFLAGS" |
| 55 | +AC_ARG_ENABLE(graphviz, AS_HELP_STRING([--disable-graphviz], [Disable graphviz usage for valadoc]), enable_graphviz=$enableval, enable_graphviz=yes) |
| 56 | +if test x$enable_graphviz = xyes; then |
| 57 | + PKG_CHECK_MODULES(LIBGVC, libgvc >= $LIBGVC_REQUIRED) |
| 58 | + AC_MSG_CHECKING([for CGRAPH]) |
| 59 | + VALAFLAGS="$VALAFLAGS -D HAVE_GRAPHVIZ" |
| 60 | + cgraph_tmp_LIBADD="$LIBADD" |
| 61 | + cgraph_tmp_CFLAGS="$CFLAGS" |
| 62 | + LIBADD="$LIBADD $LIBGVC_LIBS" |
| 63 | + CFLAGS="$CFLAGS $LIBGVC_CFLAGS" |
| 64 | + AC_RUN_IFELSE( |
| 65 | + [AC_LANG_SOURCE([ |
| 66 | + #include <gvc.h> |
| 67 | + int main(void) { |
| 68 | + #ifdef WITH_CGRAPH |
| 69 | + return 0; |
| 70 | + #else |
| 71 | + return -1; |
| 72 | + #endif |
| 73 | + } |
| 74 | + ])], [ |
| 75 | + AC_MSG_RESULT([yes]) |
| 76 | + VALAFLAGS="$VALAFLAGS -D WITH_CGRAPH" |
| 77 | + have_cgraph=yes |
| 78 | + ], [ |
| 79 | + AC_MSG_RESULT([no]) |
| 80 | + have_cgraph=no |
| 81 | + ] |
| 82 | + ) |
| 83 | + LIBADD="$cgraph_tmp_LIBADD" |
| 84 | + CFLAGS="$cgraph_tmp_CFLAGS" |
| 85 | +fi |
| 86 | +AM_CONDITIONAL(ENABLE_GRAPHVIZ, test x$enable_graphviz = xyes) |
| 87 | AM_CONDITIONAL(HAVE_CGRAPH, test "$have_cgraph" = "yes") |
| 88 | |
| 89 | AC_PATH_PROG([XSLTPROC], [xsltproc], :) |
| 90 | diff --git a/libvaladoc/Makefile.am b/libvaladoc/Makefile.am |
Brad Bishop | 1a4b7ee | 2018-12-16 17:11:34 -0800 | [diff] [blame^] | 91 | index 384292f..cce50d8 100644 |
Brad Bishop | 316dfdd | 2018-06-25 12:45:53 -0400 | [diff] [blame] | 92 | --- a/libvaladoc/Makefile.am |
| 93 | +++ b/libvaladoc/Makefile.am |
Brad Bishop | 1a4b7ee | 2018-12-16 17:11:34 -0800 | [diff] [blame^] | 94 | @@ -126,10 +126,6 @@ libvaladoc_la_VALASOURCES = \ |
Brad Bishop | 316dfdd | 2018-06-25 12:45:53 -0400 | [diff] [blame] | 95 | content/tablerow.vala \ |
| 96 | content/taglet.vala \ |
| 97 | content/text.vala \ |
| 98 | - charts/chart.vala \ |
| 99 | - charts/chartfactory.vala \ |
| 100 | - charts/hierarchychart.vala \ |
| 101 | - charts/simplechartfactory.vala \ |
| 102 | parser/manyrule.vala \ |
| 103 | parser/oneofrule.vala \ |
| 104 | parser/optionalrule.vala \ |
Brad Bishop | 1a4b7ee | 2018-12-16 17:11:34 -0800 | [diff] [blame^] | 105 | @@ -156,13 +152,24 @@ libvaladoc_la_VALASOURCES = \ |
Brad Bishop | 316dfdd | 2018-06-25 12:45:53 -0400 | [diff] [blame] | 106 | highlighter/codetoken.vala \ |
| 107 | highlighter/highlighter.vala \ |
| 108 | html/basicdoclet.vala \ |
| 109 | - html/htmlchartfactory.vala \ |
| 110 | html/linkhelper.vala \ |
| 111 | html/cssclassresolver.vala \ |
| 112 | html/htmlmarkupwriter.vala \ |
| 113 | html/htmlrenderer.vala \ |
| 114 | $(NULL) |
| 115 | |
| 116 | +if ENABLE_GRAPHVIZ |
| 117 | +libvaladoc_la_VALASOURCES += \ |
| 118 | + charts/chart.vala \ |
| 119 | + charts/chartfactory.vala \ |
| 120 | + charts/hierarchychart.vala \ |
| 121 | + charts/simplechartfactory.vala \ |
| 122 | + html/htmlchartfactory.vala \ |
| 123 | + $(NULL) |
| 124 | + |
| 125 | +LIBGVC_PKG = --vapidir $(top_srcdir)/vapi --pkg libgvc |
| 126 | +endif |
| 127 | + |
| 128 | libvaladoc@PACKAGE_SUFFIX@_la_SOURCES = \ |
| 129 | libvaladoc.vala.stamp \ |
| 130 | $(libvaladoc_la_VALASOURCES:.vala=.c) \ |
Brad Bishop | 1a4b7ee | 2018-12-16 17:11:34 -0800 | [diff] [blame^] | 131 | @@ -182,9 +189,9 @@ libvaladoc.vala.stamp: $(libvaladoc_la_VALASOURCES) |
Brad Bishop | 316dfdd | 2018-06-25 12:45:53 -0400 | [diff] [blame] | 132 | --library valadoc \ |
| 133 | --vapi valadoc@PACKAGE_SUFFIX@.vapi \ |
| 134 | --vapidir $(top_srcdir)/vapi --pkg gmodule-2.0 \ |
| 135 | - --vapidir $(top_srcdir)/vapi --pkg libgvc \ |
| 136 | --vapidir $(top_srcdir)/gee --pkg gee \ |
Brad Bishop | 1a4b7ee | 2018-12-16 17:11:34 -0800 | [diff] [blame^] | 137 | --vapidir $(top_srcdir)/vala --pkg vala \ |
Brad Bishop | 316dfdd | 2018-06-25 12:45:53 -0400 | [diff] [blame] | 138 | + $(LIBGVC_PKG) \ |
| 139 | --pkg config \ |
| 140 | $(filter %.vala %.c,$^) |
| 141 | touch $@ |
Brad Bishop | 1a4b7ee | 2018-12-16 17:11:34 -0800 | [diff] [blame^] | 142 | @@ -211,6 +218,9 @@ nodist_pkgconfig_DATA = valadoc@PACKAGE_SUFFIX@.pc |
Brad Bishop | 316dfdd | 2018-06-25 12:45:53 -0400 | [diff] [blame] | 143 | |
| 144 | valadoc@PACKAGE_SUFFIX@.pc: valadoc.pc |
| 145 | cp $< $@ |
| 146 | +if !ENABLE_GRAPHVIZ |
| 147 | + sed -i "s/libgvc //g" $@ |
| 148 | +endif |
| 149 | |
| 150 | vapidir = $(datadir)/vala/vapi |
| 151 | dist_vapi_DATA = valadoc@PACKAGE_SUFFIX@.vapi |
Brad Bishop | 1a4b7ee | 2018-12-16 17:11:34 -0800 | [diff] [blame^] | 152 | @@ -218,6 +228,9 @@ nodist_vapi_DATA = valadoc@PACKAGE_SUFFIX@.deps |
Brad Bishop | 316dfdd | 2018-06-25 12:45:53 -0400 | [diff] [blame] | 153 | |
| 154 | valadoc@PACKAGE_SUFFIX@.deps: valadoc.deps |
| 155 | cp $< $@ |
| 156 | +if !ENABLE_GRAPHVIZ |
| 157 | + sed -i "s/libgvc//g" $@ |
| 158 | +endif |
| 159 | |
| 160 | EXTRA_DIST = \ |
| 161 | $(libvaladoc_la_VALASOURCES) \ |
| 162 | diff --git a/libvaladoc/html/basicdoclet.vala b/libvaladoc/html/basicdoclet.vala |
Brad Bishop | 1a4b7ee | 2018-12-16 17:11:34 -0800 | [diff] [blame^] | 163 | index 37c731c..e0326ef 100644 |
Brad Bishop | 316dfdd | 2018-06-25 12:45:53 -0400 | [diff] [blame] | 164 | --- a/libvaladoc/html/basicdoclet.vala |
| 165 | +++ b/libvaladoc/html/basicdoclet.vala |
| 166 | @@ -46,7 +46,11 @@ public abstract class Valadoc.Html.BasicDoclet : Api.Visitor, Doclet { |
| 167 | protected HtmlRenderer _renderer; |
| 168 | protected Html.MarkupWriter writer; |
| 169 | protected Html.CssClassResolver cssresolver; |
| 170 | +#if HAVE_GRAPHVIZ |
| 171 | protected Charts.Factory image_factory; |
| 172 | +#else |
| 173 | + protected void* image_factory; |
| 174 | +#endif |
| 175 | protected ErrorReporter reporter; |
| 176 | protected string package_list_link = "../index.html"; |
| 177 | |
| 178 | @@ -120,7 +124,9 @@ public abstract class Valadoc.Html.BasicDoclet : Api.Visitor, Doclet { |
| 179 | this.linker = new LinkHelper (); |
| 180 | |
| 181 | _renderer = new HtmlRenderer (settings, this.linker, this.cssresolver); |
| 182 | +#if HAVE_GRAPHVIZ |
| 183 | this.image_factory = new SimpleChartFactory (settings, linker); |
| 184 | +#endif |
| 185 | } |
| 186 | |
| 187 | |
| 188 | @@ -1025,6 +1031,7 @@ public abstract class Valadoc.Html.BasicDoclet : Api.Visitor, Doclet { |
| 189 | } |
| 190 | |
| 191 | protected void write_image_block (Api.Node element) { |
| 192 | +#if HAVE_GRAPHVIZ |
| 193 | if (element is Class || element is Interface || element is Struct) { |
| 194 | unowned string format = (settings.use_svg_images ? "svg" : "png"); |
| 195 | var chart = new Charts.Hierarchy (image_factory, element); |
| 196 | @@ -1044,6 +1051,7 @@ public abstract class Valadoc.Html.BasicDoclet : Api.Visitor, Doclet { |
| 197 | this.get_img_path_html (element, format)}); |
| 198 | writer.add_usemap (chart); |
| 199 | } |
| 200 | +#endif |
| 201 | } |
| 202 | |
| 203 | public void write_namespace_content (Namespace node, Api.Node? parent) { |
| 204 | diff --git a/libvaladoc/html/htmlmarkupwriter.vala b/libvaladoc/html/htmlmarkupwriter.vala |
Brad Bishop | 1a4b7ee | 2018-12-16 17:11:34 -0800 | [diff] [blame^] | 205 | index 5aa4afd..e79b0b8 100644 |
Brad Bishop | 316dfdd | 2018-06-25 12:45:53 -0400 | [diff] [blame] | 206 | --- a/libvaladoc/html/htmlmarkupwriter.vala |
| 207 | +++ b/libvaladoc/html/htmlmarkupwriter.vala |
Brad Bishop | 1a4b7ee | 2018-12-16 17:11:34 -0800 | [diff] [blame^] | 208 | @@ -51,12 +51,16 @@ public class Valadoc.Html.MarkupWriter : Valadoc.MarkupWriter { |
| 209 | } |
Brad Bishop | 316dfdd | 2018-06-25 12:45:53 -0400 | [diff] [blame] | 210 | } |
| 211 | |
| 212 | +#if HAVE_GRAPHVIZ |
Brad Bishop | 1a4b7ee | 2018-12-16 17:11:34 -0800 | [diff] [blame^] | 213 | public unowned MarkupWriter add_usemap (Charts.Chart chart) { |
Brad Bishop | 316dfdd | 2018-06-25 12:45:53 -0400 | [diff] [blame] | 214 | string? buf = (string?) chart.write_buffer ("cmapx"); |
| 215 | if (buf != null) { |
| 216 | raw_text ("\n"); |
| 217 | raw_text ((!) buf); |
| 218 | } |
| 219 | +#else |
Brad Bishop | 1a4b7ee | 2018-12-16 17:11:34 -0800 | [diff] [blame^] | 220 | + public unowned MarkupWriter add_usemap (void* chart) { |
Brad Bishop | 316dfdd | 2018-06-25 12:45:53 -0400 | [diff] [blame] | 221 | +#endif |
| 222 | |
| 223 | return this; |
| 224 | } |