You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

613 lines
26 KiB

6 years ago
  1. """SCons.Tool.icl
  2. Tool-specific initialization for the Intel C/C++ compiler.
  3. Supports Linux and Windows compilers, v7 and up.
  4. There normally shouldn't be any need to import this module directly.
  5. It will usually be imported through the generic SCons.Tool.Tool()
  6. selection method.
  7. """
  8. #
  9. # Copyright (c) 2001 - 2017 The SCons Foundation
  10. #
  11. # Permission is hereby granted, free of charge, to any person obtaining
  12. # a copy of this software and associated documentation files (the
  13. # "Software"), to deal in the Software without restriction, including
  14. # without limitation the rights to use, copy, modify, merge, publish,
  15. # distribute, sublicense, and/or sell copies of the Software, and to
  16. # permit persons to whom the Software is furnished to do so, subject to
  17. # the following conditions:
  18. #
  19. # The above copyright notice and this permission notice shall be included
  20. # in all copies or substantial portions of the Software.
  21. #
  22. # THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY
  23. # KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE
  24. # WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
  25. # NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
  26. # LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
  27. # OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
  28. # WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
  29. from __future__ import division, print_function
  30. __revision__ = "src/engine/SCons/Tool/intelc.py rel_3.0.0:4395:8972f6a2f699 2017/09/18 12:59:24 bdbaddog"
  31. import math, sys, os.path, glob, string, re
  32. is_windows = sys.platform == 'win32'
  33. is_win64 = is_windows and (os.environ['PROCESSOR_ARCHITECTURE'] == 'AMD64' or
  34. ('PROCESSOR_ARCHITEW6432' in os.environ and
  35. os.environ['PROCESSOR_ARCHITEW6432'] == 'AMD64'))
  36. is_linux = sys.platform.startswith('linux')
  37. is_mac = sys.platform == 'darwin'
  38. if is_windows:
  39. import SCons.Tool.msvc
  40. elif is_linux:
  41. import SCons.Tool.gcc
  42. elif is_mac:
  43. import SCons.Tool.gcc
  44. import SCons.Util
  45. import SCons.Warnings
  46. # Exceptions for this tool
  47. class IntelCError(SCons.Errors.InternalError):
  48. pass
  49. class MissingRegistryError(IntelCError): # missing registry entry
  50. pass
  51. class MissingDirError(IntelCError): # dir not found
  52. pass
  53. class NoRegistryModuleError(IntelCError): # can't read registry at all
  54. pass
  55. def linux_ver_normalize(vstr):
  56. """Normalize a Linux compiler version number.
  57. Intel changed from "80" to "9.0" in 2005, so we assume if the number
  58. is greater than 60 it's an old-style number and otherwise new-style.
  59. Always returns an old-style float like 80 or 90 for compatibility with Windows.
  60. Shades of Y2K!"""
  61. # Check for version number like 9.1.026: return 91.026
  62. # XXX needs to be updated for 2011+ versions (like 2011.11.344 which is compiler v12.1.5)
  63. m = re.match(r'([0-9]+)\.([0-9]+)\.([0-9]+)', vstr)
  64. if m:
  65. vmaj,vmin,build = m.groups()
  66. return float(vmaj) * 10. + float(vmin) + float(build) / 1000.;
  67. else:
  68. f = float(vstr)
  69. if is_windows:
  70. return f
  71. else:
  72. if f < 60: return f * 10.0
  73. else: return f
  74. def check_abi(abi):
  75. """Check for valid ABI (application binary interface) name,
  76. and map into canonical one"""
  77. if not abi:
  78. return None
  79. abi = abi.lower()
  80. # valid_abis maps input name to canonical name
  81. if is_windows:
  82. valid_abis = {'ia32' : 'ia32',
  83. 'x86' : 'ia32',
  84. 'ia64' : 'ia64',
  85. 'em64t' : 'em64t',
  86. 'amd64' : 'em64t'}
  87. if is_linux:
  88. valid_abis = {'ia32' : 'ia32',
  89. 'x86' : 'ia32',
  90. 'x86_64' : 'x86_64',
  91. 'em64t' : 'x86_64',
  92. 'amd64' : 'x86_64'}
  93. if is_mac:
  94. valid_abis = {'ia32' : 'ia32',
  95. 'x86' : 'ia32',
  96. 'x86_64' : 'x86_64',
  97. 'em64t' : 'x86_64'}
  98. try:
  99. abi = valid_abis[abi]
  100. except KeyError:
  101. raise SCons.Errors.UserError("Intel compiler: Invalid ABI %s, valid values are %s"% \
  102. (abi, list(valid_abis.keys())))
  103. return abi
  104. def vercmp(a, b):
  105. """Compare strings as floats,
  106. but Intel changed Linux naming convention at 9.0"""
  107. return cmp(linux_ver_normalize(b), linux_ver_normalize(a))
  108. def get_version_from_list(v, vlist):
  109. """See if we can match v (string) in vlist (list of strings)
  110. Linux has to match in a fuzzy way."""
  111. if is_windows:
  112. # Simple case, just find it in the list
  113. if v in vlist: return v
  114. else: return None
  115. else:
  116. # Fuzzy match: normalize version number first, but still return
  117. # original non-normalized form.
  118. fuzz = 0.001
  119. for vi in vlist:
  120. if math.fabs(linux_ver_normalize(vi) - linux_ver_normalize(v)) < fuzz:
  121. return vi
  122. # Not found
  123. return None
  124. def get_intel_registry_value(valuename, version=None, abi=None):
  125. """
  126. Return a value from the Intel compiler registry tree. (Windows only)
  127. """
  128. # Open the key:
  129. if is_win64:
  130. K = 'Software\\Wow6432Node\\Intel\\Compilers\\C++\\' + version + '\\'+abi.upper()
  131. else:
  132. K = 'Software\\Intel\\Compilers\\C++\\' + version + '\\'+abi.upper()
  133. try:
  134. k = SCons.Util.RegOpenKeyEx(SCons.Util.HKEY_LOCAL_MACHINE, K)
  135. except SCons.Util.RegError:
  136. # For version 13 and later, check UUID subkeys for valuename
  137. if is_win64:
  138. K = 'Software\\Wow6432Node\\Intel\\Suites\\' + version + "\\Defaults\\C++\\" + abi.upper()
  139. else:
  140. K = 'Software\\Intel\\Suites\\' + version + "\\Defaults\\C++\\" + abi.upper()
  141. try:
  142. k = SCons.Util.RegOpenKeyEx(SCons.Util.HKEY_LOCAL_MACHINE, K)
  143. uuid = SCons.Util.RegQueryValueEx(k, 'SubKey')[0]
  144. if is_win64:
  145. K = 'Software\\Wow6432Node\\Intel\\Suites\\' + version + "\\" + uuid + "\\C++"
  146. else:
  147. K = 'Software\\Intel\\Suites\\' + version + "\\" + uuid + "\\C++"
  148. k = SCons.Util.RegOpenKeyEx(SCons.Util.HKEY_LOCAL_MACHINE, K)
  149. try:
  150. v = SCons.Util.RegQueryValueEx(k, valuename)[0]
  151. return v # or v.encode('iso-8859-1', 'replace') to remove unicode?
  152. except SCons.Util.RegError:
  153. if abi.upper() == 'EM64T':
  154. abi = 'em64t_native'
  155. if is_win64:
  156. K = 'Software\\Wow6432Node\\Intel\\Suites\\' + version + "\\" + uuid + "\\C++\\" + abi.upper()
  157. else:
  158. K = 'Software\\Intel\\Suites\\' + version + "\\" + uuid + "\\C++\\" + abi.upper()
  159. k = SCons.Util.RegOpenKeyEx(SCons.Util.HKEY_LOCAL_MACHINE, K)
  160. try:
  161. v = SCons.Util.RegQueryValueEx(k, valuename)[0]
  162. return v # or v.encode('iso-8859-1', 'replace') to remove unicode?
  163. except SCons.Util.RegError:
  164. raise MissingRegistryError("%s was not found in the registry, for Intel compiler version %s, abi='%s'"%(K, version,abi))
  165. except SCons.Util.RegError:
  166. raise MissingRegistryError("%s was not found in the registry, for Intel compiler version %s, abi='%s'"%(K, version,abi))
  167. except SCons.Util.WinError:
  168. raise MissingRegistryError("%s was not found in the registry, for Intel compiler version %s, abi='%s'"%(K, version,abi))
  169. # Get the value:
  170. try:
  171. v = SCons.Util.RegQueryValueEx(k, valuename)[0]
  172. return v # or v.encode('iso-8859-1', 'replace') to remove unicode?
  173. except SCons.Util.RegError:
  174. raise MissingRegistryError("%s\\%s was not found in the registry."%(K, valuename))
  175. def get_all_compiler_versions():
  176. """Returns a sorted list of strings, like "70" or "80" or "9.0"
  177. with most recent compiler version first.
  178. """
  179. versions=[]
  180. if is_windows:
  181. if is_win64:
  182. keyname = 'Software\\WoW6432Node\\Intel\\Compilers\\C++'
  183. else:
  184. keyname = 'Software\\Intel\\Compilers\\C++'
  185. try:
  186. k = SCons.Util.RegOpenKeyEx(SCons.Util.HKEY_LOCAL_MACHINE,
  187. keyname)
  188. except SCons.Util.WinError:
  189. # For version 13 or later, check for default instance UUID
  190. if is_win64:
  191. keyname = 'Software\\WoW6432Node\\Intel\\Suites'
  192. else:
  193. keyname = 'Software\\Intel\\Suites'
  194. try:
  195. k = SCons.Util.RegOpenKeyEx(SCons.Util.HKEY_LOCAL_MACHINE,
  196. keyname)
  197. except SCons.Util.WinError:
  198. return []
  199. i = 0
  200. versions = []
  201. try:
  202. while i < 100:
  203. subkey = SCons.Util.RegEnumKey(k, i) # raises EnvironmentError
  204. # Check that this refers to an existing dir.
  205. # This is not 100% perfect but should catch common
  206. # installation issues like when the compiler was installed
  207. # and then the install directory deleted or moved (rather
  208. # than uninstalling properly), so the registry values
  209. # are still there.
  210. if subkey == 'Defaults': # Ignore default instances
  211. i = i + 1
  212. continue
  213. ok = False
  214. for try_abi in ('IA32', 'IA32e', 'IA64', 'EM64T'):
  215. try:
  216. d = get_intel_registry_value('ProductDir', subkey, try_abi)
  217. except MissingRegistryError:
  218. continue # not found in reg, keep going
  219. if os.path.exists(d): ok = True
  220. if ok:
  221. versions.append(subkey)
  222. else:
  223. try:
  224. # Registry points to nonexistent dir. Ignore this
  225. # version.
  226. value = get_intel_registry_value('ProductDir', subkey, 'IA32')
  227. except MissingRegistryError as e:
  228. # Registry key is left dangling (potentially
  229. # after uninstalling).
  230. print("scons: *** Ignoring the registry key for the Intel compiler version %s.\n" \
  231. "scons: *** It seems that the compiler was uninstalled and that the registry\n" \
  232. "scons: *** was not cleaned up properly.\n" % subkey)
  233. else:
  234. print("scons: *** Ignoring "+str(value))
  235. i = i + 1
  236. except EnvironmentError:
  237. # no more subkeys
  238. pass
  239. elif is_linux or is_mac:
  240. for d in glob.glob('/opt/intel_cc_*'):
  241. # Typical dir here is /opt/intel_cc_80.
  242. m = re.search(r'cc_(.*)$', d)
  243. if m:
  244. versions.append(m.group(1))
  245. for d in glob.glob('/opt/intel/cc*/*'):
  246. # Typical dir here is /opt/intel/cc/9.0 for IA32,
  247. # /opt/intel/cce/9.0 for EMT64 (AMD64)
  248. m = re.search(r'([0-9][0-9.]*)$', d)
  249. if m:
  250. versions.append(m.group(1))
  251. for d in glob.glob('/opt/intel/Compiler/*'):
  252. # Typical dir here is /opt/intel/Compiler/11.1
  253. m = re.search(r'([0-9][0-9.]*)$', d)
  254. if m:
  255. versions.append(m.group(1))
  256. for d in glob.glob('/opt/intel/composerxe-*'):
  257. # Typical dir here is /opt/intel/composerxe-2011.4.184
  258. m = re.search(r'([0-9][0-9.]*)$', d)
  259. if m:
  260. versions.append(m.group(1))
  261. for d in glob.glob('/opt/intel/composer_xe_*'):
  262. # Typical dir here is /opt/intel/composer_xe_2011_sp1.11.344
  263. # The _sp1 is useless, the installers are named 2011.9.x, 2011.10.x, 2011.11.x
  264. m = re.search(r'([0-9]{0,4})(?:_sp\d*)?\.([0-9][0-9.]*)$', d)
  265. if m:
  266. versions.append("%s.%s"%(m.group(1), m.group(2)))
  267. for d in glob.glob('/opt/intel/compilers_and_libraries_*'):
  268. # JPA: For the new version of Intel compiler 2016.1.
  269. m = re.search(r'([0-9]{0,4})(?:_sp\d*)?\.([0-9][0-9.]*)$', d)
  270. if m:
  271. versions.append("%s.%s"%(m.group(1), m.group(2)))
  272. def keyfunc(str):
  273. """Given a dot-separated version string, return a tuple of ints representing it."""
  274. return [int(x) for x in str.split('.')]
  275. # split into ints, sort, then remove dups
  276. return sorted(SCons.Util.unique(versions), key=keyfunc, reverse=True)
  277. def get_intel_compiler_top(version, abi):
  278. """
  279. Return the main path to the top-level dir of the Intel compiler,
  280. using the given version.
  281. The compiler will be in <top>/bin/icl.exe (icc on linux),
  282. the include dir is <top>/include, etc.
  283. """
  284. if is_windows:
  285. if not SCons.Util.can_read_reg:
  286. raise NoRegistryModuleError("No Windows registry module was found")
  287. top = get_intel_registry_value('ProductDir', version, abi)
  288. archdir={'x86_64': 'intel64',
  289. 'amd64' : 'intel64',
  290. 'em64t' : 'intel64',
  291. 'x86' : 'ia32',
  292. 'i386' : 'ia32',
  293. 'ia32' : 'ia32'
  294. }[abi] # for v11 and greater
  295. # pre-11, icl was in Bin. 11 and later, it's in Bin/<abi> apparently.
  296. if not os.path.exists(os.path.join(top, "Bin", "icl.exe")) \
  297. and not os.path.exists(os.path.join(top, "Bin", abi, "icl.exe")) \
  298. and not os.path.exists(os.path.join(top, "Bin", archdir, "icl.exe")):
  299. raise MissingDirError("Can't find Intel compiler in %s"%(top))
  300. elif is_mac or is_linux:
  301. def find_in_2008style_dir(version):
  302. # first dir is new (>=9.0) style, second is old (8.0) style.
  303. dirs=('/opt/intel/cc/%s', '/opt/intel_cc_%s')
  304. if abi == 'x86_64':
  305. dirs=('/opt/intel/cce/%s',) # 'e' stands for 'em64t', aka x86_64 aka amd64
  306. top=None
  307. for d in dirs:
  308. if os.path.exists(os.path.join(d%version, "bin", "icc")):
  309. top = d%version
  310. break
  311. return top
  312. def find_in_2010style_dir(version):
  313. dirs=('/opt/intel/Compiler/%s/*'%version)
  314. # typically /opt/intel/Compiler/11.1/064 (then bin/intel64/icc)
  315. dirs=glob.glob(dirs)
  316. # find highest sub-version number by reverse sorting and picking first existing one.
  317. dirs.sort()
  318. dirs.reverse()
  319. top=None
  320. for d in dirs:
  321. if (os.path.exists(os.path.join(d, "bin", "ia32", "icc")) or
  322. os.path.exists(os.path.join(d, "bin", "intel64", "icc"))):
  323. top = d
  324. break
  325. return top
  326. def find_in_2011style_dir(version):
  327. # The 2011 (compiler v12) dirs are inconsistent, so just redo the search from
  328. # get_all_compiler_versions and look for a match (search the newest form first)
  329. top=None
  330. for d in glob.glob('/opt/intel/composer_xe_*'):
  331. # Typical dir here is /opt/intel/composer_xe_2011_sp1.11.344
  332. # The _sp1 is useless, the installers are named 2011.9.x, 2011.10.x, 2011.11.x
  333. m = re.search(r'([0-9]{0,4})(?:_sp\d*)?\.([0-9][0-9.]*)$', d)
  334. if m:
  335. cur_ver = "%s.%s"%(m.group(1), m.group(2))
  336. if cur_ver == version and \
  337. (os.path.exists(os.path.join(d, "bin", "ia32", "icc")) or
  338. os.path.exists(os.path.join(d, "bin", "intel64", "icc"))):
  339. top = d
  340. break
  341. if not top:
  342. for d in glob.glob('/opt/intel/composerxe-*'):
  343. # Typical dir here is /opt/intel/composerxe-2011.4.184
  344. m = re.search(r'([0-9][0-9.]*)$', d)
  345. if m and m.group(1) == version and \
  346. (os.path.exists(os.path.join(d, "bin", "ia32", "icc")) or
  347. os.path.exists(os.path.join(d, "bin", "intel64", "icc"))):
  348. top = d
  349. break
  350. return top
  351. def find_in_2016style_dir(version):
  352. # The 2016 (compiler v16) dirs are inconsistent from previous.
  353. top = None
  354. for d in glob.glob('/opt/intel/compilers_and_libraries_%s/linux'%version):
  355. if os.path.exists(os.path.join(d, "bin", "ia32", "icc")) or os.path.exists(os.path.join(d, "bin", "intel64", "icc")):
  356. top = d
  357. break
  358. return top
  359. top = find_in_2016style_dir(version) or find_in_2011style_dir(version) or find_in_2010style_dir(version) or find_in_2008style_dir(version)
  360. # print "INTELC: top=",top
  361. if not top:
  362. raise MissingDirError("Can't find version %s Intel compiler in %s (abi='%s')"%(version,top, abi))
  363. return top
  364. def generate(env, version=None, abi=None, topdir=None, verbose=0):
  365. """Add Builders and construction variables for Intel C/C++ compiler
  366. to an Environment.
  367. args:
  368. version: (string) compiler version to use, like "80"
  369. abi: (string) 'win32' or whatever Itanium version wants
  370. topdir: (string) compiler top dir, like
  371. "c:\Program Files\Intel\Compiler70"
  372. If topdir is used, version and abi are ignored.
  373. verbose: (int) if >0, prints compiler version used.
  374. """
  375. if not (is_mac or is_linux or is_windows):
  376. # can't handle this platform
  377. return
  378. if is_windows:
  379. SCons.Tool.msvc.generate(env)
  380. elif is_linux:
  381. SCons.Tool.gcc.generate(env)
  382. elif is_mac:
  383. SCons.Tool.gcc.generate(env)
  384. # if version is unspecified, use latest
  385. vlist = get_all_compiler_versions()
  386. if not version:
  387. if vlist:
  388. version = vlist[0]
  389. else:
  390. # User may have specified '90' but we need to get actual dirname '9.0'.
  391. # get_version_from_list does that mapping.
  392. v = get_version_from_list(version, vlist)
  393. if not v:
  394. raise SCons.Errors.UserError("Invalid Intel compiler version %s: "%version + \
  395. "installed versions are %s"%(', '.join(vlist)))
  396. version = v
  397. # if abi is unspecified, use ia32
  398. # alternatives are ia64 for Itanium, or amd64 or em64t or x86_64 (all synonyms here)
  399. abi = check_abi(abi)
  400. if abi is None:
  401. if is_mac or is_linux:
  402. # Check if we are on 64-bit linux, default to 64 then.
  403. uname_m = os.uname()[4]
  404. if uname_m == 'x86_64':
  405. abi = 'x86_64'
  406. else:
  407. abi = 'ia32'
  408. else:
  409. if is_win64:
  410. abi = 'em64t'
  411. else:
  412. abi = 'ia32'
  413. if version and not topdir:
  414. try:
  415. topdir = get_intel_compiler_top(version, abi)
  416. except (SCons.Util.RegError, IntelCError):
  417. topdir = None
  418. if not topdir:
  419. # Normally this is an error, but it might not be if the compiler is
  420. # on $PATH and the user is importing their env.
  421. class ICLTopDirWarning(SCons.Warnings.Warning):
  422. pass
  423. if (is_mac or is_linux) and not env.Detect('icc') or \
  424. is_windows and not env.Detect('icl'):
  425. SCons.Warnings.enableWarningClass(ICLTopDirWarning)
  426. SCons.Warnings.warn(ICLTopDirWarning,
  427. "Failed to find Intel compiler for version='%s', abi='%s'"%
  428. (str(version), str(abi)))
  429. else:
  430. # should be cleaned up to say what this other version is
  431. # since in this case we have some other Intel compiler installed
  432. SCons.Warnings.enableWarningClass(ICLTopDirWarning)
  433. SCons.Warnings.warn(ICLTopDirWarning,
  434. "Can't find Intel compiler top dir for version='%s', abi='%s'"%
  435. (str(version), str(abi)))
  436. if topdir:
  437. archdir={'x86_64': 'intel64',
  438. 'amd64' : 'intel64',
  439. 'em64t' : 'intel64',
  440. 'x86' : 'ia32',
  441. 'i386' : 'ia32',
  442. 'ia32' : 'ia32'
  443. }[abi] # for v11 and greater
  444. if os.path.exists(os.path.join(topdir, 'bin', archdir)):
  445. bindir="bin/%s"%archdir
  446. libdir="lib/%s"%archdir
  447. else:
  448. bindir="bin"
  449. libdir="lib"
  450. if verbose:
  451. print("Intel C compiler: using version %s (%g), abi %s, in '%s/%s'"%\
  452. (repr(version), linux_ver_normalize(version),abi,topdir,bindir))
  453. if is_linux:
  454. # Show the actual compiler version by running the compiler.
  455. os.system('%s/%s/icc --version'%(topdir,bindir))
  456. if is_mac:
  457. # Show the actual compiler version by running the compiler.
  458. os.system('%s/%s/icc --version'%(topdir,bindir))
  459. env['INTEL_C_COMPILER_TOP'] = topdir
  460. if is_linux:
  461. paths={'INCLUDE' : 'include',
  462. 'LIB' : libdir,
  463. 'PATH' : bindir,
  464. 'LD_LIBRARY_PATH' : libdir}
  465. for p in list(paths.keys()):
  466. env.PrependENVPath(p, os.path.join(topdir, paths[p]))
  467. if is_mac:
  468. paths={'INCLUDE' : 'include',
  469. 'LIB' : libdir,
  470. 'PATH' : bindir,
  471. 'LD_LIBRARY_PATH' : libdir}
  472. for p in list(paths.keys()):
  473. env.PrependENVPath(p, os.path.join(topdir, paths[p]))
  474. if is_windows:
  475. # env key reg valname default subdir of top
  476. paths=(('INCLUDE', 'IncludeDir', 'Include'),
  477. ('LIB' , 'LibDir', 'Lib'),
  478. ('PATH' , 'BinDir', 'Bin'))
  479. # We are supposed to ignore version if topdir is set, so set
  480. # it to the emptry string if it's not already set.
  481. if version is None:
  482. version = ''
  483. # Each path has a registry entry, use that or default to subdir
  484. for p in paths:
  485. try:
  486. path=get_intel_registry_value(p[1], version, abi)
  487. # These paths may have $(ICInstallDir)
  488. # which needs to be substituted with the topdir.
  489. path=path.replace('$(ICInstallDir)', topdir + os.sep)
  490. except IntelCError:
  491. # Couldn't get it from registry: use default subdir of topdir
  492. env.PrependENVPath(p[0], os.path.join(topdir, p[2]))
  493. else:
  494. env.PrependENVPath(p[0], path.split(os.pathsep))
  495. # print "ICL %s: %s, final=%s"%(p[0], path, str(env['ENV'][p[0]]))
  496. if is_windows:
  497. env['CC'] = 'icl'
  498. env['CXX'] = 'icl'
  499. env['LINK'] = 'xilink'
  500. else:
  501. env['CC'] = 'icc'
  502. env['CXX'] = 'icpc'
  503. # Don't reset LINK here;
  504. # use smart_link which should already be here from link.py.
  505. #env['LINK'] = '$CC'
  506. env['AR'] = 'xiar'
  507. env['LD'] = 'xild' # not used by default
  508. # This is not the exact (detailed) compiler version,
  509. # just the major version as determined above or specified
  510. # by the user. It is a float like 80 or 90, in normalized form for Linux
  511. # (i.e. even for Linux 9.0 compiler, still returns 90 rather than 9.0)
  512. if version:
  513. env['INTEL_C_COMPILER_VERSION']=linux_ver_normalize(version)
  514. if is_windows:
  515. # Look for license file dir
  516. # in system environment, registry, and default location.
  517. envlicdir = os.environ.get("INTEL_LICENSE_FILE", '')
  518. K = ('SOFTWARE\Intel\Licenses')
  519. try:
  520. k = SCons.Util.RegOpenKeyEx(SCons.Util.HKEY_LOCAL_MACHINE, K)
  521. reglicdir = SCons.Util.RegQueryValueEx(k, "w_cpp")[0]
  522. except (AttributeError, SCons.Util.RegError):
  523. reglicdir = ""
  524. defaultlicdir = r'C:\Program Files\Common Files\Intel\Licenses'
  525. licdir = None
  526. for ld in [envlicdir, reglicdir]:
  527. # If the string contains an '@', then assume it's a network
  528. # license (port@system) and good by definition.
  529. if ld and (ld.find('@') != -1 or os.path.exists(ld)):
  530. licdir = ld
  531. break
  532. if not licdir:
  533. licdir = defaultlicdir
  534. if not os.path.exists(licdir):
  535. class ICLLicenseDirWarning(SCons.Warnings.Warning):
  536. pass
  537. SCons.Warnings.enableWarningClass(ICLLicenseDirWarning)
  538. SCons.Warnings.warn(ICLLicenseDirWarning,
  539. "Intel license dir was not found."
  540. " Tried using the INTEL_LICENSE_FILE environment variable (%s), the registry (%s) and the default path (%s)."
  541. " Using the default path as a last resort."
  542. % (envlicdir, reglicdir, defaultlicdir))
  543. env['ENV']['INTEL_LICENSE_FILE'] = licdir
  544. def exists(env):
  545. if not (is_mac or is_linux or is_windows):
  546. # can't handle this platform
  547. return 0
  548. try:
  549. versions = get_all_compiler_versions()
  550. except (SCons.Util.RegError, IntelCError):
  551. versions = None
  552. detected = versions is not None and len(versions) > 0
  553. if not detected:
  554. # try env.Detect, maybe that will work
  555. if is_windows:
  556. return env.Detect('icl')
  557. elif is_linux:
  558. return env.Detect('icc')
  559. elif is_mac:
  560. return env.Detect('icc')
  561. return detected
  562. # end of file
  563. # Local Variables:
  564. # tab-width:4
  565. # indent-tabs-mode:nil
  566. # End:
  567. # vim: set expandtab tabstop=4 shiftwidth=4: