ViewVC Help
View File | Revision Log | Show Annotations | Root Listing
root/JSOC/localize.py
(Generate patch)

Comparing localize.py (file contents):
Revision 1.3 by arta, Mon Nov 11 14:53:11 2013 UTC vs.
Revision 1.4 by arta, Mon Nov 11 15:40:14 2013 UTC

# Line 170 | Line 170 | def processMakeParam(mDefs, key, val, pl
170                  machDict[varMach] = {}
171              machDict[varMach][varName] = varValu
172  
173 < def processParam(cfgfile, line, regexpComm, regexpDefs, regexpMake, regexpQuote, regexp, keymap, defs, cDefs, mDefs, perlConstSection, perlInitSection, platDict, machDict, section):
173 > def processParam(cfgfile, line, regexpComm, regexpDefs, regexpMake, regexpQuote, regexp, keymap, defs, cDefs, mDefsGen, mDefsMake, perlConstSection, perlInitSection, platDict, machDict, section):
174      status = 0
175      
176      matchobj = regexpComm.match(line)
# Line 239 | Line 239 | def processParam(cfgfile, line, regexpCo
239                      raise Exception('paramNameTooLong', key)
240                  
241                  # Make file - val should never be quoted; just use as is
242 <                mDefs.extend(list('\n' + key + ' = ' + val))
242 >                mDefsGen.extend(list('\n' + key + ' = ' + val))
243                  
244                  # Perl file - val should ALWAYS be single-quote quoted
245                  # Save const info to a string
# Line 267 | Line 267 | def processParam(cfgfile, line, regexpCo
267  
268              # This information is for making make variables only. We do not need to worry about quoting any values
269              defs[key] = val
270 <            processMakeParam(mDefs, key, val, platDict, machDict)
270 >            processMakeParam(mDefsMake, key, val, platDict, machDict)
271      
272      return bool(0)
273  
274   # We have some extraneous line or a newline - ignore.
275  
276   # defs is a dictionary containing all parameters (should they be needed in this script)
277 < def parseConfig(fin, keymap, addenda, defs, cDefs, mDefs, perlConstSection, perlInitSection):
277 > def parseConfig(fin, keymap, addenda, defs, cDefs, mDefsGen, mDefsMake, perlConstSection, perlInitSection):
278      rv = bool(0)
279      
280      # Open required config file (config.local)
# Line 294 | Line 294 | def parseConfig(fin, keymap, addenda, de
294          iscfg = bool(1)
295          if not fin is None:
296              for line in fin:
297 <                ppRet = processParam(iscfg, line, regexpComm, regexpDefs, regexpMake, regexpQuote, regexp, keymap, defs, cDefs, mDefs, perlConstSection, perlInitSection, platDict, machDict, section)
297 >                ppRet = processParam(iscfg, line, regexpComm, regexpDefs, regexpMake, regexpQuote, regexp, keymap, defs, cDefs, mDefsGen, mDefsMake, perlConstSection, perlInitSection, platDict, machDict, section)
298                  if ppRet:
299                      break;
300              
# Line 303 | Line 303 | def parseConfig(fin, keymap, addenda, de
303          iscfg = bool(0)
304          for key in addenda:
305              item = key + ' ' + addenda[key]
306 <            ppRet = processParam(iscfg, item, regexpComm, regexpDefs, regexpMake, regexpQuote, regexp, keymap, defs, cDefs, mDefs, perlConstSection, perlInitSection, platDict, machDict, section)
306 >            ppRet = processParam(iscfg, item, regexpComm, regexpDefs, regexpMake, regexpQuote, regexp, keymap, defs, cDefs, mDefsGen, mDefsMake, perlConstSection, perlInitSection, platDict, machDict, section)
307              if ppRet:
308                  break;
309      except Exception as exc:
# Line 328 | Line 328 | def parseConfig(fin, keymap, addenda, de
328              # re-raise the exception
329              raise
330  
331 <    # Put information collected in platDict and machDict into mDefs
331 >    # Put information collected in platDict and machDict into mDefs. Must do this here, and not in processParam, since
332 >    # we need to parse all platform-specific make variables before grouping them into platform categories.
333      if not rv:
334          for plat in platDict:
335 <            mDefs.extend(list('\nifeq ($(JSOC_MACHINE), linux_' + plat.lower() + ')'))
335 >            mDefsMake.extend(list('\nifeq ($(JSOC_MACHINE), linux_' + plat.lower() + ')'))
336              for var in platDict[plat]:
337 <                mDefs.extend(list('\n' + var + ' = ' + platDict[plat][var]))
338 <            mDefs.extend(list('\nendif\n'))
337 >                mDefsMake.extend(list('\n' + var + ' = ' + platDict[plat][var]))
338 >            mDefsMake.extend(list('\nendif\n'))
339                              
340      if not rv:
341          for mach in machDict:
342 <            mDefs.extend(list('\nifeq ($(MACHTYPE), ' + mach + ')'))
342 >            mDefsMake.extend(list('\nifeq ($(MACHTYPE), ' + mach + ')'))
343              for var in platDict[plat]:
344 <                mDefs.extend(list('\n' + var + ' = ' + platDict[plat][var]))
345 <            mDefs.extend(list('\nendif\n'))
344 >                mDefsMake.extend(list('\n' + var + ' = ' + platDict[plat][var]))
345 >            mDefsMake.extend(list('\nendif\n'))
346                              
347      return rv
348  
# Line 483 | Line 484 | def configureComps(defs, mDefs):
484  
485      return rv
486  
487 < def writeFiles(base, cfile, mfile, pfile, cDefs, mDefs, perlConstSection, perlInitSection):
487 > def writeFiles(base, cfile, mfile, pfile, cDefs, mDefsGen, mDefsMake, mDefsComps, perlConstSection, perlInitSection):
488      rv = bool(0)
489 +
490 +    # Merge mDefsGen, mDefsMake, and mDefsComps into a single string with compiler configuration first, general parameters next, then
491 +    # make-specific make variables (e.g., third-party library information) last.
492 +    mDefs = '\n# Compiler Selection\n' + ''.join(mDefsComps) + '\n\n# General Parameters\n' + ''.join(mDefsGen) + '\n\n# Parameters to Configure make\n' + ''.join(mDefsMake)
493      
494      try:
495          with open(cfile, 'w') as cout, open(mfile, 'w') as mout, open(pfile, 'w') as pout:
# Line 499 | Line 504 | def writeFiles(base, cfile, mfile, pfile
504              
505              # Make file of make variables
506              print(PREFIX, file=mout)
507 <            print('# This file contains a set of make-variable values - one for each configuration parameter.', file=mout)
508 <            print(''.join(mDefs), file=mout)
507 >            print('# This file contains a set of make-variable values. The first section contains compiler-selection variables, the second contains general configuration variables, and the third section contains variables that configure how make is run.', file=mout)
508 >            print(mDefs, file=mout)
509              
510              # Perl module
511              print(PERL_BINPATH, file=pout)
# Line 529 | Line 534 | def configureNet(cfgfile, cfile, mfile,
534      defs = {}
535      cDefs = list()
536      mDefs = list()
537 +    mDefsGen = list()
538 +    mDefsMake = list()
539 +    mDefsComps = list()
540      perlConstSection = list()
541      perlInitSection = list()
542      addenda = {}
# Line 545 | Line 553 | def configureNet(cfgfile, cfile, mfile,
553      try:
554          with open(cfgfile, 'r') as fin:
555              # Process configuration parameters
556 <            rv = parseConfig(fin, keymap, addenda, defs, cDefs, mDefs, perlConstSection, perlInitSection)
556 >            rv = parseConfig(fin, keymap, addenda, defs, cDefs, mDefsGen, mDefsMake, perlConstSection, perlInitSection)
557              if rv == bool(0):
558                  # Must add a parameter for the SUMS_MANAGER UID (for some reason). This must be done after the
559                  # config file is processed since an input to getMgrUIDLine() is one of the config file's
# Line 553 | Line 561 | def configureNet(cfgfile, cfile, mfile,
561                  uidParam = {}
562                  rv = getMgrUIDLine(defs, uidParam)
563                  if rv == bool(0):
564 <                    rv = parseConfig(None, keymap, uidParam, defs, cDefs, mDefs, perlConstSection, perlInitSection)
564 >                    rv = parseConfig(None, keymap, uidParam, defs, cDefs, mDefsGen, None, perlConstSection, perlInitSection)
565                  
566              # Configure the compiler-selection make variables.
567              if rv == bool(0):
568 <                rv = configureComps(defs, mDefs)
568 >                rv = configureComps(defs, mDefsComps)
569  
570              # Write out the parameter files.
571              if rv == bool(0):
572 <                rv = writeFiles(base, cfile, mfile, pfile, cDefs, mDefs, perlConstSection, perlInitSection)
572 >                rv = writeFiles(base, cfile, mfile, pfile, cDefs, mDefsGen, mDefsMake, mDefsComps, perlConstSection, perlInitSection)
573      except IOError as exc:
574          sys.stderr.write(exc.strerror)
575          sys.stderr.write('Unable to read configuration file ' + cfgfile + '.')

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines