ViewVC Help
View File | Revision Log | Show Annotations | Download File | Root Listing
root/radiance/ray/build_utils/load_plat.py
(Generate patch)

Comparing ray/build_utils/load_plat.py (file contents):
Revision 1.18 by schorsch, Tue Apr 19 21:21:23 2016 UTC vs.
Revision 1.19 by schorsch, Mon Jan 8 13:38:37 2018 UTC

# Line 1 | Line 1
1 < from __future__ import print_function
1 > from __future__ import division, print_function, unicode_literals
2  
3   import os
4   import sys
5   import re
6   import platform
7 < import ConfigParser
7 > try: import configparser # Py3
8 > except ImportError:
9 >        import ConfigParser as configparser # Py2
10  
9
11   _platdir = 'platform'
12  
13  
14   def read_plat(env, fn):
15          envdict = env.Dictionary().copy()
16 <        # can't feed ConfigParser the original dict, because it also
16 >        # can't feed configparser the original dict, because it also
17          # contains non-string values.
18 <        for k,v in envdict.items():
18 >        for k,v in list(envdict.items()): # make a list, so we can change the dict.
19                  if not isinstance(v, str):
20                          del envdict[k]
21 <        cfig = ConfigParser.ConfigParser(envdict)
21 >        cfig = configparser.ConfigParser(envdict)
22          cfig.read(fn)
23          buildvars = [['CC',
24                          'TIFFINCLUDE', # where to find preinstalled tifflib headers
# Line 55 | Line 56 | def read_plat(env, fn):
56                  if cfig.has_section(section[0]):
57                          for p in section[1]: # single items to replace
58                                  try: v = cfig.get(section[0], p)
59 <                                except ConfigParser.NoOptionError: continue
60 <                                if section[0] in ('install','build','debug') and '{' in v:
61 <                                        v = subst_osenvvars(v)
59 >                                except configparser.NoOptionError: continue
60 >                                if section[0] in ('install','build','debug'):
61 >                                        if '{' in v:
62 >                                                v = subst_sysenvvars(v, env)
63                                  env[p] = v
64                                  #print('%s: %s' % (p, env[p]))
65                          for p in section[2]: # multiple items to append
# Line 66 | Line 68 | def read_plat(env, fn):
68                                          if section[0] in ('build','debug') and '{' in v:
69                                                  v = subst_sconsvars(v, env)
70                                          #print('%s: %s - %s' % (section[0], p, v))
71 <                                except ConfigParser.NoOptionError: continue
72 <                                apply(env.Append,[],{p:env.Split(v)})
73 <        # XXX Check that basedir exists.
71 >                                except configparser.NoOptionError: continue
72 >                                env.Append(*[], **{p:env.Split(v)})
73 >                                #apply(env.Append,[],{p:env.Split(v)})
74 >
75 > def combine_instpaths(env):
76 >        # XXX Check that basedir exists?
77          for k in ['RAD_BINDIR', 'RAD_RLIBDIR', 'RAD_MANDIR']:
78                  if (env.has_key('RAD_BASEDIR') and env.has_key(k)
79                                  and not os.path.isabs(env[k])):
80                          env[k] = os.path.join(env['RAD_BASEDIR'],env[k])
81  
82 < def subst_osenvvars(s):
82 >
83 >
84 > def subst_sysenvvars(s, env):
85          try: return s.format(**os.environ)
86          except KeyError: return s
87  
# Line 94 | Line 101 | def subst_sconsvars(s, env,
101                  nl.append(ss)
102          return ''.join(nl)
103  
104 < def load_plat(env):
104 >
105 > def identify_plat(env):
106          memmodel, binformat = platform.architecture()
99        # XXX env['TARGET_ARCH'] --> memmodel
107          platsys = platform.system()
108          print('Detected platform "%s" (%s).' % (platsys, memmodel))
109          cfgname = platsys + '_' + memmodel[:2]
110 +        env['CFG_PLATSYS'] = platsys
111 +        env['CFG_MEMMODEL'] = memmodel[:2]
112 +        env['CFG_PATHFILE'] = os.path.join('#scbuild', cfgname, 'install_paths.py')
113 +        env['CFG_OPTFILE']  = os.path.join('#scbuild', cfgname, 'build_opts.py')
114  
115 +
116 + def load_plat(env, testenv):
117 +        platsys = testenv['CFG_PLATSYS']
118 +        memmodel = testenv['CFG_MEMMODEL']
119 +        cfgname = platsys + '_' + memmodel[:2]
120 +
121          env['RAD_BUILDBIN'] = os.path.join('#scbuild', cfgname, 'bin')
122 <        env['RAD_BUILDLIB']  = os.path.join('#scbuild', cfgname, 'lib')
123 <        env['RAD_BUILDOBJ']  = os.path.join('#scbuild', cfgname, 'obj')
122 >        env['RAD_BUILDLIB'] = os.path.join('#scbuild', cfgname, 'lib')
123 >        env['RAD_BUILDOBJ'] = os.path.join('#scbuild', cfgname, 'obj')
124  
125          cust_pfn = os.path.join(_platdir, cfgname + '_custom.cfg')
126          if os.path.isfile(cust_pfn):
# Line 128 | Line 145 | def load_plat(env):
145                          % (os.name, sys.platform))
146          sys.exit(2)
147  
148 <        
132 <        
148 > # vi: set ts=4 sw=4 :

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines