ViewVC Help
View File | Revision Log | Show Annotations | Download File | Root Listing
root/radiance/ray/build_utils/load_plat.py
Revision: 1.10
Committed: Mon Apr 21 07:31:27 2008 UTC (16 years ago) by schorsch
Content type: text/x-python
Branch: MAIN
Changes since 1.9: +3 -1 lines
Log Message:
Scons update for mingw.

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