(file) Return to localize.py CVS log (file) (dir) Up to [Development] / JSOC

Diff for /JSOC/localize.py between version 1.5 and 1.11

version 1.5, 2013/11/11 17:34:54 version 1.11, 2013/11/19 23:41:02
Line 1 
Line 1 
 #!/home/jsoc/bin/linux_x86_64/activepython #!/home/jsoc/bin/linux_x86_64/activepython
  
 import os.path  
 import sys import sys
 import getopt import getopt
 import re import re
   import os
   import stat
   import xml.etree.ElementTree as ET
 from subprocess import check_output, CalledProcessError from subprocess import check_output, CalledProcessError
  
 # Constants # Constants
Line 40  PERL_FXNS_A = """sub new
Line 42  PERL_FXNS_A = """sub new
     };     };
  
     bless($self, $clname);     bless($self, $clname);
     $self->{_paramsH} = $self->initialize();      $self->{_paramsH} = {};
       $self->initialize();
  
     return $self;     return $self;
 } }
Line 68  PERL_FXNS_B = """sub get
Line 71  PERL_FXNS_B = """sub get
 } }
 1;""" 1;"""
  
   
   RULESPREFIX = """# Standard things
   sp              := $(sp).x
   dirstack_$(sp)  := $(d)
   d               := $(dir)
   """
   
   RULESSUFFIX = """dir    := $(d)/example
   -include                $(SRCDIR)/$(dir)/Rules.mk
   dir     := $(d)/cookbook
   -include                $(SRCDIR)/$(dir)/Rules.mk
   dir     := $(d)/myproj
   -include                $(SRCDIR)/$(dir)/Rules.mk
   
   # Standard things
   d               := $(dirstack_$(sp))
   sp              := $(basename $(sp))
   """
   
   TARGETPREFIX = """$(PROJOBJDIR):\n\t+@[ -d $@ ] || mkdir -p $@"""
   
 ICC_MAJOR = 9 ICC_MAJOR = 9
 ICC_MINOR = 0 ICC_MINOR = 0
 GCC_MAJOR = 3 GCC_MAJOR = 3
Line 144  def isSupportedPlat(plat):
Line 168  def isSupportedPlat(plat):
     else:     else:
         return bool(0);         return bool(0);
  
 def processMakeParam(mDefs, key, val, platDict, matchDict):  def processMakeParam(mDefs, key, val, platDict, machDict):
     varMach = None     varMach = None
     regexp = re.compile(r"(\S+):(\S+)")     regexp = re.compile(r"(\S+):(\S+)")
     matchobj = regexp.match(key)     matchobj = regexp.match(key)
