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

Contents of /trunk/scons/graphviz.py

Parent Directory Parent Directory | Revision Log Revision Log


Revision 1930 - (show annotations) (download) (as text)
Sun Oct 19 02:48:37 2008 UTC (16 years ago) by jpye
File MIME type: text/x-python
File size: 2006 byte(s)
Replace env.Copy to env.Clone in graphviz.py
Fixed location of documentation PDF in RPM.
1 import os, os.path, platform, subprocess
2 from SCons.Script import *
3
4 munge = lambda s: s
5
6 try:
7 # if we have access to GetShortPathName, we'll use it...
8 import win32api
9 def munge1(s):
10 s1 = s
11 try:
12 # we can only munge the path if it actually exists
13 s1 = win32api.GetShortPathName(s)
14 except:
15 # if it doesn't exist, we just return the un-munged path
16 pass
17 return s1
18 munge = munge1
19 except:
20 pass
21
22 def generate(env):
23 """
24 Detect Graphviz settings and add them to the environment.
25 """
26 try:
27 if platform.system()=="Windows":
28 import _winreg
29 x=_winreg.ConnectRegistry(None,_winreg.HKEY_LOCAL_MACHINE)
30 y= _winreg.OpenKey(x,r"SOFTWARE\ATT\GraphViz")
31 PATH,t = _winreg.QueryValueEx(y,"InstallPath")
32 LIB = os.path.join(PATH,"lib")
33 BIN = os.path.join(PATH,"bin")
34 INCLUDE = os.path.join(PATH,"include")
35
36 env['GRAPHVIZ_CPPPATH'] = [munge(INCLUDE)]
37 env['GRAPHVIZ_LIBPATH'] = [munge(BIN)]
38 env['GRAPHVIZ_LIBS'] = ['gvc','graph']
39 env['HAVE_GRAPHVIZ'] = True
40
41 else:
42 cmd = ['pkg-config','libgvc','libagraph','--cflags','--libs']
43 env1 = env.Clone()
44 env1['CPPPATH'] = None
45 env1['LIBPATH'] = None
46 env1['LIBS'] = None
47 env1.ParseConfig(cmd)
48 env['GRAPHVIZ_CPPPATH'] = env1.get('CPPPATH')
49 env['GRAPHVIZ_LIBPATH'] = env1.get('LIBPATH')
50 env['GRAPHVIZ_LIBS'] = env1.get('LIBS')
51 env['HAVE_GRAPHVIZ'] = True
52
53 print "GRAPHVIZ_LIBS =",env.get('GRAPHVIZ_LIBS')
54 print "GRAPHVIZ_LIBPATH =",env.get('GRAPHVIZ_LIBPATH')
55 print "GRAPHVIZ_CPPPATH =",env.get('GRAPHVIZ_CPPPATH')
56
57 except:
58 env['HAVE_GRAPHVIZ'] = False
59
60 def exists(env):
61 """
62 Make sure this tool exists.
63 """
64 if platform.system()=="Windows":
65 try:
66 import _winreg
67 x=_winreg.ConnectRegistry(None,_winreg.HKEY_LOCAL_MACHINE)
68 y= _winreg.OpenKey(x,r"SOFTWARE\graphviz")
69 INCLUDE,t = _winreg.QueryValueEx(y,'INSTALL_INCLUDE')
70 return True
71 except:
72 return False
73 else:
74 if not subprocess.call('pkg-config libgvc libagraph --exists'):
75 return True
76 return False
77

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