parameters: (env, version=None, abi=None, topdir=None, verbose=0)
docstring: Add Builders and construction variables for Intel C/C++ compiler
      to an Environment.
      args:
        version: (string) compiler version to use, like "80"
        abi:     (string) 'win32' or whatever Itanium version wants
        topdir:  (string) compiler top dir, like
                           "c:\Program Files\Intel\Compiler70"
                          If topdir is used, version and abi are ignored.
        verbose: (int)    if >0, prints compiler version used.
docstring_summary: Add Builders and construction variables for Intel C/C++ compiler
      to an Environment.
      args:
        version: (string) compiler version to use, like "80"
        abi:     (string) 'win32' or whatever Itanium version wants
        topdir:  (string) compiler top dir, like
                           "c:\Program Files\Intel\Compiler70"
                          If topdir is used, version and abi are ignored.
        verbose: (int)    if >0, prints compiler version used.
docstring_tokens: Add Builders and construction variables for Intel C / C ++ compiler to an Environment . args : version : ( string ) compiler version to use like 80 abi : ( string ) win32 or whatever Itanium version wants topdir : ( string ) compiler top dir like c : \ Program Files \ Intel \ Compiler70 If topdir is used version and abi are ignored . verbose : ( int ) if > 0 prints compiler version used .
function: def generate(env, version=None, abi=None, topdir=None, verbose=0):
      """Add Builders and construction variables for Intel C/C++ compiler
      to an Environment.
      args:
        version: (string) compiler version to use, like "80"
        abi:     (string) 'win32' or whatever Itanium version wants
        topdir:  (string) compiler top dir, like
                           "c:\Program Files\Intel\Compiler70"
                          If topdir is used, version and abi are ignored.
        verbose: (int)    if >0, prints compiler version used.
      """
      if not (is_mac or is_linux or is_windows):
          # can't handle this platform
          return
  
      if is_windows:
          SCons.Tool.msvc.generate(env)
      elif is_linux:
          SCons.Tool.gcc.generate(env)
      elif is_mac:
          SCons.Tool.gcc.generate(env)
  
      # if version is unspecified, use latest
      vlist = get_all_compiler_versions()
      if not version:
          if vlist:
              version = vlist[0]
      else:
          # User may have specified '90' but we need to get actual dirname '9.0'.
          # get_version_from_list does that mapping.
          v = get_version_from_list(version, vlist)
          if not v:
              raise SCons.Errors.UserError("Invalid Intel compiler version %s: "%version + \
                    "installed versions are %s"%(', '.join(vlist)))
          version = v
  
      # if abi is unspecified, use ia32
      # alternatives are ia64 for Itanium, or amd64 or em64t or x86_64 (all synonyms here)
      abi = check_abi(abi)
      if abi is None:
          if is_mac or is_linux:
              # Check if we are on 64-bit linux, default to 64 then.
              uname_m = os.uname()[4]
              if uname_m == 'x86_64':
                  abi = 'x86_64'
              else:
                  abi = 'ia32'
          else:
              if is_win64:
                  abi = 'em64t'
              else:
                  abi = 'ia32'
  
      if version and not topdir:
          try:
              topdir = get_intel_compiler_top(version, abi)
          except (SCons.Util.RegError, IntelCError):
              topdir = None
  
      if not topdir:
          # Normally this is an error, but it might not be if the compiler is
          # on $PATH and the user is importing their env.
          class ICLTopDirWarning(SCons.Warnings.Warning):
              pass
          if (is_mac or is_linux) and not env.Detect('icc') or \
             is_windows and not env.Detect('icl'):
  
              SCons.Warnings.enableWarningClass(ICLTopDirWarning)
              SCons.Warnings.warn(ICLTopDirWarning,
                                  "Failed to find Intel compiler for version='%s', abi='%s'"%
                                  (str(version), str(abi)))
          else:
              # should be cleaned up to say what this other version is
              # since in this case we have some other Intel compiler installed
              SCons.Warnings.enableWarningClass(ICLTopDirWarning)
              SCons.Warnings.warn(ICLTopDirWarning,
                                  "Can't find Intel compiler top dir for version='%s', abi='%s'"%
                                      (str(version), str(abi)))
  
      if topdir:
          archdir={'x86_64': 'intel64',
                   'amd64' : 'intel64',
                   'em64t' : 'intel64',
                   'x86'   : 'ia32',
                   'i386'  : 'ia32',
                   'ia32'  : 'ia32'
          }[abi] # for v11 and greater
          if os.path.exists(os.path.join(topdir, 'bin', archdir)):
              bindir="bin/%s"%archdir
              libdir="lib/%s"%archdir
          else:
              bindir="bin"
              libdir="lib"
          if verbose:
              print "Intel C compiler: using version %s (%g), abi %s, in '%s/%s'"%\
                    (repr(version), linux_ver_normalize(version),abi,topdir,bindir)
              if is_linux:
                  # Show the actual compiler version by running the compiler.
                  os.system('%s/%s/icc --version'%(topdir,bindir))
              if is_mac:
                  # Show the actual compiler version by running the compiler.
                  os.system('%s/%s/icc --version'%(topdir,bindir))
  
          env['INTEL_C_COMPILER_TOP'] = topdir
          if is_linux:
              paths={'INCLUDE'         : 'include',
                     'LIB'             : libdir,
                     'PATH'            : bindir,
                     'LD_LIBRARY_PATH' : libdir}
              for p in paths.keys():
                  env.PrependENVPath(p, os.path.join(topdir, paths[p]))
          if is_mac:
              paths={'INCLUDE'         : 'include',
                     'LIB'             : libdir,
                     'PATH'            : bindir,
                     'LD_LIBRARY_PATH' : libdir}
              for p in paths.keys():
                  env.PrependENVPath(p, os.path.join(topdir, paths[p]))
          if is_windows:
              #       env key    reg valname   default subdir of top
              paths=(('INCLUDE', 'IncludeDir', 'Include'),
                     ('LIB'    , 'LibDir',     'Lib'),
                     ('PATH'   , 'BinDir',     'Bin'))
              # We are supposed to ignore version if topdir is set, so set
              # it to the emptry string if it's not already set.
              if version is None:
                  version = ''
              # Each path has a registry entry, use that or default to subdir
              for p in paths:
                  try:
                      path=get_intel_registry_value(p[1], version, abi)
                      # These paths may have $(ICInstallDir)
                      # which needs to be substituted with the topdir.
                      path=path.replace('$(ICInstallDir)', topdir + os.sep)
                  except IntelCError:
                      # Couldn't get it from registry: use default subdir of topdir
                      env.PrependENVPath(p[0], os.path.join(topdir, p[2]))
                  else:
                      env.PrependENVPath(p[0], path.split(os.pathsep))
                      # print "ICL %s: %s, final=%s"%(p[0], path, str(env['ENV'][p[0]]))
  
      if is_windows:
          env['CC']        = 'icl'
          env['CXX']       = 'icl'
          env['LINK']      = 'xilink'
      else:
          env['CC']        = 'icc'
          env['CXX']       = 'icpc'
          # Don't reset LINK here;
          # use smart_link which should already be here from link.py.
          #env['LINK']      = '$CC'
          env['AR']        = 'xiar'
          env['LD']        = 'xild' # not used by default
  
      # This is not the exact (detailed) compiler version,
      # just the major version as determined above or specified
      # by the user.  It is a float like 80 or 90, in normalized form for Linux
      # (i.e. even for Linux 9.0 compiler, still returns 90 rather than 9.0)
      if version:
          env['INTEL_C_COMPILER_VERSION']=linux_ver_normalize(version)
  
      if is_windows:
          # Look for license file dir
          # in system environment, registry, and default location.
          envlicdir = os.environ.get("INTEL_LICENSE_FILE", '')
          K = ('SOFTWARE\Intel\Licenses')
          try:
              k = SCons.Util.RegOpenKeyEx(SCons.Util.HKEY_LOCAL_MACHINE, K)
              reglicdir = SCons.Util.RegQueryValueEx(k, "w_cpp")[0]
          except (AttributeError, SCons.Util.RegError):
              reglicdir = ""
          defaultlicdir = r'C:\Program Files\Common Files\Intel\Licenses'
  
          licdir = None
          for ld in [envlicdir, reglicdir]:
              # If the string contains an '@', then assume it's a network
              # license (port@system) and good by definition.
              if ld and (ld.find('@') != -1 or os.path.exists(ld)):
                  licdir = ld
                  break
          if not licdir:
              licdir = defaultlicdir
              if not os.path.exists(licdir):
                  class ICLLicenseDirWarning(SCons.Warnings.Warning):
                      pass
                  SCons.Warnings.enableWarningClass(ICLLicenseDirWarning)
                  SCons.Warnings.warn(ICLLicenseDirWarning,
                                      "Intel license dir was not found."
                                      "  Tried using the INTEL_LICENSE_FILE environment variable (%s), the registry (%s) and the default path (%s)."
                                      "  Using the default path as a last resort."
                                          % (envlicdir, reglicdir, defaultlicdir))
          env['ENV']['INTEL_LICENSE_FILE'] = licdir