Line 170  def processMakeParam(mDefs, key, val, pl
Line 194  def processMakeParam(mDefs, key, val, pl
                 machDict[varMach] = {}                 machDict[varMach] = {}
             machDict[varMach][varName] = varValu             machDict[varMach][varName] = varValu
  
 def processParam(cfgfile, line, regexpComm, regexpDefs, regexpMake, regexpQuote, regexp, keymap, defs, cDefs, mDefsGen, mDefsMake, perlConstSection, perlInitSection, platDict, machDict, section):  def processParam(cfgfile, line, regexpQuote, regexp, keymap, defs, cDefs, mDefsGen, mDefsMake, perlConstSection, perlInitSection, platDict, machDict, section):
     status = 0     status = 0
  
     matchobj = regexpComm.match(line)  
     if not matchobj is None:  
         # Skip comment line  
         return bool(0)  
   
     matchobj = regexpDefs.match(line)  
     if not matchobj is None:  
         del section[:]  
         section.extend(list('defs'))  
         return bool(0)  
   
     matchobj = regexpMake.match(line)  
     if not matchobj is None:  
         del section[:]  
         section.extend(list('make'))  
         return bool(0)  
   
     if ''.join(section) == 'defs' or not cfgfile:     if ''.join(section) == 'defs' or not cfgfile:
         matchobj = regexp.match(line)         matchobj = regexp.match(line)
         if not matchobj is None:         if not matchobj is None:
Line 203  def processParam(cfgfile, line, regexpCo
Line 210  def processParam(cfgfile, line, regexpCo
                 if keyCfgSp in keymap:                 if keyCfgSp in keymap:
                     key = keymap[keyCfgSp]                     key = keymap[keyCfgSp]
                 elif keyCfgSp == 'LOCAL_CONFIG_SET' or keyCfgSp == 'DRMS_SAMPLE_NAMESPACE':                 elif keyCfgSp == 'LOCAL_CONFIG_SET' or keyCfgSp == 'DRMS_SAMPLE_NAMESPACE':
                     # Ignore parameters that are not useful and shouldn't have been there in the first place                      # Ignore parameters that are not useful and shouldn't have been there in the first place. But
                       # they have been released to the world, so we have to account for them.
                     return bool(0)                     return bool(0)
                 elif not cfgfile:                 elif not cfgfile:
                     # Should not be doing mapping for addenda                     # Should not be doing mapping for addenda
Line 252  def processParam(cfgfile, line, regexpCo
Line 260  def processParam(cfgfile, line, regexpCo
                 # constants (the names of which are the parameter names)                 # constants (the names of which are the parameter names)
                 # we can refer to those in the init section. The key variable holds the                 # we can refer to those in the init section. The key variable holds the
                 # name of the constant.                 # name of the constant.
                 perlInitSection.extend(list('\n  $self->{_paramsH}->{' + key + '} = ' + "'" + val + "';"))                  perlInitSection.extend(list("\n  $self->{_paramsH}->{'" + key + "'} = " + key + ';'))
             else:             else:
                 # No quote qualifier                 # No quote qualifier
                 raise Exception('missingQuoteQual', key)                 raise Exception('missingQuoteQual', key)
Line 273  def processParam(cfgfile, line, regexpCo
Line 281  def processParam(cfgfile, line, regexpCo
  
 # We have some extraneous line or a newline - ignore. # We have some extraneous line or a newline - ignore.
  
   def processXML(xml, projRules, projTarget):
       rv = bool(0)
   
       # <projects>
       root = ET.fromstring(xml)
   
       # Iterate through each proj child.
       for proj in root.iter('proj'):
           # Rules.mk
           nameElem = proj.find('name')
           rulesStr = 'dir     := $(d)/' + nameElem.text + '\n-include          $(SRCDIR)/$(dir)/Rules.mk\n'
   
           # make doesn't support logical operations in ifeq conditionals (you can't do ifeq (A AND B)),
           # so we need to write:
           #   ifeq (A)
           #      ifeq (B)
           #        <do something>
           #      endif
           #   endif
   
           rulesPref = '';
           rulesSuff = '';
   
           filters = proj.find('filters')
           if filters is not None:
               for filter in filters.findall('filter'):
                   rulesPref += 'ifeq ($(' + filter.find('name').text + '),' + filter.find('value').text + ')\n'
                   rulesSuff += 'endif\n'
   
           if len(rulesPref) > 0 and len(rulesSuff) > 0:
               projRules.extend(list(rulesPref))
               projRules.extend(list(rulesStr))
               projRules.extend(list(rulesSuff))
           else:
               projRules.extend(list(rulesStr))
   
           # target.mk
           subdirs = proj.find('subdirs')
           if subdirs is not None:
               for subdir in subdirs.findall('subdir'):
                   targetStr = '\n\t+@[ -d $@/' + nameElem.text + '/' + subdir.text + ' ] || mkdir -p $@/' + nameElem.text + '/' + subdir.text
                   projTarget.extend(list(targetStr))
   
       return rv
   
   def determineSection(line, regexpDefs, regexpMake, regexpProjMkRules, regexpProj, regexpProjCfg):
       matchobj = regexpDefs.match(line)
       if not matchobj is None:
           return 'defs'
   
       matchobj = regexpMake.match(line)
       if not matchobj is None:
           return 'make'
   
       matchobj = regexpProjMkRules.match(line)
       if not matchobj is None:
           return 'projmkrules'
   
       matchobj = regexpProj.match(line)
       if not matchobj is None:
           return 'proj'
   
       matchobj = regexpProjCfg.match(line)
       if not matchobj is None:
           return 'projcfg'
   
       return None
   
 # defs is a dictionary containing all parameters (should they be needed in this script) # defs is a dictionary containing all parameters (should they be needed in this script)
 def parseConfig(fin, keymap, addenda, defs, cDefs, mDefsGen, mDefsMake, perlConstSection, perlInitSection):  # projCfg is the list containing the configure script content.
   # projMkRules is the list containing the make_basic.mk content.
   # projRules is the list containing the Rules.mk content.
   # projTargert is the list containing the target.mk content.
   def parseConfig(fin, keymap, addenda, defs, cDefs, mDefsGen, mDefsMake, projCfg, projMkRules, projRules, projTarget, perlConstSection, perlInitSection):
     rv = bool(0)     rv = bool(0)
  
     # Open required config file (config.local)     # Open required config file (config.local)
Line 282  def parseConfig(fin, keymap, addenda, de
Line 362  def parseConfig(fin, keymap, addenda, de
         # Examine each line, looking for key=value pairs.         # Examine each line, looking for key=value pairs.
         regexpDefs = re.compile(r"^__DEFS__")         regexpDefs = re.compile(r"^__DEFS__")
         regexpMake = re.compile(r"^__MAKE__")         regexpMake = re.compile(r"^__MAKE__")
           regexpProjMkRules = re.compile(r"__PROJ_MK_RULES__")
           regexpProj = re.compile(r"^__PROJ__")
           regexpProjCfg = re.compile(r"^__PROJCFG__")
         regexpComm = re.compile(r"^\s*#")         regexpComm = re.compile(r"^\s*#")
           regexpSp = re.compile(r"^s*$")
         regexpQuote = re.compile(r"^\s*(\w):(.+)")         regexpQuote = re.compile(r"^\s*(\w):(.+)")
         regexp = re.compile(r"^\s*(\S+)\s+(\S+)")          regexpCustMkBeg = re.compile(r"^_CUST_")
           regexpCustMkEnd = re.compile(r"^_ENDCUST_")
           regexpDiv = re.compile(r"^__")
           regexp = re.compile(r"^\s*(\S+)\s+(\S.*)")
  
         platDict = {}         platDict = {}
         machDict = {}         machDict = {}
         section = list()  
           xml = None
  
         # Process the parameters in the configuration file         # Process the parameters in the configuration file
         iscfg = bool(1)  
         if not fin is None:         if not fin is None:
             for line in fin:             for line in fin:
                 ppRet = processParam(iscfg, line, regexpComm, regexpDefs, regexpMake, regexpQuote, regexp, keymap, defs, cDefs, mDefsGen, mDefsMake, perlConstSection, perlInitSection, platDict, machDict, section)                  matchobj = regexpComm.match(line)
                 if ppRet:                  if not matchobj is None:
                       # Skip comment line
                       continue
   
                   matchobj = regexpSp.match(line)
                   if not matchobj is None:
                       # Skip whitespace line
                       continue
   
                   newSection = determineSection(line, regexpDefs, regexpMake, regexpProjMkRules, regexpProj, regexpProjCfg)
                   if not newSection is None:
                       section = newSection
   
                   if section == 'make':
   
                       # There are some blocks of lines in the __MAKE__ section that must be copied ver batim to the output make file.
                       # The blocks are defined by _CUST_/_ENDCUST_ tags.
                       matchobj = regexpCustMkBeg.match(line)
   
                       if not matchobj is None:
                           mDefsMake.extend(list('\n'))
                           for line in fin:
                               matchobj = regexpCustMkEnd.match(line)
                               if not matchobj is None:
                     break;                     break;
                               mDefsMake.extend(list(line))
                           newSection = determineSection(line, regexpDefs, regexpMake, regexpProjMkRules, regexpProj, regexpProjCfg)
                           if not newSection is None:
                               section = newSection
                           continue
                       # Intentional fall through to next if statement
                   if section == 'defs' or section == 'make':
                       iscfg = bool(1)
                       ppRet = processParam(iscfg, line, regexpQuote, regexp, keymap, defs, cDefs, mDefsGen, mDefsMake, perlConstSection, perlInitSection, platDict, machDict, section)
  
         # Process addenda - these are parameters that are not configurable and must be set in the  
         # NetDRMS build.  
         iscfg = bool(0)  
         for key in addenda:  
             item = key + ' ' + addenda[key]  
             ppRet = processParam(iscfg, item, regexpComm, regexpDefs, regexpMake, regexpQuote, regexp, keymap, defs, cDefs, mDefsGen, mDefsMake, perlConstSection, perlInitSection, platDict, machDict, section)  
             if ppRet:             if ppRet:
                           break
                   elif section == 'projcfg':
                       # Copy the line ver batim to the projCfg list (configure)
                       for line in fin:
                           matchobj = regexpDiv.match(line)
                           if not matchobj is None:
                               break;
                           projCfg.extend(list(line))
                       newSection = determineSection(line, regexpDefs, regexpMake, regexpProjMkRules, regexpProj, regexpProjCfg)
                       if not newSection is None:
                           section = newSection
                       continue
                   elif section == 'projmkrules':
                       # Copy the line ver batim to the projMkRules list (make_basic.mk)
                       for line in fin:
                           matchobj = regexpDiv.match(line)
                           if not matchobj is None:
                 break;                 break;
                           projMkRules.extend(list(line))
                       newSection = determineSection(line, regexpDefs, regexpMake, regexpProjMkRules, regexpProj, regexpProjCfg)
                       if not newSection is None:
                           section = newSection
                       continue
                   elif section == 'proj':
                       # Must parse xml and use the project-specific information to populate the Rules.mk and target.mk files.
                       # Collect all xml lines for now, then process after file-read loop.
                       if xml is None:
                           xml = line
                       else:
                           xml += line
                   else:
                       # Unknown section
                       raise Exception('unknownSection', section)
     except Exception as exc:     except Exception as exc:
         msg, violator = exc.args          msg = exc.args[0]
         if msg == 'badKeyMapKey':         if msg == 'badKeyMapKey':
             # If we are here, then there was a non-empty keymap, and the parameter came from             # If we are here, then there was a non-empty keymap, and the parameter came from
             # the configuration file.             # the configuration file.
               violator = exc.args[1]
             print('Unknown parameter name ' + "'" + violator + "'" + ' in ' + cfgfile + '.', file=sys.stderr)             print('Unknown parameter name ' + "'" + violator + "'" + ' in ' + cfgfile + '.', file=sys.stderr)
             rv = bool(1)             rv = bool(1)
         elif msg == 'badQuoteQual':         elif msg == 'badQuoteQual':
             # The bad quote qualifier came from the configuration file, not the addenda, since             # The bad quote qualifier came from the configuration file, not the addenda, since
             # we will have fixed any bad qualifiers in the addenda (which is populated by code).             # we will have fixed any bad qualifiers in the addenda (which is populated by code).
               violator = exc.args[1]
             print('Unknown quote qualifier ' + "'" + violator + "'" + ' in ' + cfgfile + '.', file=sys.stderr)             print('Unknown quote qualifier ' + "'" + violator + "'" + ' in ' + cfgfile + '.', file=sys.stderr)
             rv = bool(1)             rv = bool(1)
         elif msg == 'missingQuoteQual':         elif msg == 'missingQuoteQual':
               violator = exc.args[1]
             print('Missing quote qualifier for parameter ' + "'" + violator + "'" + ' in ' + cfgfile + '.', file=sys.stderr)             print('Missing quote qualifier for parameter ' + "'" + violator + "'" + ' in ' + cfgfile + '.', file=sys.stderr)
             rv = bool(1)             rv = bool(1)
         elif msg == 'paramNameTooLong':         elif msg == 'paramNameTooLong':
               violator = exc.args[1]
             print('Macro name ' + "'" + violator + "' is too long.", file=sys.stderr)             print('Macro name ' + "'" + violator + "' is too long.", file=sys.stderr)
             rv = bool(1)             rv = bool(1)
           elif msg == 'unknownSection':
               violator = exc.args[1]
               print('Unknown section ' + "'" + violator + "' in configuration file.", file=sys.stderr)
               rv = bool(1)
         else:         else:
             # re-raise the exception             # re-raise the exception
             raise             raise
  
       if not rv:
           if not xml is None:
               # Process xml.
               projRules.extend(list(RULESPREFIX))
               projTarget.extend(list(TARGETPREFIX))
               rv = processXML(xml, projRules, projTarget)
               projRules.extend(RULESSUFFIX)
   
       # Process addenda - these are parameters that are not configurable and must be set in the
       # NetDRMS build.
       if not rv:
           iscfg = bool(0)
           for key in addenda:
               item = key + ' ' + addenda[key]
               ppRet = processParam(iscfg, item, regexpQuote, regexp, keymap, defs, cDefs, mDefsGen, mDefsMake, perlConstSection, perlInitSection, platDict, machDict, 'defs')
               if ppRet:
                   break;
   
     # Put information collected in platDict and machDict into mDefs. Must do this here, and not in processParam, since     # Put information collected in platDict and machDict into mDefs. Must do this here, and not in processParam, since
     # we need to parse all platform-specific make variables before grouping them into platform categories.     # we need to parse all platform-specific make variables before grouping them into platform categories.
     if not rv:     if not rv:
Line 340  def parseConfig(fin, keymap, addenda, de
Line 511  def parseConfig(fin, keymap, addenda, de
     if not rv:     if not rv:
         for mach in machDict:         for mach in machDict:
             mDefsMake.extend(list('\nifeq ($(MACHTYPE), ' + mach + ')'))             mDefsMake.extend(list('\nifeq ($(MACHTYPE), ' + mach + ')'))
             for var in platDict[plat]:              for var in machDict[mach]:
                 mDefsMake.extend(list('\n' + var + ' = ' + platDict[plat][var]))                  mDefsMake.extend(list('\n' + var + ' = ' + machDict[mach][var]))
             mDefsMake.extend(list('\nendif\n'))             mDefsMake.extend(list('\nendif\n'))
   
     return rv     return rv
  
 def getMgrUIDLine(defs, uidParam): def getMgrUIDLine(defs, uidParam):
Line 372  def isVersion(maj, min, majDef, minDef):
Line 542  def isVersion(maj, min, majDef, minDef):
  
 def configureComps(defs, mDefs): def configureComps(defs, mDefs):
     rv = bool(0)     rv = bool(0)
       autoConfig = bool(1)
   
       if 'AUTOSELCOMP' in defs:
     autoConfig = (not defs['AUTOSELCOMP'] == '0')     autoConfig = (not defs['AUTOSELCOMP'] == '0')
  
     if autoConfig:     if autoConfig:
Line 389  def configureComps(defs, mDefs):
Line 562  def configureComps(defs, mDefs):
             print('Command ' + "'" + cmd + "'" + ' ran improperly.')             print('Command ' + "'" + cmd + "'" + ' ran improperly.')
             rv = bool(1)             rv = bool(1)
  
         if rv == bool(0):          if not rv:
             regexp = re.compile(r".+Version\s+(\d+)[.](\d+)", re.DOTALL)             regexp = re.compile(r".+Version\s+(\d+)[.](\d+)", re.DOTALL)
             matchobj = regexp.match(ret)             matchobj = regexp.match(ret)
             if matchobj is None:             if matchobj is None:
Line 430  def configureComps(defs, mDefs):
Line 603  def configureComps(defs, mDefs):
             print('Command ' + "'" + cmd + "'" + ' ran improperly.')             print('Command ' + "'" + cmd + "'" + ' ran improperly.')
             rv = bool(1)             rv = bool(1)
  
         if rv == bool(0):          if not rv:
             regexp = re.compile(r".+Version\s+(\d+)\.(\d+)", re.DOTALL)             regexp = re.compile(r".+Version\s+(\d+)\.(\d+)", re.DOTALL)
             matchobj = regexp.match(ret)             matchobj = regexp.match(ret)
             if matchobj is None:             if matchobj is None:
Line 479  def configureComps(defs, mDefs):
Line 652  def configureComps(defs, mDefs):
             mDefs.extend(list('\nFCOMPILER = gfortran'))             mDefs.extend(list('\nFCOMPILER = gfortran'))
  
         # Environment overrides. These get written, regardless of the disposition of auto-configuration.         # Environment overrides. These get written, regardless of the disposition of auto-configuration.
         mDefs.extend(list('\nifneq $(JSOC_COMPILER,)\n  COMPILER = $(JSOC_COMPILER)\nendif'))          mDefs.extend(list('\nifneq ($(JSOC_COMPILER),)\n  COMPILER = $(JSOC_COMPILER)\nendif'))
         mDefs.extend(list('\nifneq $(JSOC_FCOMPILER,)\n  FCOMPILER = $(JSOC_FCOMPILER)\nendif'))          mDefs.extend(list('\nifneq ($(JSOC_FCOMPILER),)\n  FCOMPILER = $(JSOC_FCOMPILER)\nendif'))
  
     return rv     return rv
  
 def writeFiles(base, cfile, mfile, pfile, cDefs, mDefsGen, mDefsMake, mDefsComps, perlConstSection, perlInitSection):  def writeParamsFiles(base, cfile, mfile, pfile, cDefs, mDefsGen, mDefsMake, mDefsComps, perlConstSection, perlInitSection):
     rv = bool(0)     rv = bool(0)
  
     # Merge mDefsGen, mDefsMake, and mDefsComps into a single string with compiler configuration first, general parameters next, then     # Merge mDefsGen, mDefsMake, and mDefsComps into a single string with compiler configuration first, general parameters next, then
Line 522  def writeFiles(base, cfile, mfile, pfile
Line 695  def writeFiles(base, cfile, mfile, pfile
             print('}\n', file=pout)             print('}\n', file=pout)
             print(PERL_FXNS_B, file=pout)             print(PERL_FXNS_B, file=pout)
     except IOError as exc:     except IOError as exc:
         sys.stderr.write(exc.strerror)          type, value, traceback = sys.exc_info()
         sys.stderr.write('Unable to open a parameter vile.')          print(exc.strerror, file=sys.stderr)
           print('Unable to open ' + "'" + value.filename + "'.", file=sys.stderr)
           rv = bool(1)
   
       return rv
   
   def writeProjFiles(pCfile, pMfile, pRfile, pTfile, projCfg, projMkRules, projRules, projTarget):
       rv = bool(0)
   
       try:
           if projCfg:
               with open(pCfile, 'w') as cout:
                   # configure
                   print(''.join(projCfg), file=cout)
   
           if projMkRules:
               with open(pMfile, 'w') as mout:
                   # make_basic.mk
                   print(PREFIX, file=mout)
                   print(''.join(projMkRules), file=mout)
   
           if projRules:
               with open(pRfile, 'w') as rout:
                   # Rules.mk
                   print(PREFIX, file=rout)
                   print(''.join(projRules), file=rout)
   
           if projTarget:
               with open(pTfile, 'w') as tout:
                   # target.mk
                   print(PREFIX, file=tout)
                   print(''.join(projTarget), file=tout)
       except IOError as exc:
           type, value, traceback = sys.exc_info()
           print(exc.strerror, file=sys.stderr)
           print('Unable to open ' + "'" + value.filename + "'.", file=sys.stderr)
           rv = bool(1)
   
       if not rv:
           if os.path.exists(pCfile):
               try:
                   os.chmod(pCfile, stat.S_IRWXU | stat.S_IRGRP | stat.S_IROTH)
               except OSError as exc:
                   type, value, traceback = sys.exc_info()
                   print('Unable to chmod file ' + "'" + value.filename + "'.", file=sys.stderr)
                   print(exc.strerror, file=sys.stderr)
         rv = bool(1)         rv = bool(1)
  
     return rv     return rv
  
 def configureNet(cfgfile, cfile, mfile, pfile, base, keymap):  def configureNet(cfgfile, cfile, mfile, pfile, pCfile, pMfile, pRfile, pTfile, base, keymap):
     rv = bool(0)     rv = bool(0)
  
     defs = {}     defs = {}
     cDefs = list()     cDefs = list()
     mDefs = list()  
     mDefsGen = list()     mDefsGen = list()
     mDefsMake = list()     mDefsMake = list()
     mDefsComps = list()     mDefsComps = list()
       projCfg = list()
       projMkRules = list()
       projRules = list()
       projTarget = list()
     perlConstSection = list()     perlConstSection = list()
     perlInitSection = list()     perlInitSection = list()
     addenda = {}     addenda = {}
  
     # There are three parameters that are not configurable and must be set.      # There are three parameters that were not included in the original config.local parameter set, for some reason.
       # Due to this omission, then are not configurable, and must be set in the script.
     addenda['a:USER'] = 'NULL'     addenda['a:USER'] = 'NULL'
     addenda['a:PASSWD'] = 'NULL'     addenda['a:PASSWD'] = 'NULL'
     addenda['p:DSDS_SUPPORT'] = '0'     addenda['p:DSDS_SUPPORT'] = '0'
   
       # This parameter is not configurable. BUILD_TYPE is used to distinguish between a NetDRMS and an JSOC-SDP build.
     addenda['a:BUILD_TYPE'] = 'NETDRMS' # Means a non-Stanford build. This will set two additional macros used by make:     addenda['a:BUILD_TYPE'] = 'NETDRMS' # Means a non-Stanford build. This will set two additional macros used by make:
                                         #   __LOCALIZED_DEFS__ and NETDRMS_BUILD. The former is to support legacy code                                         #   __LOCALIZED_DEFS__ and NETDRMS_BUILD. The former is to support legacy code
                                         #   which incorrectly used this macro, and the latter is for future use.                                         #   which incorrectly used this macro, and the latter is for future use.
Line 553  def configureNet(cfgfile, cfile, mfile,
Line 777  def configureNet(cfgfile, cfile, mfile,
     try:     try:
         with open(cfgfile, 'r') as fin:         with open(cfgfile, 'r') as fin:
             # Process configuration parameters             # Process configuration parameters
             rv = parseConfig(fin, keymap, addenda, defs, cDefs, mDefsGen, mDefsMake, perlConstSection, perlInitSection)              rv = parseConfig(fin, keymap, addenda, defs, cDefs, mDefsGen, mDefsMake, projCfg, projMkRules, projRules, projTarget, perlConstSection, perlInitSection)
             if rv == bool(0):              if not rv:
                 # Must add a parameter for the SUMS_MANAGER UID (for some reason). This must be done after the                 # Must add a parameter for the SUMS_MANAGER UID (for some reason). This must be done after the
                 # config file is processed since an input to getMgrUIDLine() is one of the config file's                 # config file is processed since an input to getMgrUIDLine() is one of the config file's
                 # parameter values.                 # parameter values.
                 uidParam = {}                 uidParam = {}
                 rv = getMgrUIDLine(defs, uidParam)                 rv = getMgrUIDLine(defs, uidParam)
                 if rv == bool(0):                 if rv == bool(0):
                     rv = parseConfig(None, keymap, uidParam, defs, cDefs, mDefsGen, None, perlConstSection, perlInitSection)                      rv = parseConfig(None, keymap, uidParam, defs, cDefs, mDefsGen, None, projCfg, projMkRules, projRules, projTarget, perlConstSection, perlInitSection)
   
             # Configure the compiler-selection make variables.             # Configure the compiler-selection make variables.
             if rv == bool(0):              if not rv:
                 rv = configureComps(defs, mDefsComps)                 rv = configureComps(defs, mDefsComps)
  
             # Write out the parameter files.             # Write out the parameter files.
             if rv == bool(0):              if not rv:
                 rv = writeFiles(base, cfile, mfile, pfile, cDefs, mDefsGen, mDefsMake, mDefsComps, perlConstSection, perlInitSection)                  rv = writeParamsFiles(base, cfile, mfile, pfile, cDefs, mDefsGen, mDefsMake, mDefsComps, perlConstSection, perlInitSection)
               # Write out the project-specific make files (make_basic.mk, Rules.mk, and target.mk).
               if not rv:
                   rv = writeProjFiles(pCfile, pMfile, pRfile, pTfile, projCfg, projMkRules, projRules, projTarget)
     except IOError as exc:     except IOError as exc:
         sys.stderr.write(exc.strerror)          print(exc.strerror, file=sys.stderr)
         sys.stderr.write('Unable to read configuration file ' + cfgfile + '.')          print('Unable to read configuration file ' + cfgfile + '.', file=sys.stderr)
     except Exception as exc:     except Exception as exc:
         type, msg = exc.args         type, msg = exc.args
         if type == 'unexpectedIccRet':         if type == 'unexpectedIccRet':
Line 593  def configureNet(cfgfile, cfile, mfile,
Line 819  def configureNet(cfgfile, cfile, mfile,
  
     return rv     return rv
  
 def configureSdp(cfgfile, cfile, mfile, pfile, base, keymap):  def configureSdp(cfgfile, cfile, mfile, pfile, pCfile, pMfile, pRfile, pTfile, base):
     rv = bool(0)     rv = bool(0)
  
     defs = {}     defs = {}
     cDefs = list()     cDefs = list()
     mDefsGen = list()     mDefsGen = list()
     mDefsMake = list()     mDefsMake = list()
       projCfg = list()
       projMkRules = list()
       projRules = list()
       projTarget = list()
     mDefsComps = list()     mDefsComps = list()
     perlConstSection = list()     perlConstSection = list()
     perlInitSection = list()     perlInitSection = list()
     addenda = {}     addenda = {}
  
       # There are three parameters that were not included in the original config.local parameter set, for some reason.
       # Due to this omission, then are not configurable, and must be set in the script.
     addenda['a:USER'] = 'NULL'     addenda['a:USER'] = 'NULL'
     addenda['a:PASSWD'] = 'NULL'     addenda['a:PASSWD'] = 'NULL'
     addenda['p:DSDS_SUPPORT'] = '1'     addenda['p:DSDS_SUPPORT'] = '1'
   
       # This parameter is not configurable. BUILD_TYPE is used to distinguish between a NetDRMS and an JSOC-SDP build.
     addenda['a:BUILD_TYPE'] = 'JSOC_SDP' # Means a Stanford build. This will set one additional macro used by make: JSOC_SDP_BUILD.     addenda['a:BUILD_TYPE'] = 'JSOC_SDP' # Means a Stanford build. This will set one additional macro used by make: JSOC_SDP_BUILD.
  
     try:     try:
         with open(cfgfile, 'r') as fin:         with open(cfgfile, 'r') as fin:
             rv = parseConfig(cfgfile, keymap, addenda, defs, cDefs, mDefsGen, mDefsMake, perlConstSection, perlInitSection)              rv = parseConfig(fin, None, addenda, defs, cDefs, mDefsGen, mDefsMake, projCfg, projMkRules, projRules, projTarget, perlConstSection, perlInitSection)
             if rv == bool(0):  
               if not rv:
                 # Must add a parameter for the SUMS_MANAGER UID (for some reason)                 # Must add a parameter for the SUMS_MANAGER UID (for some reason)
                 uidParam = {}                 uidParam = {}
                 rv = getMgrUIDLine(defs, uidParam)                 rv = getMgrUIDLine(defs, uidParam)
                 if rv == bool(0):                  if not rv:
                     rv = parseConfig(None, keymap, uidParam, defs, cDefs, mDefsGen, NONE, perlConstSection, perlInitSection)                      rv = parseConfig(None, None, uidParam, defs, cDefs, mDefsGen, None, projCfg, projMkRules, projRules, projTarget, perlConstSection, perlInitSection)
  
                 # Configure the compiler-selection make variables.                 # Configure the compiler-selection make variables.
                 if rv == bool(0):                  if not rv:
                     rv = configureComps(defs, mDefsComps)                     rv = configureComps(defs, mDefsComps)
  
                 if rv == bool(0):                  # Write out the parameter files.
                     rv = writeFiles(base, cfile, mfile, pfile, cDefs, mDefsGen, mDefsMake, perlConstSection, perlInitSection)                  if not rv:
                       rv = writeParamsFiles(base, cfile, mfile, pfile, cDefs, mDefsGen, mDefsMake, mDefsComps, perlConstSection, perlInitSection)
   
                   # Write out the project-specific make files (make_basic.mk, Rules.mk, and target.mk).
                   if not rv:
                       rv = writeProjFiles(pCfile, pMfile, pRfile, pTfile, projCfg, projMkRules, projRules, projTarget)
     except IOError as exc:     except IOError as exc:
         sys.stderr.write(exc.strerror)          print(exc.strerror, file=sys.stderr)
         sys.stderr.write('Unable to read configuration file ' + cfgfile + '.')          print('Unable to read configuration file ' + cfgfile + '.', file=sys.stderr)
     except Exception as exc:     except Exception as exc:
         type, msg = exc.args          type = exc.args[0]
         if type == 'unexpectedIccRet':         if type == 'unexpectedIccRet':
               msg = exc.args[1]
             print('icc -V returned this unexpected message:\n' + msg, file=sys.stderr)             print('icc -V returned this unexpected message:\n' + msg, file=sys.stderr)
             rv = bool(1)             rv = bool(1)
         elif type == 'unexpectedGccRet':         elif type == 'unexpectedGccRet':
               msg = exc.args[1]
             print('gcc -v returned this unexpected message:\n' + msg, file=sys.stderr)             print('gcc -v returned this unexpected message:\n' + msg, file=sys.stderr)
             rv = bool(1)             rv = bool(1)
         elif type == 'unexpectedIfortRet':         elif type == 'unexpectedIfortRet':
               msg = exc.args[1]
             print('ifort -V returned this unexpected message:\n' + msg, file=sys.stderr)             print('ifort -V returned this unexpected message:\n' + msg, file=sys.stderr)
             rv = bool(1)             rv = bool(1)
         elif type == 'unexpectedGfortranRet':         elif type == 'unexpectedGfortranRet':
               msg = exc.args[1]
             print('gfortran -v returned this unexpected message:\n' + msg, file=sys.stderr)             print('gfortran -v returned this unexpected message:\n' + msg, file=sys.stderr)
             rv = bool(1)             rv = bool(1)
         else:         else:
Line 675  if rv == RET_SUCCESS:
Line 919  if rv == RET_SUCCESS:
     cfile = optD['dir'] + '/' + optD['base'] + '.h'     cfile = optD['dir'] + '/' + optD['base'] + '.h'
     mfile = optD['dir'] + '/' + optD['base'] + '.mk'     mfile = optD['dir'] + '/' + optD['base'] + '.mk'
     pfile = optD['dir'] + '/' + optD['base'] + '.pm'     pfile = optD['dir'] + '/' + optD['base'] + '.pm'
       pCfile = optD['dir'] + '/configure'
       pMfile = optD['dir'] + '/make_basic.mk'
       pRfile = optD['dir'] + '/Rules.mk'
       pTfile = optD['dir'] + '/target.mk'
  
     if net:     if net:
         try:         try:
Line 699  if rv == RET_SUCCESS:
Line 947  if rv == RET_SUCCESS:
             sys.stderr.write('Unable to read configuration map-file ' + NET_CFGMAP + '.')             sys.stderr.write('Unable to read configuration map-file ' + NET_CFGMAP + '.')
             rv = bool(1)             rv = bool(1)
  
   
   
         # We also need to set the UID of the SUMS manager. We have the name of the         # We also need to set the UID of the SUMS manager. We have the name of the
         # SUMS manager (it is in the configuration file)         # SUMS manager (it is in the configuration file)
         configureNet(NET_CFG, cfile, mfile, pfile, optD['base'], keymap)          configureNet(NET_CFG, cfile, mfile, pfile, pCfile, pMfile, pRfile, pTfile, optD['base'], keymap)
     else:     else:
         configureSdp(SDP_CFG, cfile, mfile, pfile, optD['base'], {})          # A Stanford user can override the parameters in configsdp.txt by copying that file to config.local,
           # and then editing config.local. So, if config.local exists, use that.
           if os.path.isfile(cdir + '/' + NET_CFG):
               configureSdp(NET_CFG, cfile, mfile, pfile, pCfile, pMfile, pRfile, pTfile, optD['base'])
           else:
               configureSdp(SDP_CFG, cfile, mfile, pfile, pCfile, pMfile, pRfile, pTfile, optD['base'])


Legend:
Removed from v.1.5  
changed lines
  Added in v.1.11

Karen Tian
Powered by
ViewCVS 0.9.4