ViewVC Help
View File | Revision Log | Show Annotations | Download File | Root Listing
root/radiance/ray/build_utils/load_plat.py
Revision: 1.2
Committed: Mon Oct 27 10:35:41 2003 UTC (20 years, 5 months ago) by schorsch
Content type: text/x-python
Branch: MAIN
Changes since 1.1: +12 -9 lines
Log Message:
Experimental SCons update: Debug builds, split libraries, more Windows targets.

File Contents

# Content
1
2 import os
3 import sys
4 import string
5 import ConfigParser
6
7
8 _platdir = 'platform'
9
10
11 def POSIX_setup(env):
12 # common stuff for all posix systems
13 env['RAD_PROCESS'] = string.split('unix_process.c')
14
15
16 def read_plat(env, args, fn):
17 cfig = ConfigParser.ConfigParser(env.Dictionary())
18 cfig.read(fn)
19 buildvars = [['CC'], # replace
20 ['CPPPATH','CPPFLAGS','CCFLAGS','LIBPATH','LINKFLAGS']] # append
21 vars = [
22 ['install',
23 ['RAD_BASEDIR', 'RAD_BINDIR', 'RAD_RLIBDIR', 'RAD_MANDIR'],
24 []],
25 ['code',
26 ['RAD_SPEED'],
27 ['RAD_COMPAT', 'RAD_MEMCOMPAT', 'RAD_MATHCOMPAT', 'RAD_ARGSCOMPAT',
28 'RAD_MLIB', 'RAD_PROCESS']],
29 ]
30 if args.get('RAD_DEBUG',0):
31 vars.insert(0, ['debug'] + buildvars)
32 else: vars.insert(0, ['build'] + buildvars)
33 for section in vars:
34 if cfig.has_section(section[0]):
35 for p in section[1]:
36 try: v = cfig.get(section[0], p)
37 except ConfigParser.NoOptionError: continue
38 env[p] = v
39 #print '%s: %s' % (p, env[p])
40 for p in section[2]:
41 try: v = cfig.get(section[0], p)
42 except ConfigParser.NoOptionError: continue
43 apply(env.Append,[],{p:string.split(v)})
44 #print '%s: %s' % (p, env[p])
45 # 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 def load_plat(env, args, platform=None):
53 if os.name == 'posix':
54 POSIX_setup(env)
55 if platform == None: # override
56 p = sys.platform
57 else: p = platform
58 pl = []
59 print 'Detected platform "%s" (%s).' % (sys.platform, os.name)
60 for i in [len(p), -1, -2]:
61 pfn = os.path.join(_platdir, p[:i] + '_custom.cfg')
62 if os.path.isfile(pfn):
63 print 'Reading configuration "%s"' % pfn
64 read_plat(env, args, pfn)
65 return 1
66 pfn = os.path.join(_platdir, p[:i] + '.cfg')
67 if os.path.isfile(pfn):
68 print 'Reading configuration "%s"' % pfn
69 read_plat(env, args, pfn)
70 return 1
71
72 if os.name == 'posix':
73 pfn = os.path.join(_platdir, 'posix.cfg')
74 if os.path.isfile(pfn):
75 print 'Reading generic configuration "%s".' % pfn
76 read_plat(env, args, pfn)
77 return 1
78
79 print 'Platform "%s/%s" not supported yet' % (os.name, sys.platform)
80 sys.exit(2)
81
82
83