function_tokens: def generate ( env , version = None , abi = None , topdir = None , verbose = 0 ) : if not ( is_mac or is_linux or is_windows ) : # can't handle this platform return if is_windows : SCons . Tool . msvc . generate ( env ) elif is_linux : SCons . Tool . gcc . generate ( env ) elif is_mac : SCons . Tool . gcc . generate ( env ) # if version is unspecified, use latest vlist = get_all_compiler_versions ( ) if not version : if vlist : version = vlist [ 0 ] else : # User may have specified '90' but we need to get actual dirname '9.0'. # get_version_from_list does that mapping. v = get_version_from_list ( version , vlist ) if not v : raise SCons . Errors . UserError ( "Invalid Intel compiler version %s: " % version + "installed versions are %s" % ( ', ' . join ( vlist ) ) ) version = v # if abi is unspecified, use ia32 # alternatives are ia64 for Itanium, or amd64 or em64t or x86_64 (all synonyms here) abi = check_abi ( abi ) if abi is None : if is_mac or is_linux : # Check if we are on 64-bit linux, default to 64 then. uname_m = os . uname ( ) [ 4 ] if uname_m == 'x86_64' : abi = 'x86_64' else : abi = 'ia32' else : if is_win64 : abi = 'em64t' else : abi = 'ia32' if version and not topdir : try : topdir = get_intel_compiler_top ( version , abi ) except ( SCons . Util . RegError , IntelCError ) : topdir = None if not topdir : # Normally this is an error, but it might not be if the compiler is # on $PATH and the user is importing their env. class ICLTopDirWarning ( SCons . Warnings . Warning ) : pass if ( is_mac or is_linux ) and not env . Detect ( 'icc' ) or is_windows and not env . Detect ( 'icl' ) : SCons . Warnings . enableWarningClass ( ICLTopDirWarning ) SCons . Warnings . warn ( ICLTopDirWarning , "Failed to find Intel compiler for version='%s', abi='%s'" % ( str ( version ) , str ( abi ) ) ) else : # should be cleaned up to say what this other version is # since in this case we have some other Intel compiler installed SCons . Warnings . enableWarningClass ( ICLTopDirWarning ) SCons . Warnings . warn ( ICLTopDirWarning , "Can't find Intel compiler top dir for version='%s', abi='%s'" % ( str ( version ) , str ( abi ) ) ) if topdir : archdir = { 'x86_64' : 'intel64' , 'amd64' : 'intel64' , 'em64t' : 'intel64' , 'x86' : 'ia32' , 'i386' : 'ia32' , 'ia32' : 'ia32' } [ abi ] # for v11 and greater if os . path . exists ( os . path . join ( topdir , 'bin' , archdir ) ) : bindir = "bin/%s" % archdir libdir = "lib/%s" % archdir else : bindir = "bin" libdir = "lib" if verbose : print "Intel C compiler: using version %s (%g), abi %s, in '%s/%s'" % ( repr ( version ) , linux_ver_normalize ( version ) , abi , topdir , bindir ) if is_linux : # Show the actual compiler version by running the compiler. os . system ( '%s/%s/icc --version' % ( topdir , bindir ) ) if is_mac : # Show the actual compiler version by running the compiler. os . system ( '%s/%s/icc --version' % ( topdir , bindir ) ) env [ 'INTEL_C_COMPILER_TOP' ] = topdir if is_linux : paths = { 'INCLUDE' : 'include' , 'LIB' : libdir , 'PATH' : bindir , 'LD_LIBRARY_PATH' : libdir } for p in paths . keys ( ) : env . PrependENVPath ( p , os . path . join ( topdir , paths [ p ] ) ) if is_mac : paths = { 'INCLUDE' : 'include' , 'LIB' : libdir , 'PATH' : bindir , 'LD_LIBRARY_PATH' : libdir } for p in paths . keys ( ) : env . PrependENVPath ( p , os . path . join ( topdir , paths [ p ] ) ) if is_windows : #       env key    reg valname   default subdir of top paths = ( ( 'INCLUDE' , 'IncludeDir' , 'Include' ) , ( 'LIB' , 'LibDir' , 'Lib' ) , ( 'PATH' , 'BinDir' , 'Bin' ) ) # We are supposed to ignore version if topdir is set, so set # it to the emptry string if it's not already set. if version is None : version = '' # Each path has a registry entry, use that or default to subdir for p in paths : try : path = get_intel_registry_value ( p [ 1 ] , version , abi ) # These paths may have $(ICInstallDir) # which needs to be substituted with the topdir. path = path . replace ( '$(ICInstallDir)' , topdir + os . sep ) except IntelCError : # Couldn't get it from registry: use default subdir of topdir env . PrependENVPath ( p [ 0 ] , os . path . join ( topdir , p [ 2 ] ) ) else : env . PrependENVPath ( p [ 0 ] , path . split ( os . pathsep ) ) # print "ICL %s: %s, final=%s"%(p[0], path, str(env['ENV'][p[0]])) if is_windows : env [ 'CC' ] = 'icl' env [ 'CXX' ] = 'icl' env [ 'LINK' ] = 'xilink' else : env [ 'CC' ] = 'icc' env [ 'CXX' ] = 'icpc' # Don't reset LINK here; # use smart_link which should already be here from link.py. #env['LINK']      = '$CC' env [ 'AR' ] = 'xiar' env [ 'LD' ] = 'xild' # not used by default # This is not the exact (detailed) compiler version, # just the major version as determined above or specified # by the user.  It is a float like 80 or 90, in normalized form for Linux # (i.e. even for Linux 9.0 compiler, still returns 90 rather than 9.0) if version : env [ 'INTEL_C_COMPILER_VERSION' ] = linux_ver_normalize ( version ) if is_windows : # Look for license file dir # in system environment, registry, and default location. envlicdir = os . environ . get ( "INTEL_LICENSE_FILE" , '' ) K = ( 'SOFTWARE\Intel\Licenses' ) try : k = SCons . Util . RegOpenKeyEx ( SCons . Util . HKEY_LOCAL_MACHINE , K ) reglicdir = SCons . Util . RegQueryValueEx ( k , "w_cpp" ) [ 0 ] except ( AttributeError , SCons . Util . RegError ) : reglicdir = "" defaultlicdir = r'C:\Program Files\Common Files\Intel\Licenses' licdir = None for ld in [ envlicdir , reglicdir ] : # If the string contains an '@', then assume it's a network # license (port@system) and good by definition. if ld and ( ld . find ( '@' ) != - 1 or os . path . exists ( ld ) ) : licdir = ld break if not licdir : licdir = defaultlicdir if not os . path . exists ( licdir ) : class ICLLicenseDirWarning ( SCons . Warnings . Warning ) : pass SCons . Warnings . enableWarningClass ( ICLLicenseDirWarning ) SCons . Warnings . warn ( ICLLicenseDirWarning , "Intel license dir was not found." "  Tried using the INTEL_LICENSE_FILE environment variable (%s), the registry (%s) and the default path (%s)." "  Using the default path as a last resort." % ( envlicdir , reglicdir , defaultlicdir ) ) env [ 'ENV' ] [ 'INTEL_LICENSE_FILE' ] = licdir