ViewVC Help
View File | Revision Log | Show Annotations | Download File | Root Listing
root/radiance/ray/build_utils/load_plat.py
Revision: 1.1
Committed: Tue Oct 21 19:27:28 2003 UTC (20 years, 6 months ago) by schorsch
Content type: text/x-python
Branch: MAIN
Log Message:
Checking in experimental SCons build environment.

File Contents

# User Rev Content
1 schorsch 1.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, fn):
17     cfig = ConfigParser.ConfigParser(env.Dictionary())
18     cfig.read(fn)
19     vars = [
20     ['build',
21     ['CC'], # replace
22     ['CPPFLAGS', 'CCFLAGS', 'CPPPATH', 'LIBPATH']], # append
23     ['install',
24     ['RAD_BASEDIR', 'RAD_BINDIR', 'RAD_RLIBDIR', 'RAD_MANDIR'],
25     []],
26     ['code',
27     ['RAD_SPEED'],
28     ['RAD_COMPAT', 'RAD_MLIB', 'RAD_PROCESS']],
29     ]
30     for section in vars:
31     if cfig.has_section(section[0]):
32     for p in section[1]:
33     try: v = cfig.get(section[0], p)
34     except ConfigParser.NoOptionError: continue
35     env[p] = v
36     #print '%s: %s' % (p, env[p])
37     for p in section[2]:
38     try: v = cfig.get(section[0], p)
39     except ConfigParser.NoOptionError: continue
40     apply(env.Append,[],{p:string.split(v)})
41     #print '%s: %s' % (p, env[p])
42     # XXX Check that basedir exists.
43     for k in ['RAD_BINDIR', 'RAD_RLIBDIR', 'RAD_MANDIR']:
44     if (env.has_key('RAD_BASEDIR') and env.has_key(k)
45     and not os.path.isabs(env[k])):
46     env[k] = os.path.join(env['RAD_BASEDIR'],env[k])
47    
48    
49     def load_plat(env, platform=None):
50     if os.name == 'posix':
51     POSIX_setup(env)
52     if platform == None: # override
53     p = sys.platform
54     else: p = platform
55     pl = []
56     print 'Detected platform "%s" (%s).' % (sys.platform, os.name)
57     for i in [len(p), -1, -2]:
58     pfn = os.path.join(_platdir, p[:i] + '_custom.cfg')
59     if os.path.isfile(pfn):
60     print 'Reading configuration "%s"' % pfn
61     read_plat(env, pfn)
62     return 1
63     pfn = os.path.join(_platdir, p[:i] + '.cfg')
64     if os.path.isfile(pfn):
65     print 'Reading configuration "%s"' % pfn
66     read_plat(env, pfn)
67     return 1
68    
69     if os.name == 'posix':
70     pfn = os.path.join(_platdir, 'posix.cfg')
71     if os.path.isfile(pfn):
72     print 'Reading generic configuration "%s".' % pfn
73     read_plat(env, pfn)
74     return 1
75    
76     print 'Platform "%s/%s" not supported yet' % (os.name, sys.platform)
77     sys.exit(2)
78    
79    
80