/[ascend]/trunk/scons/graphviz.py
ViewVC logotype

Contents of /trunk/scons/graphviz.py

Parent Directory Parent Directory | Revision Log Revision Log


Revision 2429 - (show annotations) (download) (as text)
Sat Mar 26 00:44:44 2011 UTC (11 years, 3 months ago) by jpye
File MIME type: text/x-python
File size: 2602 byte(s)
Working on Windows supprt. Problems with detection of standard solvers in 'ascdev' driver,
updating to GraphViz 2.26.3 installer's registry usage.
1 import os, os.path, platform, subprocess
2 from SCons.Script import *
3
4 HKLM_GRAPHVIZ = r"SOFTWARE\AT&T Research Labs\Graphviz"
5
6 munge = lambda s: s
7 try:
8 # if we have access to GetShortPathName, we'll use it...
9 import win32api
10 def munge1(s):
11 s1 = s
12 try:
13 # we can only munge the path if it actually exists
14 s1 = win32api.GetShortPathName(s)
15 except:
16 # if it doesn't exist, we just return the un-munged path
17 pass
18 return s1
19 munge = munge1
20 except:
21 pass
22
23 def generate(env):
24 """
25 Detect Graphviz settings and add them to the environment.
26 """
27 try:
28 if platform.system()=="Windows":
29 import _winreg
30 x=_winreg.ConnectRegistry(None,_winreg.HKEY_LOCAL_MACHINE)
31 y= _winreg.OpenKey(x,HKLM_GRAPHVIZ)
32 PATH,t = _winreg.QueryValueEx(y,"InstallPath")
33 LIB = os.path.join(PATH,"lib")
34 BIN = os.path.join(PATH,"bin")
35 INCLUDE = os.path.join(PATH,"include","graphviz")
36
37 env['GRAPHVIZ_CPPPATH'] = [munge(INCLUDE)]
38 env['GRAPHVIZ_LIBPATH'] = [munge(BIN)]
39 env['GRAPHVIZ_LIBS'] = ['gvc','graph']
40 env['HAVE_GRAPHVIZ'] = True
41
42 else:
43 env1 = env.Clone()
44 env1['CPPPATH'] = None
45 env1['LIBPATH'] = None
46 env1['LIBS'] = None
47 try:
48 cmd = ['pkg-config','libgvc','libcgraph','--cflags','--libs']
49 env1.ParseConfig(cmd)
50 # we might get an error from this with older versions of GraphViz, so failover to below...
51 env['GRAPHVIZ_CPPPATH'] = env1.get('CPPPATH')
52 env['GRAPHVIZ_LIBPATH'] = env1.get('LIBPATH')
53 env['GRAPHVIZ_LIBS'] = env1.get('LIBS')
54 env['HAVE_GRAPHVIZ'] = True
55 except:
56 cmd = ['pkg-config','libgvc','libagraph','--cflags','--libs']
57 env1.ParseConfig(cmd)
58 env['GRAPHVIZ_CPPPATH'] = env1.get('CPPPATH')
59 env['GRAPHVIZ_LIBPATH'] = env1.get('LIBPATH')
60 env['GRAPHVIZ_LIBS'] = env1.get('LIBS')
61 env['HAVE_GRAPHVIZ'] = True
62
63 print "GRAPHVIZ_LIBS =",env.get('GRAPHVIZ_LIBS')
64 print "GRAPHVIZ_LIBPATH =",env.get('GRAPHVIZ_LIBPATH')
65 print "GRAPHVIZ_CPPPATH =",env.get('GRAPHVIZ_CPPPATH')
66
67 except Exception,e:
68 print "NO GRAPHVIZ (%s)" % str(e)
69 env['HAVE_GRAPHVIZ'] = False
70
71 def exists(env):
72 """
73 Make sure this tool exists.
74 """
75 print "CHECKING FOR GRAPHVIZ"
76 if platform.system()=="Windows":
77 try:
78 import _winreg
79 x=_winreg.ConnectRegistry(None,_winreg.HKEY_LOCAL_MACHINE)
80 y= _winreg.OpenKey(x,HKLM_GRAPHVIZ)
81 INCLUDE,t = _winreg.QueryValueEx(y,'InstallPath')
82 print "GRAPHVIZ EXISTS"
83 return True
84 except:
85 print "GRAPHVIZ DOESN'T EXIST"
86 return False
87 else:
88 print "NOT WINDOWS"
89 if not subprocess.call('pkg-config libgvc libagraph --exists'):
90 return True
91 return False
92

john.pye@anu.edu.au
ViewVC Help
Powered by ViewVC 1.1.22