Advertisement
Guest User

Untitled

a guest
Oct 11th, 2014
900
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 14.84 KB | None | 0 0
  1. # Copyright Vladimir Prus 2004.
  2. # Distributed under the Boost Software License, Version 1.0.
  3. # (See accompanying file LICENSE_1_0.txt
  4. # or copy at http://www.boost.org/LICENSE_1_0.txt)
  5.  
  6. # Importing common is needed because the rules we inherit here depend on it.
  7. # That is nasty.
  8. import common ;
  9. import errors ;
  10. import feature ;
  11. import intel ;
  12. import msvc ;
  13. import os ;
  14. import set ;
  15. import toolset ;
  16. import generators ;
  17. import type ;
  18. import path ;
  19.  
  20. feature.extend-subfeature toolset intel : platform : win ;
  21.  
  22. toolset.inherit-generators intel-win <toolset>intel <toolset-intel:platform>win : msvc ;
  23. toolset.inherit-flags intel-win : msvc : : YLOPTION ;
  24. toolset.inherit-rules intel-win : msvc ;
  25.  
  26. # Override default do-nothing generators.
  27. generators.override intel-win.compile.c.pch : pch.default-c-pch-generator ;
  28. generators.override intel-win.compile.c++.pch : pch.default-cpp-pch-generator ;
  29. generators.override intel-win.compile.rc : rc.compile.resource ;
  30. generators.override intel-win.compile.mc : mc.compile ;
  31.  
  32. toolset.flags intel-win.compile PCH_SOURCE <pch>on : <pch-source> ;
  33.  
  34. toolset.add-requirements <toolset>intel-win,<runtime-link>shared:<threading>multi ;
  35.  
  36. # Initializes the intel toolset for windows
  37. rule init ( version ? : # the compiler version
  38. command * : # the command to invoke the compiler itself
  39. options * # Additional option: <compatibility>
  40. # either 'vc6', 'vc7', 'vc7.1'
  41. # or 'native'(default).
  42. )
  43. {
  44. if $(version)
  45. {
  46. configure $(version) : $(command) : $(options) ;
  47. }
  48. else
  49. {
  50. if $(command)
  51. {
  52. errors.error "Autodetect of version from command not implemented!" ;
  53. }
  54. local intel_versions = [ get-autodetect-versions () ] ;
  55. if ! $(intel_versions)
  56. {
  57. errors.error "No intel compiler version found!" ;
  58. }
  59. else
  60. {
  61. local msvc-version = [ feature.get-values <compatibility> : $(options) ] ; # On auto config mode the user can still request a msvc backend. If some intel compiler doesn't support it, don't try to configure it!
  62. msvc-version = [ get-msvc-version-from-vc-string $(msvc-version) ] ;
  63. for local v in $(intel_versions)
  64. {
  65. if [ is-msvc-supported $(v) : $(msvc-version) ]
  66. {
  67. configure $(v) : : $(options) ;
  68. }
  69. }
  70. }
  71. }
  72. }
  73.  
  74. local rule configure ( version ? : command * : options * )
  75. {
  76. local compatibility =
  77. [ feature.get-values <compatibility> : $(options) ] ;
  78. # Allow to specify toolset and visual studio backend from commandline .e.g --toolset=intel-14.0-vc10
  79. local vc_in_version = [ MATCH (vc[0-9]+(\\.[0-9]+)?)$ : $(version) ] ;
  80. vc_in_version = $(vc_in_version[1]) ;
  81. if $(compatibility) && $(vc_in_version)
  82. {
  83. if $(compatibility) != $(vc_in_version)
  84. {
  85. errors.error "feature compatibility and vc version in toolset present!" ;
  86. }
  87. }
  88.  
  89. if $(vc_in_version) && ! $(compatibility)
  90. {
  91. # vc Version must be stripped before check-init-parameters is called!
  92. version = [ MATCH (.+)-vc.+$ : $(version) ] ;
  93.  
  94. compatibility = $(vc_in_version) ;
  95. options += <compatibility>$(vc_in_version) ;
  96. }
  97. if $(compatibility)
  98. {
  99. configure-really $(version) : $(command) : $(options) : $(compatibility) ;
  100. }
  101. else
  102. {
  103. local msvc_versions = [ feature.values <toolset-msvc:version> ] ;
  104. if ! $(msvc_versions)
  105. {
  106. ECHO notice: no msvc versions detected. trying auto detect ;
  107. toolset.using msvc : all ;
  108. msvc_versions = [ feature.values <toolset-msvc:version> ] ;
  109. }
  110. if ! $(.iclvars-$(version)-supported-vcs)
  111. {
  112. errors.error "Supported msvc versions not known for intel $(version)" ;
  113. }
  114.  
  115. for local v in $(msvc_versions)
  116. {
  117. if [ MATCH "($(v))" : $(.iclvars-$(version)-supported-vcs) ]
  118. {
  119. # Strip trailing .0 from msvc version as intel compiler uses atm only major version for Qvc
  120. local m = [ MATCH ([0-9]+).0$ : $(v) ] ;
  121. if $(m)
  122. {
  123. v = $(m) ;
  124. }
  125. v = "vc$(v)" ;
  126. local options_really = $(options) ;
  127. options_really += <compatibility>$(v) ;
  128. if $(.debug-configuration)
  129. {
  130. ECHO "configure: intel version: $(version) msvc version: $(v)" ;
  131. }
  132. configure-really $(version) : $(command) : $(options) : $(v) ;
  133. }
  134. }
  135. if ! [ feature.values <toolset-intel:version> ]
  136. {
  137. errors.error "Failed to register an intel toolset!" ;
  138. }
  139. }
  140. }
  141.  
  142. local rule configure-really ( version ? : command * : options * : compatibility )
  143. {
  144. local condition = [ common.check-init-parameters intel-win
  145. : version $(version) : compatibility $(compatibility) ] ;
  146.  
  147. local m = [ MATCH ([0-9]+).* : $(version) ] ;
  148. local major = $(m[1]) ;
  149. if ! $(major)
  150. {
  151. errors.error "Major version not found: $(version)" ;
  152. }
  153.  
  154. local msvc-version = [ get-msvc-version-from-vc-string $(compatibility) ] ;
  155. if ! $(msvc-version)
  156. {
  157. errors.user-error "Invalid value for compatibility option:"
  158. $(compatibility) ;
  159. }
  160.  
  161. command = [ get-compiler-invocation-cmd $(major) : $(command) ] ;
  162.  
  163. common.handle-options intel-win : $(condition) : $(command) : $(options) ;
  164.  
  165. local root ;
  166. if $(command)
  167. {
  168. root = [ common.get-absolute-tool-path $(command[-1]) ] ;
  169. if $(major) >= 12
  170. {
  171. root = [ path.make $(root) ] ;
  172. root = [ path.parent $(root) ] ;
  173. }
  174. root = $(root)/ ;
  175. }
  176.  
  177. local setup ;
  178. setup = [ GLOB $(root) : iclvars_*.bat ] ;
  179. if ! $(setup)
  180. {
  181. setup = [ path.join $(root) "iclvars.bat" ] ;
  182. setup = [ path.native $(setup) ] ;
  183. }
  184.  
  185. local target_types ;
  186. local iclvars_vs_arg ;
  187. if $(major) >= 12
  188. {
  189. # if we have a known intel toolset check for visual studio compatibility
  190. # if not trust parameters
  191. if ! [ is-msvc-supported $(version) : $(msvc-version) ]
  192. {
  193. errors.error "msvc $(msvc-version) not supported for intel toolset version $(version)" ;
  194. }
  195. if $(.iclvars-version-alias-$(compatibility))
  196. {
  197. iclvars_vs_arg = $(.iclvars-version-alias-$(compatibility)) ;
  198. }
  199. else
  200. {
  201. errors.error "Don't know what parameter to pass for vc version ( $(compatibility) )" ;
  202. }
  203. if [ MATCH ^(AMD64) : [ os.environ PROCESSOR_ARCHITECTURE ] ]
  204. {
  205. target_types = ia32 intel64 ;
  206. }
  207. else
  208. {
  209. target_types = ia32 ia32_intel64 ;
  210. }
  211. }
  212. else
  213. {
  214. target_types = default ;
  215. iclvars_vs_arg = $(compatibility) ;
  216. }
  217.  
  218. local default-assembler-intel64 = ml64 ;
  219. local default-assembler-ia32_intel64 = ml64 ;
  220. local default-assembler-ia32 = "ml -coff" ;
  221. assembler = [ feature.get-values <assembler> : $(options) ] ;
  222.  
  223. for local c in $(target_types)
  224. {
  225. local cpu-conditions ;
  226. local setup-call ;
  227. if $(major) >= 12
  228. {
  229. setup-call = "call \""$(setup)"\" $(c) $(iclvars_vs_arg) > nul " ;
  230. cpu-conditions = $(condition)/$(.cpu-arch-$(c)) ;
  231. }
  232. else
  233. {
  234. setup-call = "call \""$(setup)"\" $(compatibility) > nul " ;
  235. cpu-conditions = $(condition) ;
  236. }
  237.  
  238.  
  239. if [ os.name ] = NT
  240. {
  241. setup-call = $(setup-call)"
  242. " ;
  243. }
  244. else
  245. {
  246. setup-call = "cmd /S /C "$(setup-call)" \"&&\" " ;
  247. }
  248.  
  249. if $(.debug-configuration)
  250. {
  251. for local cond in $(cpu-conditions)
  252. {
  253. ECHO "notice: [intel-cfg] condition: '$(cond)', setup: '$(setup-call)'" ;
  254. }
  255. }
  256.  
  257. local cpu-assembler = $(assembler) ;
  258. cpu-assembler ?= $(default-assembler-$(c)) ;
  259.  
  260. toolset.flags intel-win.compile .CC $(cpu-conditions) : $(setup-call)icl ;
  261. toolset.flags intel-win.link .LD $(cpu-conditions) : $(setup-call)xilink /nologo ;
  262. toolset.flags intel-win.archive .LD $(cpu-conditions) : $(setup-call)xilink /lib /nologo ;
  263. toolset.flags intel-win.link .MT $(cpu-conditions) : $(setup-call)mt -nologo ;
  264. toolset.flags intel-win.compile .ASM $(cpu-conditions) : $(setup-call)$(cpu-assembler) -nologo ;
  265. toolset.flags intel-win.compile .MC $(cpu-conditions) : $(setup-call)mc ;
  266. toolset.flags intel-win.compile .RC $(cpu-conditions) : $(setup-call)rc ;
  267. }
  268.  
  269. # Depending on the settings, running of tests require some runtime DLLs.
  270. toolset.flags intel-win RUN_PATH $(condition) : $(root) ;
  271.  
  272.  
  273. local C++FLAGS ;
  274.  
  275. C++FLAGS += /nologo ;
  276.  
  277. # Reduce the number of spurious error messages
  278. C++FLAGS += /Qwn5 /Qwd985 ;
  279.  
  280. # Enable ADL
  281. C++FLAGS += -Qoption,c,--arg_dep_lookup ; #"c" works for C++, too
  282.  
  283. # Disable Microsoft "secure" overloads in Dinkumware libraries since they
  284. # cause compile errors with Intel versions 9 and 10.
  285. if $(major) < 12
  286. {
  287. C++FLAGS += -D_SECURE_SCL=0 ;
  288. }
  289.  
  290. if $(major) > 5
  291. {
  292. C++FLAGS += /Zc:forScope ; # Add support for correct for loop scoping.
  293. }
  294.  
  295. # Add options recognized only by intel7 and above.
  296. if $(major) >= 7
  297. {
  298. C++FLAGS += /Qansi_alias ;
  299. }
  300.  
  301. if $(compatibility) = vc6
  302. {
  303. C++FLAGS +=
  304. # Emulate VC6
  305. /Qvc6
  306.  
  307. # No wchar_t support in vc6 dinkum library. Furthermore, in vc6
  308. # compatibility-mode, wchar_t is not a distinct type from unsigned
  309. # short.
  310. -DBOOST_NO_INTRINSIC_WCHAR_T
  311. ;
  312. }
  313. else
  314. {
  315. if $(major) > 5
  316. {
  317. # Add support for wchar_t
  318. C++FLAGS += /Zc:wchar_t
  319. # Tell the dinkumware library about it.
  320. -D_NATIVE_WCHAR_T_DEFINED
  321. ;
  322. }
  323. }
  324.  
  325. if $(compatibility) && $(compatibility) != native
  326. {
  327. C++FLAGS += /Q$(compatibility) ;
  328. }
  329. else
  330. {
  331. C++FLAGS +=
  332. -Qoption,cpp,--arg_dep_lookup
  333. # The following options were intended to disable the Intel compiler's
  334. # 'bug-emulation' mode, but were later reported to be causing ICE with
  335. # Intel-Win 9.0. It is not yet clear which options can be safely used.
  336. # -Qoption,cpp,--const_string_literals
  337. # -Qoption,cpp,--new_for_init
  338. # -Qoption,cpp,--no_implicit_typename
  339. # -Qoption,cpp,--no_friend_injection
  340. # -Qoption,cpp,--no_microsoft_bugs
  341. ;
  342. }
  343.  
  344. toolset.flags intel-win CFLAGS $(condition) : $(C++FLAGS) ;
  345. # By default, when creating PCH, intel adds 'i' to the explicitly
  346. # specified name of the PCH file. Of course, Boost.Build is not
  347. # happy when compiler produces not the file it was asked for.
  348. # The option below stops this behaviour.
  349. toolset.flags intel-win CFLAGS : -Qpchi- ;
  350.  
  351. if ! $(compatibility)
  352. {
  353. # If there's no backend version, assume 7.1.
  354. compatibility = vc7.1 ;
  355. }
  356.  
  357. msvc.configure-version-specific intel-win : $(msvc-version) : $(condition) ;
  358. }
  359.  
  360. local rule get-autodetect-versions
  361. {
  362. local result ;
  363. for local v in $(.intel-autodetect-versions)
  364. {
  365. local major = [ MATCH ([0-9]+).* : $(v) ] ; # Use only major version
  366. if [ get-icl-path-from-environment $(major) ]
  367. {
  368. result += $(v) ;
  369. }
  370. }
  371. return $(result) ;
  372. }
  373.  
  374. local rule get-icl-path-from-environment ( major_version )
  375. {
  376. local path = [ os.environ ICPP_COMPILER$(major_version) ] ;
  377. if $(path)
  378. {
  379. path = [ path.make $(path) ] ;
  380. local cmdpath ;
  381. local subdirs = $(.icl-target-subdirectories) ;
  382. while $(subdirs)
  383. {
  384. cmdpath = [ path.join $(path) "bin/$(subdirs[0])/icl.exe" ] ;
  385. cmdpath = [ path.native $(cmdpath) ] ;
  386. if [ path.exists $(cmdpath) ]
  387. {
  388. subdirs = ;
  389. } else {
  390. cmdpath = ;
  391. subdirs = $(subdirs[2-]) ;
  392. }
  393. }
  394. path = $(cmdpath) ;
  395. }
  396. return $(path) ;
  397. }
  398.  
  399. local rule get-compiler-invocation-cmd ( major_version : command * )
  400. {
  401. if $(command)
  402. {
  403. return [ common.get-invocation-command intel-win : icl.exe : $(command) ] ;
  404. }
  405. else
  406. {
  407. local path = [ get-icl-path-from-environment $(major_version) ] ;
  408. return [ common.get-invocation-command intel-win : icl.exe : $(path) ] ;
  409. }
  410. }
  411.  
  412. local rule is-msvc-supported ( intel-version : msvc-version )
  413. {
  414. if ! $(msvc-version)
  415. {
  416. return true ;
  417. }
  418. else
  419. {
  420. if $(.iclvars-$(intel-version)-supported-vcs)
  421. {
  422. if [ MATCH "($(msvc-version))" : $(.iclvars-$(intel-version)-supported-vcs) ]
  423. {
  424. return true ;
  425. }
  426. }
  427. else
  428. {
  429. return true ;
  430. }
  431. }
  432. }
  433.  
  434. local rule get-msvc-version-from-vc-string ( vc-string )
  435. {
  436. local r = [ MATCH "^vc([0-9]+(\\.[0-9]+)?)$" : $(vc-string) ] ;
  437. return $(r[1]) ;
  438. }
  439.  
  440. if [ MATCH (--debug-configuration) : [ modules.peek : ARGV ] ]
  441. {
  442. .debug-configuration = true ;
  443. }
  444.  
  445. # Copied from msvc.jam
  446. # Supported CPU architectures.
  447. .cpu-arch-ia32 =
  448. <architecture>/<address-model>
  449. <architecture>/<address-model>32
  450. <architecture>x86/<address-model>
  451. <architecture>x86/<address-model>32 ;
  452.  
  453. .cpu-arch-intel64 =
  454. <architecture>/<address-model>64
  455. <architecture>x86/<address-model>64 ;
  456.  
  457. .cpu-arch-ia32_intel64 =
  458. <architecture>/<address-model>64
  459. <architecture>x86/<address-model>64 ;
  460.  
  461. .intel-autodetect-versions = 15.0 14.0 13.0 12.0 ;
  462. .iclvars-12.0-supported-vcs = "10.0 9.0 8.0" ;
  463. .iclvars-12.1-supported-vcs = "10.0 9.0 8.0" ;
  464. .iclvars-13.0-supported-vcs = "11.0 10.0 9.0" ;
  465. .iclvars-14.0-supported-vcs = "12.0 11.0 10.0 9.0" ;
  466. .iclvars-15.0-supported-vcs = "14.0 12.0 11.0 10.0 9.0" ;
  467. .iclvars-version-alias-vc12 = vs2013 ;
  468. .iclvars-version-alias-vc11 = vs2012 ;
  469. .iclvars-version-alias-vc10 = vs2010 ;
  470. .iclvars-version-alias-vc9 = vs2008 ;
  471. .iclvars-version-alias-vc8 = vs2005 ;
  472. .icl-target-subdirectories = ia32 ia32_intel64 intel64 ;
  473.  
  474. toolset.flags intel-win.link LIBRARY_OPTION <toolset>intel : "" ;
  475.  
  476. toolset.flags intel-win YLOPTION ;
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement