/[escript]/branches/4.0fordebian/site_scons/site_init.py
ViewVC logotype

Diff of /branches/4.0fordebian/site_scons/site_init.py

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

trunk/scons/scons_extensions.py revision 2502 by gross, Tue Jun 30 05:49:22 2009 UTC branches/domexper/site_scons/site_init.py revision 3251 by jfenwick, Thu Oct 7 04:02:30 2010 UTC
# Line 1  Line 1 
1    
2  ########################################################  ########################################################
3  #  #
4  # Copyright (c) 2003-2008 by University of Queensland  # Copyright (c) 2003-2010 by University of Queensland
5  # Earth Systems Science Computational Center (ESSCC)  # Earth Systems Science Computational Center (ESSCC)
6  # http://www.uq.edu.au/esscc  # http://www.uq.edu.au/esscc
7  #  #
# Line 11  Line 11 
11  #  #
12  ########################################################  ########################################################
13    
14  __copyright__="""Copyright (c) 2003-2008 by University of Queensland  __copyright__="""Copyright (c) 2003-2010 by University of Queensland
15  Earth Systems Science Computational Center (ESSCC)  Earth Systems Science Computational Center (ESSCC)
16  http://www.uq.edu.au/esscc  http://www.uq.edu.au/esscc
17  Primary Business: Queensland, Australia"""  Primary Business: Queensland, Australia"""
# Line 21  __url__="https://launchpad.net/escript-f Line 21  __url__="https://launchpad.net/escript-f
21    
22  import sys, os, time, glob, fnmatch, types, py_compile, re  import sys, os, time, glob, fnmatch, types, py_compile, re
23    
24  from SCons.Script.SConscript import SConsEnvironment  def findLibWithHeader(env, libs, header, paths, lang='c'):
25        from SCons.Script.SConscript import Configure
26        inc_path=''
27        lib_path=''
28        # 'paths' may be a prefix, so look for lib and include subdirectories
29        if type(paths)==str:
30            # find the header file first
31            for i in 'include','include64','include32','inc':
32                inc=os.path.join(paths, i)
33                if os.path.isfile(os.path.join(inc, header)):
34                    inc_path=inc
35                    break
36            if inc_path=='':
37                raise RuntimeError('%s not found under %s'%(header,paths))
38    
39            # now try to find a lib directory
40            for l in 'lib','lib64','lib32':
41                lp=os.path.join(paths, l)
42                if os.path.isdir(lp):
43                    lib_path=lp
44                    break
45            if lib_path=='':
46                raise RuntimeError('No lib directory found under %s'%paths)
47        else:
48            if os.path.isfile(os.path.join(paths[0], header)):
49                inc_path=paths[0]
50            else:
51                raise RuntimeError('%s not found under %s'%(header,paths[0]))
52            if os.path.isdir(paths[1]):
53                lib_path=paths[1]
54            else:
55                raise RuntimeError('%s is not a valid path.'%paths[1])
56    
57        # now try the library
58        conf=Configure(env.Clone())
59        conf.env.AppendUnique(CPPPATH = [inc_path])
60        conf.env.AppendUnique(LIBPATH = [lib_path])
61        if type(libs)==str: libs=[libs]
62        # we can't check for each library by itself since they may depend on each
63        # other, so we add all libraries to the link line and check only for one
64        conf.env.AppendUnique(LIBS = libs)
65        if not conf.CheckLibWithHeader(libs[0], header, lang):
66            conf.Finish()
67            raise RuntimeError('Unable to link against %s (paths: %s, %s)'%(libs,inc_path,lib_path))
68    
69        conf.Finish()
70        return inc_path, lib_path
71    
72  # Code to build .pyc from .py  # Code to build .pyc from .py
73  def build_py(target, source, env):  def build_py(target, source, env):
# Line 34  def runUnitTest(target, source, env): Line 80  def runUnitTest(target, source, env):
80    app = str(source[0].abspath)    app = str(source[0].abspath)
81    pn, sn= os.path.split(app)    pn, sn= os.path.split(app)
82    if not os.name== "nt":    if not os.name== "nt":
83       app = "cd "+pn+"; "+os.path.join(env['bininstall'],"escript")+" -bv "+sn       app = "cd "+pn+"; "+os.path.join(env['bininstall'],"escript")+" -bv "+os.path.join('.',sn)
84    else:    else:
85        if env['usempi']:        if env['usempi']:
86            app = "cd %s | mpiexec -np %s -genvlist PYTHONPATH,OMP_NUM_THREADS,"\            app = "cd %s & mpiexec -np %s -genvlist PYTHONPATH,OMP_NUM_THREADS,"\
87              "FINLEY_TEST_DATA,PYVISI_TEST_DATA_ROOT,PYVISI_WORKDIR,PATH %s"\              "FINLEY_TEST_DATA,PYVISI_TEST_DATA_ROOT,PYVISI_WORKDIR,PATH %s"\
88              %(pn,env['ENV']['ESCRIPT_NUM_NODES'], sn)              %(pn,env['ENV']['ESCRIPT_NUM_NODES'], sn)
89        else:        else:
90             app = "cd "+ pn +" | "+ sn             app = "cd "+ pn +" & "+sn
91    print "Executing test: " + app    print "Executing test: " + app
92    if not env.Execute(app):    if not env.Execute(app):
93      open(str(target[0]),'w').write("PASSED\n")      open(str(target[0]),'w').write("PASSED\n")
# Line 56  def runPyUnitTest(target, source, env): Line 102  def runPyUnitTest(target, source, env):
102     pn, sn= os.path.split(app)     pn, sn= os.path.split(app)
103     if os.name== "nt":     if os.name== "nt":
104         if env['usempi']:         if env['usempi']:
105             app = "cd %s | mpiexec -np %s -genvlist PYTHONPATH,OMP_NUM_THREADS,"\             app = "cd %s & mpiexec -np %s -genvlist PYTHONPATH,OMP_NUM_THREADS,"\
106                "FINLEY_TEST_DATA,PYVISI_TEST_DATA_ROOT,PYVISI_WORKDIR,PATH %s\pythonMPIredirect.exe %s"\                "FINLEY_TEST_DATA,PYVISI_TEST_DATA_ROOT,PYVISI_WORKDIR,PATH %s\pythonMPIredirect.exe %s"\
107                %(pn,env['ENV']['ESCRIPT_NUM_NODES'],env['libinstall'],sn)                %(pn,env['ENV']['ESCRIPT_NUM_NODES'],env['libinstall'],sn)
108         else:         else:
109             app = "cd "+ pn +" | "+sys.executable + " " + sn             app = "cd "+ pn +" & "+sys.executable + " " + sn
110     else:     else:
111       app = "cd "+pn+"; "+os.path.join(env['bininstall'],"escript")+" -ov "+sn       app = "cd "+pn+"; "+os.path.join(env['bininstall'],"escript")+" -ov "+sn
112     print "Executing test: ",app     print "Executing test: ",app
# Line 72  def runPyUnitTest(target, source, env): Line 118  def runPyUnitTest(target, source, env):
118     return None     return None
119    
120  def eps2pdf(target, source, env):  def eps2pdf(target, source, env):
121     if env.Execute("epstopdf "+str(source[0].abspath)+" -o "+str(target[0].abspath))!=0:  #   if env.Execute("epstopdf "+str(source[0].abspath)+" -o "+str(target[0].abspath))!=0:
122       if env.Execute("ps2pdf "+str(source[0].abspath)+" "+str(target[0].abspath))!=0:
123         return 1         return 1
124     return None     return None
125    
126  def effectiveName(inname):  def effectiveName(inname):
127     m=re.compile("^r1i[0-9]{1,2}n[0-9]{1,2}$")   # savanna names take the form r1i?n?     m=re.compile("^r1i[0-9]{1,2}n[0-9]{1,2}$")   # savanna names take the form r1i?n?
128     if m.match(inname):     if m.match(inname):
129      return "service0"      return "savanna"
130     return inname     return inname

Legend:
Removed from v.2502  
changed lines
  Added in v.3251

  ViewVC Help
Powered by ViewVC 1.1.26