diff options
author | Soumith Chintala <soumith@gmail.com> | 2015-08-05 14:41:01 +0300 |
---|---|---|
committer | Soumith Chintala <soumith@gmail.com> | 2015-08-05 14:41:01 +0300 |
commit | 83cbda2754268d82d55cca52f44b741d191909fe (patch) | |
tree | f83511af4fbf01ed798dfa3fbd17d252d466f8f8 | |
parent | 2fc58236b5c9a22812e9f6b3b7cf14588053786f (diff) | |
parent | 11609f61838805ed454c4ab1dfaac7a1dcfac66f (diff) |
Merge pull request #16 from torch/ffifix
removing ffi hard-dependency
-rw-r--r-- | graphviz.lua | 20 |
1 files changed, 16 insertions, 4 deletions
diff --git a/graphviz.lua b/graphviz.lua index 847d2dd..a30fff6 100644 --- a/graphviz.lua +++ b/graphviz.lua @@ -1,7 +1,15 @@ -local ffi = require 'ffi' require 'torch' -ffi.cdef[[ +local ffiOk = false +local graphvizOk = false +local cgraphOk = false +local ffi +local graphviz +local cgraph + +ffiOk, ffi = pcall(require, 'ffi') +if ffiOk then + ffi.cdef[[ typedef struct FILE FILE; typedef struct Agraph_s Agraph_t; @@ -25,9 +33,13 @@ extern int gvRender(GVC_t *context, graph_t *g, const char *format, FILE *out); extern int gvFreeLayout(GVC_t *context, graph_t *g); extern int gvFreeContext(GVC_t *context); ]] + graphvizOk, graphviz = pcall(function() return ffi.load('libgvc') end) + cgraphOk, cgraph = pcall(function() return ffi.load('libcgraph') end) +else + graphvizOk = false + cgraphOk = false +end -local graphvizOk, graphviz = pcall(function() return ffi.load('libgvc') end) -local cgraphOk, cgraph = pcall(function() return ffi.load('libcgraph') end) -- Retrieve attribute data from a graphviz object. local function getAttribute(obj, name) |