ViewVC Help
View File | Revision Log | Show Annotations | Download File | Root Listing
root/radiance/ray/build_utils/load_plat.py
Revision: 1.12
Committed: Tue Dec 23 15:03:59 2008 UTC (15 years, 4 months ago) by schorsch
Content type: text/x-python
Branch: MAIN
CVS Tags: rad4R2P2, rad5R0, rad4R2, rad4R1, rad4R0, rad4R2P1
Changes since 1.11: +6 -2 lines
Log Message:
SCons now uses installed libtiff, if a compatible one is available. Added platform/README to explain config files.

File Contents

# User Rev Content
1 schorsch 1.1
2     import os
3     import sys
4     import ConfigParser
5    
6    
7     _platdir = 'platform'
8    
9    
10 schorsch 1.2 def read_plat(env, args, fn):
11 schorsch 1.1 cfig = ConfigParser.ConfigParser(env.Dictionary())
12     cfig.read(fn)
13 schorsch 1.12 buildvars = [['CC',
14     'TIFFINCLUDE', # where to find preinstalled tifflib headers
15     'TIFFLIB', # where to find a preinstalled tifflib library
16     ], # replace
17 schorsch 1.3 ['CPPPATH', 'CPPDEFINES', 'CPPFLAGS', 'CCFLAGS',
18 schorsch 1.11 'LIBPATH', 'LINKFLAGS',
19     'EZXML_CPPDEFINES', # build flags specific to ezxml.c
20     ]] # append
21 schorsch 1.1 vars = [
22     ['install',
23     ['RAD_BASEDIR', 'RAD_BINDIR', 'RAD_RLIBDIR', 'RAD_MANDIR'],
24     []],
25     ['code',
26 schorsch 1.12 [ # replace
27     ],
28 schorsch 1.7 [ # append
29 schorsch 1.11 'RAD_COMPAT', # theoretically obsolete (src/common/strcmp.c)
30 schorsch 1.7 'RAD_MATHCOMPAT', # erf.c floating point error function
31     'RAD_ARGSCOMPAT', # fixargv0.c for Windows
32     'RAD_NETCOMPAT', # [win_]netproc.c for ranimate
33     'RAD_MLIB', # usually 'm', or any fastlib available
34     'RAD_SOCKETLIB', # ws_2_32 on Windows (VC links it automatically)
35 schorsch 1.10 'RAD_PROCESS', # our process abstraction and win_popen()
36     'RAD_PCALLS', # more custom process abstraction
37     ]],
38 schorsch 1.1 ]
39 schorsch 1.2 if args.get('RAD_DEBUG',0):
40     vars.insert(0, ['debug'] + buildvars)
41     else: vars.insert(0, ['build'] + buildvars)
42 schorsch 1.1 for section in vars:
43     if cfig.has_section(section[0]):
44 schorsch 1.7 for p in section[1]: # single items to replace
45 schorsch 1.1 try: v = cfig.get(section[0], p)
46     except ConfigParser.NoOptionError: continue
47     env[p] = v
48     #print '%s: %s' % (p, env[p])
49 schorsch 1.7 for p in section[2]: # multiple items to append
50 schorsch 1.1 try: v = cfig.get(section[0], p)
51     except ConfigParser.NoOptionError: continue
52 schorsch 1.9 apply(env.Append,[],{p:env.Split(v)})
53 schorsch 1.1 # XXX Check that basedir exists.
54     for k in ['RAD_BINDIR', 'RAD_RLIBDIR', 'RAD_MANDIR']:
55     if (env.has_key('RAD_BASEDIR') and env.has_key(k)
56     and not os.path.isabs(env[k])):
57     env[k] = os.path.join(env['RAD_BASEDIR'],env[k])
58    
59    
60 schorsch 1.2 def load_plat(env, args, platform=None):
61 schorsch 1.1 if platform == None: # override
62     p = sys.platform
63     else: p = platform
64 schorsch 1.4 if p == 'win32' and 'gcc' in env['TOOLS']:
65 schorsch 1.7 # we don't really want to know this here...
66 schorsch 1.4 p = 'mingw'
67 schorsch 1.1 pl = []
68     print 'Detected platform "%s" (%s).' % (sys.platform, os.name)
69     for i in [len(p), -1, -2]:
70     pfn = os.path.join(_platdir, p[:i] + '_custom.cfg')
71     if os.path.isfile(pfn):
72     print 'Reading configuration "%s"' % pfn
73 schorsch 1.2 read_plat(env, args, pfn)
74 schorsch 1.1 return 1
75     pfn = os.path.join(_platdir, p[:i] + '.cfg')
76     if os.path.isfile(pfn):
77     print 'Reading configuration "%s"' % pfn
78 schorsch 1.2 read_plat(env, args, pfn)
79 schorsch 1.1 return 1
80    
81     if os.name == 'posix':
82     pfn = os.path.join(_platdir, 'posix.cfg')
83     if os.path.isfile(pfn):
84     print 'Reading generic configuration "%s".' % pfn
85 schorsch 1.2 read_plat(env, args, pfn)
86 schorsch 1.1 return 1
87    
88     print 'Platform "%s/%s" not supported yet' % (os.name, sys.platform)
89     sys.exit(2)
90    
91    
92