]> granicus.if.org Git - graphviz/commitdiff
For static and dynamic programs, builtins are now found
authorellson <devnull@localhost>
Sat, 30 Jul 2005 17:10:16 +0000 (17:10 +0000)
committerellson <devnull@localhost>
Sat, 30 Jul 2005 17:10:16 +0000 (17:10 +0000)
by scanning the symbol table of the program itsel.  This means that
making a plugin library into a builtin just requires adding it
to the list of libraries at link time.

This doesn't quite work yet when dot is itself a plugin (tcldot and
the script language bindings) so they still need a builtins.c

13 files changed:
cmd/dot/Makefile.am
cmd/tools/Makefile.am
cmd/tools/plugins.c [deleted file]
lib/gvc/Makefile.am
lib/gvc/builtins.c [deleted file]
lib/gvc/gvc.c
lib/gvc/gvconfig.c
lib/gvc/gvplugin.c
lib/gvc/gvplugin.h
tclpkg/gv/Makefile.am
tclpkg/gv/builtins.c [new file with mode: 0644]
tclpkg/tcldot/Makefile.am
tclpkg/tcldot/builtins.c [new file with mode: 0644]

index b1f5efbdc04c95c5e801af888a30fa20f61fdee3..1e0c46895cccf1d17c668055620aaba2b8c8e341 100644 (file)
@@ -21,7 +21,8 @@ endif
 man_MANS = dot.1 
 pdf_DATA = dot.pdf
 
-dot_SOURCES = dot.c $(top_srcdir)/lib/gvc/builtins.c
+dot_SOURCES = dot.c
+dot_LDFLAGS = -export-dynamic -dlpreopen self -export-symbols-regex '.*_LTX_library'
 dot_LDADD = \
        $(top_builddir)/lib/plugin/libgvplugin_dot_layout.la \
        $(top_builddir)/lib/plugin/libgvplugin_neato_layout.la \
@@ -57,6 +58,8 @@ dot_static_DEPENDENCIES = \
        $(top_builddir)/lib/graph/.libs/libgraph.a \
        $(top_builddir)/lib/cdt/.libs/libcdt.a \
        $(top_builddir)/lib/gd/.libs/libgvgd.a
+dot_static_LDFLAGS = -export-dynamic -dlpreopen self -export-symbols-regex '.*_LTX_library'
+
 dot_static_LDADD = \
        $(top_builddir)/lib/plugin/.libs/libgvplugin_dot_layout.a \
        $(top_builddir)/lib/plugin/.libs/libgvplugin_neato_layout.a \
@@ -67,7 +70,7 @@ dot_static_LDADD = \
        $(top_builddir)/lib/graph/.libs/libgraph.a \
        $(top_builddir)/lib/cdt/.libs/libcdt.a \
        $(top_builddir)/lib/gd/.libs/libgvgd.a \
-       @GD_LIBS@ @EXPAT_LIBS@ @Z_LIBS@ @LIBGEN_LIBS@ @LIBLTDL@ @SOCKET_LIBS@
+       @ICONV_LIBS@ @FC_LIBS@ @FT_LIBS@ @JPEG_LIBS@ @PNG_LIBS@ @MATH_LIBS@ @EXPAT_LIBS@ @Z_LIBS@ @LIBGEN_LIBS@ @LIBLTDL@ @SOCKET_LIBS@
 
 EXTRA_DIST = Makefile.old dot.1 dot.pdf 
 
index e064d12f32d2860d2396a2b01b02f06f3741e4d2..5707e9b7892fc78c46219daa96a50d00297f41e0 100644 (file)
@@ -95,7 +95,9 @@ gc_LDADD = \
        $(top_builddir)/lib/ingraphs/libingraphs.la \
        $(top_builddir)/lib/graph/libgraph.la
 
-gvpack_SOURCES = gvpack.c plugins.c
+gvpack_SOURCES = gvpack.c
+
+gvpack_LDFLAGS = -export-dynamic -dlpreopen self -export-symbols-regex '.*_LTX_library'
 
 gvpack_LDADD = \
        $(top_builddir)/lib/common/libcommon.la \
