ViewVC Help
View File | Revision Log | Show Annotations | Download File | Root Listing
root/radiance/ray/build_utils/load_plat.py
Revision: 1.4
Committed: Mon Sep 12 11:32:30 2005 UTC (18 years, 7 months ago) by schorsch
Content type: text/x-python
Branch: MAIN
Changes since 1.3: +3 -0 lines
Log Message:
Special case testing for mingw.

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