From e066e92388dfc41459aaf10e450049789fb4e1f2 Mon Sep 17 00:00:00 2001 From: ellson Date: Wed, 27 Jul 2005 20:37:01 +0000 Subject: [PATCH] add -c argument to dot and friends to explicity generate the config file do "dot -c" on installation, don't rely on timestamps --- cmd/dot/Makefile.am | 4 ++-- graphviz.spec.in | 8 ++++---- lib/common/args.c | 31 +++++++++++++++++++++++++++++++ lib/common/globals.h | 2 +- lib/common/input.c | 11 ++++++++++- lib/gvc/gvc.c | 2 +- lib/gvc/gvconfig.c | 16 +++++++--------- lib/gvc/gvcproc.h | 2 +- tclpkg/gv/gv.cpp | 2 +- tclpkg/tcldot/tcldot.c | 2 +- 10 files changed, 59 insertions(+), 21 deletions(-) diff --git a/cmd/dot/Makefile.am b/cmd/dot/Makefile.am index bf9a7e104..de09e2100 100644 --- a/cmd/dot/Makefile.am +++ b/cmd/dot/Makefile.am @@ -25,10 +25,10 @@ install-data-hook: (cd $(DESTDIR)$(pdfdir); for i in $(linkedpdf); do rm -f $$i; $(LN_S) dot.pdf $$i; done;) # create "neato", "fdp" etc as soflinks to "dot" -# run dot once, if possible, to create plugin config +# run "dot -c", if possible, to create plugin config install-exec-hook: (cd $(DESTDIR)$(bindir); for i in $(linkedprogram); do rm -f $$i; $(LN_S) dot $$i; done;) - if test "x$(DESTDIR)" = "x"; then (cd $(bindir); ./dot -V 2>/dev/null;); fi + if test "x$(DESTDIR)" = "x"; then (cd $(bindir); ./dot -c;); fi uninstall-hook: (cd $(DESTDIR)$(man1dir); for i in $(linkedman); do rm -f $$i; done;) diff --git a/graphviz.spec.in b/graphviz.spec.in index fd81da8b1..05ecc659b 100644 --- a/graphviz.spec.in +++ b/graphviz.spec.in @@ -152,15 +152,15 @@ rm -rf $RPM_BUILD_ROOT %defattr(-,root,root,-) %doc __doc/* -# run "dot -V" to generate plugin config in %{_libdir}/%{name}/config +# run "dot -c" to generate plugin config in %{_libdir}/%{name}/config %post -%{_bindir}/dot -V 2>/dev/null +%{_bindir}/dot -c %post tcl -%{_bindir}/dot -V 2>/dev/null +%{_bindir}/dot -c %post devel -%{_bindir}/dot -V 2>/dev/null +%{_bindir}/dot -c %changelog * Wed Jul 20 2005 John Ellson diff --git a/lib/common/args.c b/lib/common/args.c index 23ed8ae2b..f844668d0 100644 --- a/lib/common/args.c +++ b/lib/common/args.c @@ -113,6 +113,36 @@ memtest_extra_args(GVC_t *gvc, int argc, char** argv) return cnt; } +static int +config_extra_args(GVC_t *gvc, int argc, char** argv) +{ + char** p = argv+1; + int i; + char* arg; + int cnt = 1; + + for (i = 1; i < argc; i++) { + arg = argv[i]; + if (arg && *arg == '-') { + switch (arg[1]) { + case 'c' : Config = TRUE; break; + default : + cnt++; + if (*p != arg) *p = arg; + p++; + break; + } + } + else { + cnt++; + if (*p != arg) *p = arg; + p++; + } + } + *p = 0; + return cnt; +} + /* setDouble: * If arg is an double, value is stored in v * and functions returns 0; otherwise, returns 1. @@ -222,6 +252,7 @@ int gvParseArgs(GVC_t *gvc, int argc, char** argv) argc = neato_extra_args(gvc, argc, argv); argc = fdp_extra_args(gvc, argc, argv); argc = memtest_extra_args(gvc, argc, argv); + argc = config_extra_args(gvc, argc, argv); dotneato_initialize(gvc, argc, argv); return 0; } diff --git a/lib/common/globals.h b/lib/common/globals.h index 4bdd38643..a9f5adecd 100644 --- a/lib/common/globals.h +++ b/lib/common/globals.h @@ -64,7 +64,7 @@ extern "C" { EXTERN int Obj; #endif - EXTERN boolean Verbose, Reduce, MemTest; + EXTERN boolean Verbose, Reduce, MemTest, Config; EXTERN char *HTTPServerEnVar; EXTERN char *Output_file_name; EXTERN int graphviz_errors; diff --git a/lib/common/input.c b/lib/common/input.c index 266a4e026..2d374fa2c 100644 --- a/lib/common/input.c +++ b/lib/common/input.c @@ -62,6 +62,11 @@ static char *memtestFlags = "(additional options for memtest) [-m]\n"; static char *memtestItems = "\n\ -m - Memory test (Observe no growth with top. Kill when done.)\n"; +static char *configFlags = "(additional options for config) [-c]\n"; +static char *configItems = "\n\ + -m - Configure plugins (Writes $prefix/lib/graphviz/config \n\ + with available plugin information. Needs write priviledge.)\n"; + void dotneato_usage(int exval) { FILE *outs; @@ -75,10 +80,12 @@ void dotneato_usage(int exval) fputs(neatoFlags, outs); fputs(fdpFlags, outs); fputs(memtestFlags, outs); + fputs(configFlags, outs); fputs(genericItems, outs); fputs(neatoItems, outs); fputs(fdpItems, outs); fputs(memtestItems, outs); + fputs(configItems, outs); if (exval >= 0) exit(exval); @@ -141,7 +148,9 @@ void dotneato_initialize(GVC_t * gvc, int argc, char **argv) Gvfilepath = getenv("GV_FILE_PATH"); /* configure for available plugins and codegens */ - gvconfig(gvc); + gvconfig(gvc, Config); + if (Config) + exit (0); CmdName = basename(argv[0]); i = gvlayout_select(gvc, CmdName); diff --git a/lib/gvc/gvc.c b/lib/gvc/gvc.c index 51d085ba7..c06d424f7 100644 --- a/lib/gvc/gvc.c +++ b/lib/gvc/gvc.c @@ -29,7 +29,7 @@ GVC_t *gvContext(void) aginit(); agnodeattr(NULL, "label", NODENAME_ESC); gvc = gvNEWcontext(Info, username()); - gvconfig(gvc); /* configure for available plugins and codegens */ + gvconfig(gvc, FALSE); /* configure for available plugins and codegens */ return gvc; } diff --git a/lib/gvc/gvconfig.c b/lib/gvc/gvconfig.c index 4983cc2a7..445a93739 100644 --- a/lib/gvc/gvconfig.c +++ b/lib/gvc/gvconfig.c @@ -397,7 +397,7 @@ codegen_info_t *next_codegen(codegen_info_t * p) /* gvconfig - parse a config file and install the identified plugins */ -void gvconfig(GVC_t * gvc) +void gvconfig(GVC_t * gvc, boolean rescan) { #ifdef DISABLE_LTDL gvplugin_library_t **libraryp; @@ -437,16 +437,18 @@ void gvconfig(GVC_t * gvc) strcpy(config_path, GVLIBDIR); strcat(config_path, "/"); strcat(config_path, config_file_name); - rc = stat(config_path, &config_st); - if (rc == -1 || libdir_st.st_mtime > config_st.st_mtime) { + if (rescan) { config_rescan(gvc, config_path); } else { /* load in the cached plugin library data */ - rc = 0; - if (config_st.st_size > MAX_SZ_CONFIG) { + rc = stat(config_path, &config_st); + if (rc == -1) { + agerr(AGERR,"Unable to stat %s.\n", config_path); + } + else if (config_st.st_size > MAX_SZ_CONFIG) { agerr(AGERR,"%s is bigger than I can handle.\n", config_path); } else { @@ -470,10 +472,6 @@ void gvconfig(GVC_t * gvc) if (f) fclose(f); } - if (!rc) { - agerr(AGERR,"rescanning for plugins\n"); - config_rescan(gvc, config_path); - } } if (config_path) free(config_path); diff --git a/lib/gvc/gvcproc.h b/lib/gvc/gvcproc.h index f6a60b51e..5a71be60d 100644 --- a/lib/gvc/gvcproc.h +++ b/lib/gvc/gvcproc.h @@ -31,7 +31,7 @@ extern "C" { /* configuration */ - extern void gvconfig(GVC_t * gvc); + extern void gvconfig(GVC_t * gvc, boolean rescan); extern char *gvhostname(void); /* plugins */ diff --git a/tclpkg/gv/gv.cpp b/tclpkg/gv/gv.cpp index 7576af324..516a0ff51 100644 --- a/tclpkg/gv/gv.cpp +++ b/tclpkg/gv/gv.cpp @@ -31,7 +31,7 @@ static void gvinit() gvc = gvNEWcontext(Info, username()); /* configure for available plugins and codegens */ - gvconfig(gvc); + gvconfig(gvc, FALSE); } Agraph_t *digraph(char *name) diff --git a/tclpkg/tcldot/tcldot.c b/tclpkg/tcldot/tcldot.c index e3fc4d29d..24c32b01f 100644 --- a/tclpkg/tcldot/tcldot.c +++ b/tclpkg/tcldot/tcldot.c @@ -1645,7 +1645,7 @@ int Tcldot_Init(Tcl_Interp * interp) gvc = gvNEWcontext(Info, username()); /* configure for available plugins and codegens */ - gvconfig(gvc); + gvconfig(gvc, FALSE); /* additional codegens */ for (p = cg; p->name; ++p) gvplugin_install(gvc, API_render, p->name, 0, "cg", NULL, -- 2.40.0