- Timestamp:
- 08/11/06 12:27:39 (18 years ago)
- Location:
- trunk/scons
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/scons/casa.py
r1128 r1129 1 __revision__ = "$Version:$"2 1 import os 3 import sys 4 import platform 5 from SCons.Script import * 2 import re 6 3 7 def addCasa(env): 8 casalibs = "casav atnf images ms components coordinates \ 9 lattices fits measures measures_f \ 10 tables scimath scimath_f casa wcs".split() 11 env.Prepend( LIBS = casalibs ) 12 casaincd = [os.path.join(env['CASAROOT'], 'code/include'), \ 13 os.path.join(env['CASAROOT'], 'code/casa')] 14 env.Append( CPPPATH = casaincd ) 15 casalibd = os.path.join(env['CASAROOT'], env['CASAARCH'], 'lib') 16 env.Append( LIBPATH = [ casalibd ] ) 17 # Explicit templates in casa 18 env.Append( CPPFLAGS = ['-DAIPS_NO_TEMPLATE_SRC'] ) 4 def generate(env): 5 def CheckCasaLib(context, lib): 6 context.Message("Checking casa library '%s'..."%lib) 19 7 20 def checkCasa(conf, path=None): 21 ''' look for casa libraries'''22 conf.Message('Checking for casa libraries...') 23 casaarch = None24 if os.environ.has_key('AIPSPATH'):25 casa = os.environ.get('AIPSPATH').split()26 conf.env.Append(CASAARCH = casa[1])27 conf.env.Append(CASAROOT = casa[0])28 addCasa(conf.env)29 conf.Result('yes')30 return True31 casaarch = 'linux_gnu'32 if sys.platform == 'darwin':33 casaarch = 'darwin'34 elif sys.platform == 'linux2' and platform.architecture()[0] == '64bit':35 casaarch = 'linux_64b'36 paths = "/nfs/aips++/weekly /aips++ /opt/aips++ ../casa_asap".split()37 if path is not None and len(path):38 paths = [path]39 for p in paths:40 if os.path.isfile(os.path.join(p, casaarch, "lib/libcasa.a")):41 con f.env.Append(CASAARCH = casaarch)42 con f.env.Append(CASAROOT = os.path.abspath(p))43 addCasa(con f.env)44 con f.Result('yes')8 context.Result(r) 9 return r 10 11 def CheckCasa(context, path=None): 12 ''' look for casa libraries''' 13 def addCasa(env): 14 casalibs = "casav atnf images ms components coordinates \ 15 lattices fits measures measures_f \ 16 tables scimath scimath_f casa wcs".split() 17 #env.Prepend( LIBS = casalibs ) 18 casaincd = [os.path.join(env['CASAROOT'], 'code/include'), \ 19 os.path.join(env['CASAROOT'], 'code/casa')] 20 env.Append( CPPPATH = casaincd ) 21 casalibd = os.path.join(env['CASAROOT'], env['CASAARCH'], 'lib') 22 env.Append( LIBPATH = [ casalibd ] ) 23 # Explicit templates in casa 24 env.Append( CPPFLAGS = ['-DAIPS_NO_TEMPLATE_SRC'] ) 25 context.Message('Checking for casa libraries...') 26 casaarch = None 27 if os.environ.has_key('AIPSPATH'): 28 casa = os.environ.get('AIPSPATH').split() 29 context.env.Append(CASAARCH = casa[1]) 30 context.env.Append(CASAROOT = casa[0]) 31 addCasa(context.env) 32 context.Result('yes') 45 33 return True 46 conf.Result('no') 47 return False 34 casaarch = 'linux_gnu' 35 if sys.platform == 'darwin': 36 casaarch = 'darwin' 37 elif sys.platform == 'linux2' and platform.architecture()[0] == '64bit': 38 casaarch = 'linux_64b' 39 paths = "/nfs/aips++/weekly /aips++ /opt/aips++ ../casa_asap".split() 40 if path is not None and len(path): 41 paths = [path] 42 # @todo poor mans detection, do autocontext later 43 for p in paths: 44 if os.path.isfile(os.path.join(p, casaarch, "lib/libcasa.a")): 45 context.env.Append(CASAARCH = casaarch) 46 context.env.Append(CASAROOT = os.path.abspath(p)) 47 addCasa(context.env) 48 context.Result('yes') 49 return True 50 context.Result('no') 51 return False 52 53 54 def AddCustomTests(conf): 55 conf.AddTests({ 56 'CheckCasa' : CheckCasa, 57 }) 58 59 env.AddCustomTests = AddCustomTests 60 61 def AddCustomPath(path=""): 62 if not len(path) or not os.path.exists(path): 63 return 64 env.PrependUnique(CPPPATH = [os.path.join(path, "include")]) 65 env.PrependUnique(LIBPATH = [os.path.join(path, "lib")]) 66 env.AddCustomPath = AddCustomPath 67 68 def exists(env): 69 return true -
trunk/scons/installtree.py
r1124 r1129 1 1 import os 2 2 import fnmatch 3 from SCons.Script import *3 #from SCons.Script import * 4 4 5 def InstallTree(env, dest_dir, src_dir, includes, excludes): 6 destnode = env.Dir(dest_dir) 7 dirs = [] 8 dirs.append(src_dir) 9 while len(dirs) > 0: 10 currdir = dirs.pop(0) 11 currdestdir = dest_dir + currdir[len(src_dir):] 12 flist = os.listdir(currdir) 13 for currfile in flist: 14 currpath = os.path.join(currdir, currfile) 15 match = 0 16 for pattern in includes: 17 if fnmatch.fnmatchcase(currfile, pattern): 18 match = 1 19 if (match == 1): 20 for pattern in excludes: 5 def generate(env): 6 def InstallTree(dest_dir, src_dir, includes, excludes): 7 destnode = env.Dir(dest_dir) 8 dirs = [] 9 dirs.append(src_dir) 10 while len(dirs) > 0: 11 currdir = dirs.pop(0) 12 currdestdir = dest_dir + currdir[len(src_dir):] 13 flist = os.listdir(currdir) 14 for currfile in flist: 15 currpath = os.path.join(currdir, currfile) 16 match = 0 17 for pattern in includes: 21 18 if fnmatch.fnmatchcase(currfile, pattern): 22 match = 019 match = 1 23 20 if (match == 1): 24 if (os.path.isdir(currpath)): 25 #print "d=" + currpath 26 dirs.append(currpath) 27 else: 28 #print "f=" + currpath 29 env.Install(currdestdir, currpath) 30 return destnode 21 for pattern in excludes: 22 if fnmatch.fnmatchcase(currfile, pattern): 23 match = 0 24 if (match == 1): 25 if (os.path.isdir(currpath)): 26 #print "d=" + currpath 27 dirs.append(currpath) 28 else: 29 #print "f=" + currpath 30 env.Install(currdestdir, currpath) 31 return destnode 32 33 env.InstallTree = InstallTree 34 def exists(env): 35 return true
Note:
See TracChangeset
for help on using the changeset viewer.