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

Contents of /trunk/scons/graphviz.py

Parent Directory Parent Directory | Revision Log Revision Log


Revision 2425 - (show annotations) (download) (as text)
Wed Mar 23 05:17:07 2011 UTC (13 years, 10 months ago) by jpye
File MIME type: text/x-python
File size: 2405 byte(s)
More changes from Divyanshu Bandil.
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 try:
43 cmd = ['pkg-config','libgvc','libagraph','--cflags','--libs']
44 env1 = env.Clone()
45 env1['CPPPATH'] = None
46 env1['LIBPATH'] = None
47 env1['LIBS'] = None
48 env1.ParseConfig(cmd)
49 env['GRAPHVIZ_CPPPATH'] = env1.get('CPPPATH')
50 env['GRAPHVIZ_LIBPATH'] = env1.get('LIBPATH')
51 env['GRAPHVIZ_LIBS'] = env1.get('LIBS')
52 env['HAVE_GRAPHVIZ'] = True
53 except:
54 cmd = ['pkg-config','libgvc','libcgraph','--cflags','--libs']
55 env1 = env.Clone()
56 env1['CPPPATH'] = None
57 env1['LIBPATH'] = None
58 env1['LIBS'] = None
59 env1.ParseConfig(cmd)
60 env['GRAPHVIZ_CPPPATH'] = env1.get('CPPPATH')
61 env['GRAPHVIZ_LIBPATH'] = env1.get('LIBPATH')
62 env['GRAPHVIZ_LIBS'] = env1.get('LIBS')
63 env['HAVE_GRAPHVIZ'] = True
64
65 print "GRAPHVIZ_LIBS =",env.get('GRAPHVIZ_LIBS')
66 print "GRAPHVIZ_LIBPATH =",env.get('GRAPHVIZ_LIBPATH')
67 print "GRAPHVIZ_CPPPATH =",env.get('GRAPHVIZ_CPPPATH')
68
69 except:
70 env['HAVE_GRAPHVIZ'] = False
71
72 def exists(env):
73 """
74 Make sure this tool exists.
75 """
76 if platform.system()=="Windows":
77 try:
78 import _winreg
79 x=_winreg.ConnectRegistry(None,_winreg.HKEY_LOCAL_MACHINE)
80 y= _winreg.OpenKey(x,r"SOFTWARE\graphviz")
81 INCLUDE,t = _winreg.QueryValueEx(y,'INSTALL_INCLUDE')
82 return True
83 except:
84 return False
85 else:
86 if not subprocess.call('pkg-config libgvc libagraph --exists'):
87 return True
88 return False
89

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