/[ascend]/trunk/SConstruct
ViewVC logotype

Diff of /trunk/SConstruct

Parent Directory Parent Directory | Revision Log Revision Log | View Patch Patch

revision 392 by johnpye, Thu Mar 30 12:36:15 2006 UTC revision 393 by johnpye, Thu Mar 30 14:46:37 2006 UTC
# Line 1  Line 1 
1  import os, commands, platform, distutils.sysconfig  import os, commands, platform, distutils.sysconfig, os.path
2    
3  #------------------------------------------------------  #------------------------------------------------------
4  # OPTIONS  # OPTIONS
# Line 37  opts.Add(BoolOption( Line 37  opts.Add(BoolOption(
37  # Which solvers will we allow?  # Which solvers will we allow?
38  opts.Add(ListOption(  opts.Add(ListOption(
39      'WITH_SOLVERS'      'WITH_SOLVERS'
40      ,"List of the solvers you want to build"      ,"List of the solvers you want to build. The default is the minimum that"  
41            +" works."
42      ,["QRSLV","CMSLV"]      ,["QRSLV","CMSLV"]
43      ,['QRSLV','MPS','SLV','OPTSQP'      ,['QRSLV','MPS','SLV','OPTSQP'
44          ,'NGSLV','CMSLV','LRSLV','MINOS','CONOPT'          ,'NGSLV','CMSLV','LRSLV','MINOS','CONOPT'
# Line 45  opts.Add(ListOption( Line 46  opts.Add(ListOption(
46       ]       ]
47  ))  ))
48    
49    # Where will the local copy of the help files be kept?
50    opts.Add(PackageOption(
51        'WITH_LOCAL_HELP'
52        , "Directory containing the local copy of the help files (optional)"
53        , "no"
54    ))
55    
56    # Will bintoken support be enabled?
57    opts.Add(BoolOption(
58        'WITH_BINTOKEN'
59        ,"Enable bintoken support? This means compiling models as C-code before"
60            +" running them, to increase solving speed for large models."
61        ,False
62    ))
63    
64    opts.Add(
65        'DEFAULT_ASCENDLIBRARY'
66        ,"Set the default value of the ASCENDLIBRARY -- the location where"
67            +" ASCEND will look for models when running ASCEND"
68        ,os.path.expanduser("~/src/ascend/trunk/models")
69    )
70    
71    # Where will the 'Makefile.bt' file be installed
72    
73  # TODO: add install options  # TODO: add install options
74    
75  # TODO: OTHER OPTIONS?  # TODO: OTHER OPTIONS?
76    
77  # TODO: flags for optimisation  # TODO: flags for optimisation
78    
79    # TODO: turning on/off bintoken functionality
80    
81  opts.Update(env)  opts.Update(env)
82  opts.Save('options.cache',env)  opts.Save('options.cache',env)
83    
# Line 63  with_tcltk_gui = (env['WITHOUT_TCLTK_GUI Line 90  with_tcltk_gui = (env['WITHOUT_TCLTK_GUI
90  with_python = (env['WITHOUT_PYTHON']==False)  with_python = (env['WITHOUT_PYTHON']==False)
91    
92  print "SOLVERS:",env['WITH_SOLVERS']  print "SOLVERS:",env['WITH_SOLVERS']
93        
94    print "WITH_LOCAL_HELP:",env['WITH_LOCAL_HELP']
95    print "WITH_BINTOKEN:",env['WITH_BINTOKEN']
96    print "DEFAULT_ASCENDLIBRARY:",env['DEFAULT_ASCENDLIBRARY']
97    
98    subst_dict = {
99        '@WEBHELPROOT@':'http://pye.dyndns.org/ascend/manual/'
100        , '@GLADE_FILE@':'glade/ascend.glade'
101        , '@DEFAULT_ASCENDLIBRARY@':env['DEFAULT_ASCENDLIBRARY']
102        , '@ASCEND_ICON@':'glade/ascend.png'
103        , '@HELP_ROOT@':''
104    }
105    
106    if env['WITH_LOCAL_HELP']:
107        subst_dict['@HELP_ROOT@']=env['WITH_LOCAL_HELP']
108            
109    env.Append(SUBST_DICT=subst_dict)
110    
111  #------------------------------------------------------  #------------------------------------------------------
112  # CONFIGURATION  # CONFIGURATION
113    
# Line 129  else: Line 173  else:
173    
174  # TODO: check size of void*  # TODO: check size of void*
175    
176    # TODO: detect if dynamic libraries are possible or not
177    
178    #------------------------------------------------------
179    # RECIPE: 'SubstInFile', used in pygtk SConscript
180    
181    import SCons.Util
182    import re
183    
184    def do_subst_in_file(targetfile, sourcefile, dict):
185        """Replace all instances of the keys of dict with their values.
186        For example, if dict is {'%VERSION%': '1.2345', '%BASE%': 'MyProg'},
187        then all instances of %VERSION% in the file will be replaced with 1.2345 etc.
188        """
189        try:
190            f = open(sourcefile, 'rb')
191            contents = f.read()
192            f.close()
193        except:
194            raise RuntimeError("Can't read source file %s" % sourcefile)
195        for (k,v) in dict.items():
196            contents = re.sub(k, v, contents)
197        try:
198            f = open(targetfile, 'wb')
199            f.write(contents)
200            f.close()
201        except:
202            raise RuntimeError("Can't write target file %s" % targetfile)
203        return 0 # success
204    
205    def subst_in_file(target, source, env):
206        if not env.has_key('SUBST_DICT'):
207            raise RuntimeError("SubstInFile requires SUBST_DICT to be set.")
208        d = dict(env['SUBST_DICT']) # copy it
209        for (k,v) in d.items():
210            if callable(v):
211                d[k] = env.subst(v())
212            elif SCons.Util.is_String(v):
213                d[k]=env.subst(v)
214            else:
215                raise RuntimeError(
216                    "SubstInFile: key %s: %s must be a string or callable" % (
217                        k, repr(v)
218                ))
219        for (t,s) in zip(target, source):
220            return do_subst_in_file(str(t), str(s), d)
221    
222    def subst_in_file_string(target, source, env):
223        """This is what gets printed on the console."""
224        return '\n'.join(['Substituting vars from %s into %s'%(str(s), str(t))
225                            for (t,s) in zip(target, source)])
226    
227    env['BUILDERS']['SubstInFile'] = Builder(
228        action = subst_in_file
229        , suffix = ''
230        , src_suffix = '.in'
231    )
232    
233  #------------------------------------------------------  #------------------------------------------------------
234  # SUBDIRECTORIES....  # SUBDIRECTORIES....
235    
236    
237  env.Append(CPPPATH=['..'])  env.Append(CPPPATH=['..'])
238    
239  env.SConscript(['base/generic/general/SConscript'],'env')  env.SConscript(['base/generic/general/SConscript'],'env')
# Line 154  if with_python: Line 256  if with_python:
256  else:  else:
257      print "Skipping... Python GUI isn't being built"      print "Skipping... Python GUI isn't being built"
258    
259    

Legend:
Removed from v.392  
changed lines
  Added in v.393

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