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

Contents of /trunk/tools/scons/ascend.py

Parent Directory Parent Directory | Revision Log Revision Log


Revision 2007 - (show annotations) (download) (as text)
Mon Apr 27 06:09:29 2009 UTC (13 years, 7 months ago) by jpye
File MIME type: text/x-python
File size: 3349 byte(s)
Break ASCEND into dev package and main package.
Fix up gtksourceview syntax rules, add more keywords, remove C cruft.
Add tools/scons/ascend.py tool for detecting ASCEND when building software using SCons.
DTAR now fails if dpkg-buildpackage fails, keeps temp files hanging around for inspection.
Plots generated by 'plot.a4l' no longer add legend if no labels specified.
Committing python bindings for FPROPS. Much testing remains to be done there.

1 # SCons tool to determine settings for use with ASCEND modelling environment.
2 # If you change this file, please provide a copy back to the ASCEND project;
3 # hopefully someone else will also find your changes useful:
4 # see http://ascend.cheme.cmu.edu/
5
6 import os, platform,sys,subprocess
7 from SCons.Script import *
8
9 def generate(env):
10 """
11 Detect ASCEND settings and add them to the environment.
12 """
13 try:
14 if platform.system()=="Windows":
15 import _winreg
16 x=_winreg.ConnectRegistry(None,_winreg.HKEY_LOCAL_MACHINE)
17 y= _winreg.OpenKey(x,r"SOFTWARE\ASCEND")
18 BIN,t = _winreg.QueryValueEx(y,'INSTALL_BIN')
19 Path = os.path.join(BIN,"ascend-config")
20 if not os.path.exists(Path):
21 raise RuntimeError("Could not find 'ascend-config' in your PATH")
22
23 cmd = [sys.executable,"\"%s\""%Path,"--cppflags","--libs"]
24 env1 = env.Copy()
25 env1.ParseConfig(cmd)
26 env.Append(
27 ASCEND_CPPPATH = env1.get('CPPPATH') or []
28 ,ASCEND_CPPDEFINES = env1.get('CPPDEFINES') or []
29 ,ASCEND_LIBPATH = env1.get('LIBPATH') or []
30 ,ASCEND_LIBS = env1.get('LIBS') or []
31 )
32 cmd = [sys.executable,Path]
33 libext = ".dll"
34 libpref = ""
35
36 else:
37 cmd = ['ascend-config','--libs','--cppflags','--libs']
38 env1 = env.Clone()
39 env1.ParseConfig(cmd)
40 env.Append(
41 ASCEND_CPPPATH = env1.get('CPPPATH') or []
42 ,ASCEND_CPPDEFINES = env1.get('CPPDEFINES') or []
43 ,ASCEND_LIBPATH = env1.get('LIBPATH') or []
44 ,ASCEND_LIBS = env1.get('LIBS') or []
45 )
46 cmd = ['ascend-config']
47 libext = ".so"
48 libpref = "lib"
49
50 # Get the suffix and prefix used for external libraries
51
52 proc = subprocess.Popen(cmd+['--extlib-prefix'],stdout=subprocess.PIPE,stderr=subprocess.PIPE)
53 out = proc.communicate()[0].strip()
54 if proc.returncode is 0:
55 env.Append(ASCEND_EXTLIB_PREFIX=out)
56 else:
57 # old ASCEND will not provide '--extlib-prefix' so make some assumptions...
58 env.Append(ASCEND_EXTLIB_PREFIX=libpref)
59 proc = subprocess.Popen(cmd+['--extlib-suffix'],stdout=subprocess.PIPE,stderr=subprocess.PIPE)
60 out = proc.communicate()[0].strip()
61 if proc.returncode is 0:
62 env.Append(ASCEND_EXTLIB_SUFFIX=out)
63 else:
64 env.Append(ASCEND_EXTLIB_SUFFIX="_ascend%s"%libext)
65
66 # Get the ASCEND model library location (it will be assumed that
67 # we can install files to that location)
68
69 proc = subprocess.Popen(cmd+['--models'],stdout=subprocess.PIPE,stderr=subprocess.PIPE)
70 out = proc.communicate()[0].strip()
71 if proc.returncode is 0:
72 env.Append(ASCEND_MODELS=out)
73
74 env.Append(HAVE_ASCEND=True)
75
76 print "ASCEND_LIBS =",env.get('ASCEND_LIBS')
77 print "ASCEND_LIBPATH =",env.get('ASCEND_LIBPATH')
78 print "ASCEND_CPPPATH =",env.get('ASCEND_CPPPATH')
79 print "ASCEND_EXTLIB_SUFFIX =",env.get('ASCEND_EXTLIB_SUFFIX')
80 print "ASCEND_EXTLIB_PREFIX =",env.get('ASCEND_EXTLIB_PREFIX')
81 print "ASCEND_MODELS =",env.get('ASCEND_MODELS')
82
83 except Exception,e:
84 print "FAILED TO SET UP ASCEND (%s)" % str(e)
85 pass
86
87 def exists(env):
88 """
89 Make sure this tool exists.
90 """
91 if platform.system()=="Windows":
92 try:
93 import _winreg
94 x=_winreg.ConnectRegistry(None,_winreg.HKEY_LOCAL_MACHINE)
95 y= _winreg.OpenKey(x,r"SOFTWARE\ASCEND")
96 BIN,t = _winreg.QueryValueEx(y,'INSTALL_BIN')
97 return True
98 except:
99 return False
100 else:
101 if env.Execute(['ascend-config','--version']):
102 return True
103 return False
104

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