diff --git a/cmd/tools/plugins.c b/cmd/tools/plugins.c
deleted file mode 100644 (file)
index 582bd42..0000000
+++ /dev/null
@@ -1,26 +0,0 @@
-/* $Id$ $Revision$ */
-/* vim:set shiftwidth=4 ts=8: */
-
-/**********************************************************
-*      This software is part of the graphviz package      *
-*                http://www.graphviz.org/                 *
-*                                                         *
-*            Copyright (c) 1994-2004 AT&T Corp.           *
-*                and is licensed under the                *
-*            Common Public License, Version 1.0           *
-*                      by AT&T Corp.                      *
-*                                                         *
-*        Information and Software Systems Research        *
-*              AT&T Research, Florham Park NJ             *
-**********************************************************/
-
-#include        <stdio.h>
-
-#include        "config.h"
-#include        "types.h"
-#include        "macros.h"
-#include        "gvc.h"
-gvplugin_library_t *builtins[] = {
-    NULL
-};
-
index 9411836da09e58a1a7bf52dbd54468e4959d7186..abf17e88f17b5df4e849ce7d0c20c49c761ead0a 100644 (file)
@@ -28,4 +28,4 @@ libgvc_la_LIBADD = \
        $(top_builddir)/lib/pathplan/libpathplan.la \
        @GD_LIBS@ @EXPAT_LIBS@ @Z_LIBS@ @LIBGEN_LIBS@
 
-EXTRA_DIST = Makefile.old builtins.c
+EXTRA_DIST = Makefile.old
diff --git a/lib/gvc/builtins.c b/lib/gvc/builtins.c
deleted file mode 100644 (file)
index dcc3066..0000000
+++ /dev/null
@@ -1,30 +0,0 @@
-/* $Id$ $Revision$ */
-/* vim:set shiftwidth=4 ts=8: */
-
-/**********************************************************
-*      This software is part of the graphviz package      *
-*                http://www.graphviz.org/                 *
-*                                                         *
-*            Copyright (c) 1994-2004 AT&T Corp.           *
-*                and is licensed under the                *
-*            Common Public License, Version 1.0           *
-*                      by AT&T Corp.                      *
-*                                                         *
-*        Information and Software Systems Research        *
-*              AT&T Research, Florham Park NJ             *
-**********************************************************/
-
-#include        "gvplugin.h"
-
-extern gvplugin_library_t
-    gvplugin_dot_layout_LTX_library,
-    gvplugin_neato_layout_LTX_library,
-    gvplugin_usershape_gd_LTX_library;
-
-gvplugin_library_t *builtins[] = {
-    &gvplugin_dot_layout_LTX_library,
-    &gvplugin_neato_layout_LTX_library,
-    &gvplugin_usershape_gd_LTX_library,
-    NULL
-};
-
index c06d424f7a55a0fec290ac803bc9f8c91f8cf6cc..94aa0cf3a9dadd0842a2f99abbabf093cae5998a 100644 (file)
@@ -16,7 +16,7 @@
 
 #include "gvc.h"
 
-char *Info[] = {
+char *LibInfo[] = {
     "libgvc",          /* Program */
     VERSION,           /* Version */
     BUILDDATE          /* Build Date */
@@ -28,7 +28,7 @@ GVC_t *gvContext(void)
 
     aginit();
     agnodeattr(NULL, "label", NODENAME_ESC);
-    gvc = gvNEWcontext(Info, username());
+    gvc = gvNEWcontext(LibInfo, username());
     gvconfig(gvc, FALSE); /* configure for available plugins and codegens */
     return gvc;
 }
index bfa84f14a46885c09043c4265531fc4842314b72..95ca0615be25969196c55ed0955c984386a5f206 100644 (file)
@@ -200,6 +200,32 @@ static void gvconfig_plugin_install_from_library(GVC_t * gvc, char *path, gvplug
     }
 }
 
+struct lt_symlist
+{
+    const char *name;
+    void* address;
+};
+
+extern const struct lt_symlist lt_preloaded_symbols[];
+
+static void gvconfig_plugin_install_builtins(GVC_t * gvc)
+{
+    const struct lt_symlist *s;
+    const char *name;
+
+    s = lt_preloaded_symbols;
+    while ((name = s->name)) {
+fprintf(stderr,"%s\n",name);
+       if (name[0] == 'g'
+        && name[1] == 'v'
+        && name[2] == 'p'
+        && strstr(name, "_LTX_library")) {
+           gvconfig_plugin_install_from_library(gvc, NULL, (gvplugin_library_t *)(s->address));
+       }
+       s++;
+    }
+}
+
 #ifndef DISABLE_LTDL
 static void gvconfig_write_library_config(char *path, gvplugin_library_t *library, FILE *f)
 {
@@ -253,8 +279,6 @@ char * gvconfig_libdir(void)
 }
 #endif
 
