ViewVC Help
View File | Revision Log | Show Annotations | Download File | Root Listing
root/radiance/ray/build_utils/load_plat.py
Revision: 1.11
Committed: Thu Apr 24 10:28:24 2008 UTC (15 years, 11 months ago) by schorsch
Content type: text/x-python
Branch: MAIN
CVS Tags: rad3R9
Changes since 1.10: +4 -2 lines
Log Message:
More fixes for mingw build/install.

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