ViewVC Help
View File | Revision Log | Show Annotations | Download File | Root Listing
root/radiance/ray/build_utils/load_plat.py
Revision: 1.9
Committed: Wed Jun 7 12:25:36 2006 UTC (17 years, 10 months ago) by schorsch
Content type: text/x-python
Branch: MAIN
CVS Tags: rad3R8
Changes since 1.8: +1 -2 lines
Log Message:
Fixed the Python2.4 fix to work with older versions again.

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     'RAD_PROCESS']], # our process abstraction and win_popen()
30 schorsch 1.1 ]
31 schorsch 1.2 if args.get('RAD_DEBUG',0):
32     vars.insert(0, ['debug'] + buildvars)
33     else: vars.insert(0, ['build'] + buildvars)
34 schorsch 1.1 for section in vars:
35     if cfig.has_section(section[0]):
36 schorsch 1.7 for p in section[1]: # single items to replace
37 schorsch 1.1 try: v = cfig.get(section[0], p)
38     except ConfigParser.NoOptionError: continue
39     env[p] = v
40     #print '%s: %s' % (p, env[p])
41 schorsch 1.7 for p in section[2]: # multiple items to append
42 schorsch 1.1 try: v = cfig.get(section[0], p)
43     except ConfigParser.NoOptionError: continue
44 schorsch 1.9 apply(env.Append,[],{p:env.Split(v)})
45 schorsch 1.1 # XXX Check that basedir exists.
46     for k in ['RAD_BINDIR', 'RAD_RLIBDIR', 'RAD_MANDIR']:
47     if (env.has_key('RAD_BASEDIR') and env.has_key(k)
48     and not os.path.isabs(env[k])):
49     env[k] = os.path.join(env['RAD_BASEDIR'],env[k])
50    
51    
52 schorsch 1.2 def load_plat(env, args, platform=None):
53 schorsch 1.1 if platform == None: # override
54     p = sys.platform
55     else: p = platform
56 schorsch 1.4 if p == 'win32' and 'gcc' in env['TOOLS']:
57 schorsch 1.7 # we don't really want to know this here...
58 schorsch 1.4 p = 'mingw'
59 schorsch 1.1 pl = []
60     print 'Detected platform "%s" (%s).' % (sys.platform, os.name)
61     for i in [len(p), -1, -2]:
62     pfn = os.path.join(_platdir, p[:i] + '_custom.cfg')
63     if os.path.isfile(pfn):
64     print 'Reading configuration "%s"' % pfn
65 schorsch 1.2 read_plat(env, args, pfn)
66 schorsch 1.1 return 1
67     pfn = os.path.join(_platdir, p[:i] + '.cfg')
68     if os.path.isfile(pfn):
69     print 'Reading configuration "%s"' % pfn
70 schorsch 1.2 read_plat(env, args, pfn)
71 schorsch 1.1 return 1
72    
73     if os.name == 'posix':
74     pfn = os.path.join(_platdir, 'posix.cfg')
75     if os.path.isfile(pfn):
76     print 'Reading generic configuration "%s".' % pfn
77 schorsch 1.2 read_plat(env, args, pfn)
78 schorsch 1.1 return 1
79    
80     print 'Platform "%s/%s" not supported yet' % (os.name, sys.platform)
81     sys.exit(2)
82    
83    
84