-extern gvplugin_library_t *builtins[];
-
 #ifndef DISABLE_LTDL
 static void config_rescan(GVC_t *gvc, char *config_path)
 {
@@ -431,7 +455,9 @@ codegen_info_t *next_codegen(codegen_info_t * p)
  */
 void gvconfig(GVC_t * gvc, boolean rescan)
 {
+#if 0
     gvplugin_library_t **libraryp;
+#endif
 #ifndef DISABLE_LTDL
     int sz, rc;
     struct stat config_st, libdir_st;
@@ -451,10 +477,9 @@ void gvconfig(GVC_t * gvc, boolean rescan)
                         "cg", NULL, (gvplugin_installed_t *) p);
 #endif
 
-    for (libraryp = builtins; *libraryp; libraryp++) {
-       gvconfig_plugin_install_from_library(gvc, NULL, *libraryp);
-    }
 #ifndef DISABLE_LTDL
+    gvconfig_plugin_install_builtins(gvc);
+   
     /* see if there are any new plugins */
     libdir = gvconfig_libdir();
     rc = stat(libdir, &libdir_st);
index 93e2b159f4ee5763a6a425b2cec5c2319173415e..c508d5c7f1168e91c33efedaacd6b52d96438e9f 100644 (file)
@@ -134,7 +134,7 @@ gvplugin_library_t *gvplugin_library_load(char *path)
     }
     hndl = lt_dlopen (p);
     if (!hndl) {
-        agerr(AGWARN, "failed to dlopen %s\n", p);
+        agerr(AGWARN, lt_dlerror());
         return NULL;
     }
 
