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

# Content
1
2 import os
3 import sys
4 import ConfigParser
5
6
7 _platdir = 'platform'
8
9
10 def read_plat(env, args, fn):
11 cfig = ConfigParser.ConfigParser(env.Dictionary())
12 cfig.read(fn)
13 buildvars = [['CC'], # replace
14 ['CPPPATH', 'CPPDEFINES', 'CPPFLAGS', 'CCFLAGS',
15 'LIBPATH', 'LINKFLAGS',
16 'EZXML_CPPDEFINES', # build flags specific to ezxml.c
17 ]] # append
18 vars = [
19 ['install',
20 ['RAD_BASEDIR', 'RAD_BINDIR', 'RAD_RLIBDIR', 'RAD_MANDIR'],
21 []],
22 ['code',
23 [], # replace
24 [ # append
25 'RAD_COMPAT', # theoretically obsolete (src/common/strcmp.c)
26 '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 'RAD_PROCESS', # our process abstraction and win_popen()
32 'RAD_PCALLS', # more custom process abstraction
33 ]],
34 ]
35 if args.get('RAD_DEBUG',0):
36 vars.insert(0, ['debug'] + buildvars)
37 else: vars.insert(0, ['build'] + buildvars)
38 for section in vars:
39 if cfig.has_section(section[0]):
40 for p in section[1]: # single items to replace
41 try: v = cfig.get(section[0], p)
42 except ConfigParser.NoOptionError: continue
43 env[p] = v
44 #print '%s: %s' % (p, env[p])
45 for p in section[2]: # multiple items to append
46 try: v = cfig.get(section[0], p)
47 except ConfigParser.NoOptionError: continue
48 apply(env.Append,[],{p:env.Split(v)})
49 # 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 def load_plat(env, args, platform=None):
57 if platform == None: # override
58 p = sys.platform
59 else: p = platform
60 if p == 'win32' and 'gcc' in env['TOOLS']:
61 # we don't really want to know this here...
62 p = 'mingw'
63 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 read_plat(env, args, pfn)
70 return 1
71 pfn = os.path.join(_platdir, p[:i] + '.cfg')
72 if os.path.isfile(pfn):
73 print 'Reading configuration "%s"' % pfn
74 read_plat(env, args, pfn)
75 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 read_plat(env, args, pfn)
82 return 1
83
84 print 'Platform "%s/%s" not supported yet' % (os.name, sys.platform)
85 sys.exit(2)
86
87
88