Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/torch/graph.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorsoumith <soumith@gmail.com>2015-11-12 05:12:48 +0300
committersoumith <soumith@gmail.com>2015-11-12 05:12:48 +0300
commitb2a9fa846798a3973d89a6eb19dfb2564f446ba6 (patch)
treeb41a069f152da04926b3c39b5781be0d6327c7c4
parent4c70719edd06edbb03f6b1d191a83d47d299b04a (diff)
adding travis. Fixes for Lua51/Lua52
-rw-r--r--.travis.yml64
-rw-r--r--graphviz.lua18
2 files changed, 74 insertions, 8 deletions
diff --git a/.travis.yml b/.travis.yml
new file mode 100644
index 0000000..132d117
--- /dev/null
+++ b/.travis.yml
@@ -0,0 +1,64 @@
+language: c
+compiler:
+ - gcc
+ - clang
+cache:
+ directories:
+ - $HOME/OpenBlasInstall
+ - $HOME/GraphViz
+sudo: false
+env:
+ - TORCH_LUA_VERSION=LUAJIT21
+ - TORCH_LUA_VERSION=LUA51
+ - TORCH_LUA_VERSION=LUA52
+addons:
+ apt:
+ packages:
+ - cmake
+ - gfortran
+ - gcc-multilib
+ - gfortran-multilib
+ - liblapack-dev
+ - build-essential
+ - gcc
+ - g++
+ - curl
+ - cmake
+ - libreadline-dev
+ - git-core
+ - libqt4-core
+ - libqt4-gui
+ - libqt4-dev
+ - libjpeg-dev
+ - libpng-dev
+ - ncurses-dev
+ - imagemagick
+ - libzmq3-dev
+ - gfortran
+ - unzip
+ - gnuplot
+ - gnuplot-x11
+before_script:
+- export ROOT_TRAVIS_DIR=$(pwd)
+- export INSTALL_PREFIX=~/torch/install
+- ls $HOME/OpenBlasInstall/lib || (cd /tmp/ && git clone https://github.com/xianyi/OpenBLAS.git -b master && cd OpenBLAS && (make NO_AFFINITY=1 -j$(getconf _NPROCESSORS_ONLN) 2>/dev/null >/dev/null) && make PREFIX=$HOME/OpenBlasInstall install)
+- ls $HOME/GraphViz/lib || (cd /tmp/ && wget -c http://www.graphviz.org/pub/graphviz/stable/SOURCES/graphviz-2.38.0.tar.gz && tar -xvf graphviz-2.38.0.tar.gz && cd graphviz-2.38.0 && (./configure prefix=$HOME/GraphViz/ 2>/dev/null >/dev/null) && (make NO_AFFINITY=1 -j$(getconf _NPROCESSORS_ONLN) 2>/dev/null >/dev/null) && make install)
+- export LD_LIBRARY_PATH=$HOME/GraphViz/lib:$LD_LIBRARY_PATH
+- git clone https://github.com/torch/distro.git ~/torch --recursive
+- cd ~/torch && git submodule update --init --recursive
+- mkdir build && cd build
+- export CMAKE_LIBRARY_PATH=$HOME/OpenBlasInstall/include:$HOME/OpenBlasInstall/lib:$CMAKE_LIBRARY_PATH
+- cmake .. -DCMAKE_INSTALL_PREFIX="${INSTALL_PREFIX}" -DCMAKE_BUILD_TYPE=Release -DWITH_${TORCH_LUA_VERSION}=ON
+- make && make install
+- cd $ROOT_TRAVIS_DIR
+- export LD_LIBRARY_PATH=${INSTALL_PREFIX}/lib:$LD_LIBRARY_PATH
+script:
+- ${INSTALL_PREFIX}/bin/luarocks make
+- export PATH=${INSTALL_PREFIX}/bin:$PATH
+- export LD_LIBRARY_PATH=$HOME/GraphViz/lib:$LD_LIBRARY_PATH
+- export TESTLUA=$(which luajit lua | head -n 1)
+- ${TESTLUA} -lgraph -e "print('graph loaded succesfully')"
+- ${INSTALL_PREFIX}/bin/luarocks install totem
+- cd test
+- ${TESTLUA} test_graph.lua
+- ${TESTLUA} test_graphviz.lua
diff --git a/graphviz.lua b/graphviz.lua
index 9b2afdb..80cce0b 100644
--- a/graphviz.lua
+++ b/graphviz.lua
@@ -50,20 +50,22 @@ else
cgraphOk = false
end
+local unpack = unpack or table.unpack -- Lua52 compatibility
-- Retrieve attribute data from a graphviz object.
local function getAttribute(obj, name)
local res = cgraph.agget(obj, ffi.cast("char*", name))
assert(res ~= ffi.cast("char*", nil), 'could not get attr ' .. name)
- return ffi.string(res)
+ local out = ffi.string(res)
+ return out
end
-- Iterate through nodes of a graphviz graph.
local function nodeIterator(graph)
local node = cgraph.agfstnode(graph)
local nextNode
return function()
- if node == nil then return end
- if node == cgraph.aglstnode(graph) then nextNode = nil end
+ if node == ffi.C.NULL then return end
+ if node == cgraph.aglstnode(graph) then nextNode = ffi.C.NULL end
nextNode = cgraph.agnxtnode(graph, node)
local result = node
node = nextNode
@@ -120,13 +122,13 @@ function graph.graphvizLayout(g, algorithm)
local graphvizGraph = cgraph.agmemread(g:todot())
local algorithm = algorithm or "dot"
assert(0 == graphviz.gvLayout(context, graphvizGraph, algorithm),
- "graphviz layout failed")
- assert(0 == graphviz.gvRender(context, graphvizGraph, algorithm, nil),
- "graphviz render failed")
+ "graphviz layout failed")
+ assert(0 == graphviz.gvRender(context, graphvizGraph, algorithm, ffi.C.NULL),
+ "graphviz render failed")
-- Extract bounding box.
- local x0, y0, x1, y1 = extractNumbers(4,
- getAttribute(graphvizGraph, 'bb'), ",")
+ local x0, y0, x1, y1
+ = extractNumbers(4, getAttribute(graphvizGraph, 'bb'), ",")
local w = x1 - x0
local h = y1 - y0
local bbox = { x0, y0, w, h }