Changeset 1757 for branches/alma/scons
- Timestamp:
- 06/09/10 19:03:06 (14 years ago)
- Location:
- branches/alma
- Files:
-
- 3 edited
Legend:
- Unmodified
- Added
- Removed
-
branches/alma
-
Property svn:ignore
set to
.sconf_temp
.sconsign.dblite
-
Property svn:mergeinfo
set to
/branches/asap-3.x merged eligible
-
Property svn:ignore
set to
-
branches/alma/scons/quietinstall.py
r1184 r1757 1 1 import SCons 2 3 try: 4 from SCons.Environment import installFunc 5 except ImportError: 6 from SCons.Tool.install import installFunc 2 7 3 8 def no_output(target, source, env): … … 27 32 28 33 quietinstaller_builder = env.Builder( 29 action = env.Action( SCons.Environment.installFunc, no_output),34 action = env.Action(installFunc, no_output), 30 35 multi=1 31 36 ) -
branches/alma/scons/utils.py
r1332 r1757 1 import sys 1 2 import os 2 3 import glob 4 import re 5 import platform 3 6 4 7 def generate(env): 5 def SGlob(pattern): 6 path = env.GetBuildPath('SConscript').replace('SConscript', '') 7 return [ i.replace(path, '') for i in glob.glob(path + pattern) ] 8 9 def SGlob(pattern, excludedirs=[], recursive=False): 10 # always exclude .svn 11 excludedirs.append(".svn") 12 path = env.GetBuildPath('SConscript').replace('SConscript', '') 13 if recursive: 14 # remove '*' from pattern is accidentally specified 15 pattern=pattern.replace("*", "") 16 out = [] 17 for d, ld, fls in os.walk(path): 18 # remove directorys to be excluded 19 for exd in excludedirs: 20 if exd in ld: 21 ld.remove(exd) 22 for f in fls: 23 if f.endswith(pattern): 24 drel=d.replace(path,"") 25 out.append(os.path.join(drel,f)) 26 return out 27 else: 28 return [ i.replace(path, '') for i in glob.glob(path + pattern) ] 8 29 env.SGlob = SGlob 9 30 10 def AddCustomPath(path= ""):11 if not len(path)or not os.path.exists(path):12 return31 def AddCustomPath(path=None): 32 if path is None or not os.path.exists(path): 33 env.Exit(1) 13 34 env.PrependUnique(CPPPATH = [os.path.join(path, "include")]) 14 35 env.PrependUnique(LIBPATH = [os.path.join(path, "lib")]) … … 17 38 def AddCustomPackage(pkgname=None): 18 39 if pkgname is None: 19 20 21 22 23 24 25 26 27 28 else:29 30 31 32 33 34 35 36 37 38 39 40 41 42 40 return 41 pkgroot = env.get("%sroot" % pkgname, None) 42 pkgincd = env.get("%sincdir" % pkgname, None) 43 pkglibd = env.get("%slibdir" % pkgname, None) 44 incd = None 45 libd = None 46 if pkgroot is not None: 47 incd = os.path.join(pkgroot, "include") 48 libd = os.path.join(pkgroot, "lib") 49 else: 50 if pkgincd is not None: 51 incd = pkgincd 52 if pkglibd is not None: 53 libd = pkglibd 54 if incd is not None: 55 if not os.path.exists(incd): 56 print "Custom %s include dir '%s' not found" % (pkgname, incd) 57 env.Exit(1) 58 env.PrependUnique(CPPPATH = [incd]) 59 if libd is not None: 60 if not os.path.exists(libd): 61 print "Custom %s lib dir '%s' not found" % (pkgname, libd) 62 env.Exit(1) 63 env.PrependUnique(LIBPATH = [libd]) 43 64 44 65 env.AddCustomPackage = AddCustomPackage 45 66 67 def PlatformIdent(): 68 p = sys.platform 69 # replace the trailing 2 in linux2 70 p = re.sub(re.compile("2$"), "", p) 71 return p + "_" + platform.machine() 72 env.PlatformIdent = PlatformIdent 73 74 def MergeFlags(): 75 def _to_list(xf): 76 if xf.count(","): 77 return xf.split(",") 78 return xf.split() 79 80 xf=env.get("extracppflags", None) 81 if xf: 82 env.AppendUnique(CPPFLAGS=_to_list(xf)) 83 xf=env.get("extralinkflags", None) 84 if xf: 85 env.AppendUnique(LINKFLAGS=_to_list(xf)) 86 env.AppendUnique(SHLINKFLAGS=_to_list(xf)) 87 xf=env.get("extracxxflags", None) 88 if xf: 89 env.AppendUnique(CXXFLAGS=_to_list(xf)) 90 xf=env.get("extrafflags", None) 91 if xf: 92 env.AppendUnique(FORTRANFLAGS=_to_list(xf)) 93 env.AppendUnique(SHFORTRANFLAGS=_to_list(xf)) 94 xf=env.get("extracflags", None) 95 if xf: 96 env.AppendUnique(CCFLAGS=_to_list(xf)) 97 # set the extra flags if available 98 MergeFlags() 99 46 100 def CheckFortran(conf): 47 48 if not conf.env.has_key("FORTRAN"): 49 # auto-detect fortran 50 detect_fortran = conf.env.Detect(['gfortran', 'g77', 'f77']) 51 if not detect_fortran: 52 print "No fortran compiler found. Specify FORTRAN and f2clib." 53 conf.env.Exit(1) 54 conf.env["FORTRAN"] = detect_fortran 101 102 def getf2clib(fc): 55 103 fdict = {'gfortran': 'gfortran', 'g77': 'g2c', 'f77': 'f2c'} 56 f2clib = conf.env.get("f2clib", fdict[detect_fortran]) 57 if not conf.CheckLib(f2clib): 58 env.Exit(1) 59 else: 60 if not conf.env.has_key("f2clib"): 61 print "A custom fortran compiler also needs f2clib defined" 62 env.Exit(1) 63 else: 64 if not conf.CheckLib(env["f2clib"]): 65 env.Exit(1) 66 if conf.env["FORTRAN"].startswith("g77"): 104 return fdict[fc] 105 106 107 if not conf.env.has_key("FORTRAN"): 108 # auto-detect fortran 109 detect_fortran = conf.env.Detect(['gfortran', 'g77', 'f77']) 110 conf.env["FORTRAN"] = detect_fortran 111 f2clib = conf.env.get("f2clib", getf2clib(conf.env["FORTRAN"])) 112 if not conf.CheckLib(f2clib): 113 conf.env.Exit(1) 114 115 if conf.env["FORTRAN"].startswith("g77"): 67 116 fflags = ["-Wno-globals", "-fno-second-underscore"] 68 conf.env.Append(SHFORTRANFLAGS=fflags) 69 conf.env.Append(FORTRANFLAGS=fflags) 117 conf.env.AppendUnique(SHFORTRANFLAGS=fflags) 118 conf.env.AppendUnique(FORTRANFLAGS=fflags) 119 conf.env.AppendUnique(SHFORTRANFLAGS=['-fPIC']) 120 70 121 env.CheckFortran = CheckFortran 71 122 … … 84 135 env.WalkDirTree = WalkDirTree 85 136 137 86 138 def null_action(target, source, env): return 0 87 139
Note:
See TracChangeset
for help on using the changeset viewer.