index a9e0886b497b58694401aff681a1c16759f7b2c8..e75e181a56437c66e72857f0f677bc4439a513d6 100644 (file)
@@ -27,7 +27,6 @@ extern "C" {
 #define NULL (void *)0
 #endif
 
-
 /* 
  * Terminology:
  *
@@ -75,6 +74,8 @@ extern "C" {
        gvplugin_api_t *apis;
     } gvplugin_library_t;
 
+    extern gvplugin_library_t *builtins[];
+
 #ifdef __cplusplus
 }
 #endif
index 51fecaacd7141c23eada76a772cd1640e3447d84..b8aa928b885c428d854763b99b78ad12e7903e21 100644 (file)
@@ -10,7 +10,7 @@ AM_CPPFLAGS = \
 
 LIBS =  @LIBS@ -lc
 
-BASESOURCES = gv.cpp $(top_srcdir)/lib/gvc/builtins.c
+BASESOURCES = gv.cpp builtins.c
 BASELIBS = \
        $(top_builddir)/lib/plugin/libgvplugin_dot_layout.la \
        $(top_builddir)/lib/plugin/libgvplugin_neato_layout.la \
diff --git a/tclpkg/gv/builtins.c b/tclpkg/gv/builtins.c
new file mode 100644 (file)
index 0000000..a97ee53
--- /dev/null
@@ -0,0 +1,47 @@
+/* $Id$ $Revision$ */
+/* vim:set shiftwidth=4 ts=8: */
+
+/**********************************************************
+*      This software is part of the graphviz package      *
+*                http://www.graphviz.org/                 *
+*                                                         *
+*            Copyright (c) 1994-2004 AT&T Corp.           *
+*                and is licensed under the                *
+*            Common Public License, Version 1.0           *
+*                      by AT&T Corp.                      *
+*                                                         *
+*        Information and Software Systems Research        *
+*              AT&T Research, Florham Park NJ             *
+**********************************************************/
+
+#include "gvplugin.h"
+
+struct lt_symlist
+{
+    const char *name;
+    void* address;
+};
+
+#if 0
+const char *gvplugin_dot_layout_name = "gvplugin_dot_layout_LTX_library";
+const char *gvplugin_neato_layout_name = "gvplugin_neato_layout_LTX_library";
+const char *gvplugin_usershape_gd_name = "gvplugin_usershape_gd_LTX_library";
+
+extern gvplugin_library_t *gvplugin_dot_layout_LTX_library;
+extern gvplugin_library_t *gvplugin_neato_layout_LTX_library;
+extern gvplugin_library_t *gvplugin_usershape_gd_LTX_library;
+
+const struct lt_symlist lt_preloaded_symbols[] = {
+    {  gvplugin_dot_layout_name,
+       (void*)gvplugin_dot_layout_LTX_library },
+    {  gvplugin_neato_layout_name, 
+       (void*)gvplugin_neato_layout_LTX_library },
+    {  gvplugin_usershape_gd_name, 
+       (void*)gvplugin_usershape_gd_LTX_library },
+    {  0,
+       0 }
+};
+#else
+const struct lt_symlist lt_preloaded_symbols[] = {{0,0,},};
+#endif
+
index 407aeaec24d26d309c5e322123e42f56472f2fd5..f1db7fa03eabed674bf8023b7cd6157cbc8cb009 100644 (file)
@@ -30,16 +30,15 @@ pdf_DATA = $(pdf)
 html_DATA = $(html)
 endif
 
-libtcldot_la_SOURCES = tcldot.c tkgen.c \
-       $(top_srcdir)/tclpkg/gdtclft/gdtclft.c \
-       $(top_srcdir)/lib/gvc/builtins.c
+libtcldot_la_SOURCES = tcldot.c tkgen.c builtins.c \
+       $(top_srcdir)/tclpkg/gdtclft/gdtclft.c
 libtcldot_la_LIBADD = \
        $(top_builddir)/tclpkg/tclhandle/libtclhandle.la \
        $(top_builddir)/tclpkg/tclstubs/libtclstubs.la \
         $(top_builddir)/lib/plugin/libgvplugin_dot_layout.la \
         $(top_builddir)/lib/plugin/libgvplugin_neato_layout.la \
         $(top_builddir)/lib/plugin/libgvplugin_usershape_gd.la \
-       $(top_builddir)/lib/gvc/libgvc.la
+       $(top_builddir)/lib/gvc/libgvc.la @LIBGEN_LIBS@ @LIBLTDL@
 
 if WITH_TCL
 all-local: pkgIndex.tcl
diff --git a/tclpkg/tcldot/builtins.c b/tclpkg/tcldot/builtins.c
new file mode 100644 (file)
index 0000000..a97ee53
--- /dev/null
@@ -0,0 +1,47 @@
+/* $Id$ $Revision$ */
+/* vim:set shiftwidth=4 ts=8: */
+
+/**********************************************************
+*      This software is part of the graphviz package      *
+*                http://www.graphviz.org/                 *
+*                                                         *
+*            Copyright (c) 1994-2004 AT&T Corp.           *
+*                and is licensed under the                *
+*            Common Public License, Version 1.0           *
+*                      by AT&T Corp.                      *
+*                                                         *
+*        Information and Software Systems Research        *
+*              AT&T Research, Florham Park NJ             *
+**********************************************************/
+
+#include "gvplugin.h"
+
+struct lt_symlist
+{
+    const char *name;
+    void* address;
+};
+
+#if 0
+const char *gvplugin_dot_layout_name = "gvplugin_dot_layout_LTX_library";
+const char *gvplugin_neato_layout_name = "gvplugin_neato_layout_LTX_library";
+const char *gvplugin_usershape_gd_name = "gvplugin_usershape_gd_LTX_library";
+
+extern gvplugin_library_t *gvplugin_dot_layout_LTX_library;
+extern gvplugin_library_t *gvplugin_neato_layout_LTX_library;
+extern gvplugin_library_t *gvplugin_usershape_gd_LTX_library;
+
+const struct lt_symlist lt_preloaded_symbols[] = {
+    {  gvplugin_dot_layout_name,
+       (void*)gvplugin_dot_layout_LTX_library },
+    {  gvplugin_neato_layout_name, 
+       (void*)gvplugin_neato_layout_LTX_library },
+    {  gvplugin_usershape_gd_name, 
+       (void*)gvplugin_usershape_gd_LTX_library },
+    {  0,
+       0 }
+};
+#else
+const struct lt_symlist lt_preloaded_symbols[] = {{0,0,},};
+#endif
+