| 1 |
|
|
| 2 |
|
import os |
| 3 |
|
import sys |
| 4 |
– |
import string |
| 4 |
|
import ConfigParser |
| 5 |
|
|
| 6 |
|
|
| 7 |
|
_platdir = 'platform' |
| 8 |
|
|
| 9 |
|
|
| 10 |
< |
def POSIX_setup(env): |
| 11 |
< |
# common stuff for all posix systems |
| 12 |
< |
env['RAD_PROCESS'] = string.split('unix_process.c') |
| 13 |
< |
|
| 14 |
< |
|
| 15 |
< |
def read_plat(env, fn): |
| 16 |
< |
cfig = ConfigParser.ConfigParser(env.Dictionary()) |
| 10 |
> |
def read_plat(env, args, fn): |
| 11 |
> |
envdict = env.Dictionary().copy() |
| 12 |
> |
# can't feed ConfigParser the original dict, because it also |
| 13 |
> |
# contains non-string values. |
| 14 |
> |
for k,v in envdict.items(): |
| 15 |
> |
if not isinstance(v, str): |
| 16 |
> |
del envdict[k] |
| 17 |
> |
cfig = ConfigParser.ConfigParser(envdict) |
| 18 |
|
cfig.read(fn) |
| 19 |
+ |
buildvars = [['CC', |
| 20 |
+ |
'TIFFINCLUDE', # where to find preinstalled tifflib headers |
| 21 |
+ |
'TIFFLIB', # where to find a preinstalled tifflib library |
| 22 |
+ |
], # replace |
| 23 |
+ |
['CPPPATH', 'CPPDEFINES', 'CPPFLAGS', 'CCFLAGS', |
| 24 |
+ |
'LIBPATH', 'LINKFLAGS', |
| 25 |
+ |
'EZXML_CPPDEFINES', # build flags specific to ezxml.c |
| 26 |
+ |
]] # append |
| 27 |
|
vars = [ |
| 20 |
– |
['build', |
| 21 |
– |
['CC'], # replace |
| 22 |
– |
['CPPFLAGS', 'CCFLAGS', 'CPPPATH', 'LIBPATH']], # append |
| 28 |
|
['install', |
| 29 |
|
['RAD_BASEDIR', 'RAD_BINDIR', 'RAD_RLIBDIR', 'RAD_MANDIR'], |
| 30 |
|
[]], |
| 31 |
|
['code', |
| 32 |
< |
['RAD_SPEED'], |
| 33 |
< |
['RAD_COMPAT', 'RAD_MLIB', 'RAD_PROCESS']], |
| 32 |
> |
[ # replace |
| 33 |
> |
], |
| 34 |
> |
[ # append |
| 35 |
> |
'RAD_COMPAT', # theoretically obsolete (src/common/strcmp.c) |
| 36 |
> |
'RAD_MATHCOMPAT', # erf.c floating point error function |
| 37 |
> |
'RAD_ARGSCOMPAT', # fixargv0.c for Windows |
| 38 |
> |
'RAD_NETCOMPAT', # [win_]netproc.c for ranimate |
| 39 |
> |
'RAD_MLIB', # usually 'm', or any fastlib available |
| 40 |
> |
'RAD_SOCKETLIB', # ws_2_32 on Windows (VC links it automatically) |
| 41 |
> |
'RAD_PROCESS', # our process abstraction and win_popen() |
| 42 |
> |
'RAD_PCALLS', # more custom process abstraction |
| 43 |
> |
]], |
| 44 |
|
] |
| 45 |
+ |
if args.get('RAD_DEBUG',0): |
| 46 |
+ |
vars.insert(0, ['debug'] + buildvars) |
| 47 |
+ |
else: vars.insert(0, ['build'] + buildvars) |
| 48 |
|
for section in vars: |
| 49 |
|
if cfig.has_section(section[0]): |
| 50 |
< |
for p in section[1]: |
| 50 |
> |
for p in section[1]: # single items to replace |
| 51 |
|
try: v = cfig.get(section[0], p) |
| 52 |
|
except ConfigParser.NoOptionError: continue |
| 53 |
|
env[p] = v |
| 54 |
|
#print '%s: %s' % (p, env[p]) |
| 55 |
< |
for p in section[2]: |
| 55 |
> |
for p in section[2]: # multiple items to append |
| 56 |
|
try: v = cfig.get(section[0], p) |
| 57 |
|
except ConfigParser.NoOptionError: continue |
| 58 |
< |
apply(env.Append,[],{p:string.split(v)}) |
| 41 |
< |
#print '%s: %s' % (p, env[p]) |
| 58 |
> |
apply(env.Append,[],{p:env.Split(v)}) |
| 59 |
|
# XXX Check that basedir exists. |
| 60 |
|
for k in ['RAD_BINDIR', 'RAD_RLIBDIR', 'RAD_MANDIR']: |
| 61 |
|
if (env.has_key('RAD_BASEDIR') and env.has_key(k) |
| 63 |
|
env[k] = os.path.join(env['RAD_BASEDIR'],env[k]) |
| 64 |
|
|
| 65 |
|
|
| 66 |
< |
def load_plat(env, platform=None): |
| 50 |
< |
if os.name == 'posix': |
| 51 |
< |
POSIX_setup(env) |
| 66 |
> |
def load_plat(env, args, platform=None): |
| 67 |
|
if platform == None: # override |
| 68 |
|
p = sys.platform |
| 69 |
|
else: p = platform |
| 70 |
+ |
if p == 'win32' and 'gcc' in env['TOOLS']: |
| 71 |
+ |
# we don't really want to know this here... |
| 72 |
+ |
p = 'mingw' |
| 73 |
|
pl = [] |
| 74 |
|
print 'Detected platform "%s" (%s).' % (sys.platform, os.name) |
| 75 |
|
for i in [len(p), -1, -2]: |
| 76 |
|
pfn = os.path.join(_platdir, p[:i] + '_custom.cfg') |
| 77 |
|
if os.path.isfile(pfn): |
| 78 |
|
print 'Reading configuration "%s"' % pfn |
| 79 |
< |
read_plat(env, pfn) |
| 79 |
> |
read_plat(env, args, pfn) |
| 80 |
|
return 1 |
| 81 |
|
pfn = os.path.join(_platdir, p[:i] + '.cfg') |
| 82 |
|
if os.path.isfile(pfn): |
| 83 |
|
print 'Reading configuration "%s"' % pfn |
| 84 |
< |
read_plat(env, pfn) |
| 84 |
> |
read_plat(env, args, pfn) |
| 85 |
|
return 1 |
| 86 |
|
|
| 87 |
|
if os.name == 'posix': |
| 88 |
|
pfn = os.path.join(_platdir, 'posix.cfg') |
| 89 |
|
if os.path.isfile(pfn): |
| 90 |
|
print 'Reading generic configuration "%s".' % pfn |
| 91 |
< |
read_plat(env, pfn) |
| 91 |
> |
read_plat(env, args, pfn) |
| 92 |
|
return 1 |
| 93 |
|
|
| 94 |
|
print 'Platform "%s/%s" not supported yet' % (os.name, sys.platform) |