PageRenderTime 57ms CodeModel.GetById 22ms RepoModel.GetById 0ms app.codeStats 0ms

/couchjs/scons/scons-local-2.0.1/SCons/Tool/__init__.py

http://github.com/cloudant/bigcouch
Python | 681 lines | 665 code | 0 blank | 16 comment | 5 complexity | bcfa68d194e494e361b38f0f02d69de5 MD5 | raw file
Possible License(s): Apache-2.0
  1. """SCons.Tool
  2. SCons tool selection.
  3. This looks for modules that define a callable object that can modify
  4. a construction environment as appropriate for a given tool (or tool
  5. chain).
  6. Note that because this subsystem just *selects* a callable that can
  7. modify a construction environment, it's possible for people to define
  8. their own "tool specification" in an arbitrary callable function. No
  9. one needs to use or tie in to this subsystem in order to roll their own
  10. tool definition.
  11. """
  12. #
  13. # Copyright (c) 2001, 2002, 2003, 2004, 2005, 2006, 2007, 2008, 2009, 2010 The SCons Foundation
  14. #
  15. # Permission is hereby granted, free of charge, to any person obtaining
  16. # a copy of this software and associated documentation files (the
  17. # "Software"), to deal in the Software without restriction, including
  18. # without limitation the rights to use, copy, modify, merge, publish,
  19. # distribute, sublicense, and/or sell copies of the Software, and to
  20. # permit persons to whom the Software is furnished to do so, subject to
  21. # the following conditions:
  22. #
  23. # The above copyright notice and this permission notice shall be included
  24. # in all copies or substantial portions of the Software.
  25. #
  26. # THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY
  27. # KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE
  28. # WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
  29. # NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
  30. # LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
  31. # OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
  32. # WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
  33. __revision__ = "src/engine/SCons/Tool/__init__.py 5134 2010/08/16 23:02:40 bdeegan"
  34. import imp
  35. import sys
  36. import SCons.Builder
  37. import SCons.Errors
  38. import SCons.Node.FS
  39. import SCons.Scanner
  40. import SCons.Scanner.C
  41. import SCons.Scanner.D
  42. import SCons.Scanner.LaTeX
  43. import SCons.Scanner.Prog
  44. DefaultToolpath=[]
  45. CScanner = SCons.Scanner.C.CScanner()
  46. DScanner = SCons.Scanner.D.DScanner()
  47. LaTeXScanner = SCons.Scanner.LaTeX.LaTeXScanner()
  48. PDFLaTeXScanner = SCons.Scanner.LaTeX.PDFLaTeXScanner()
  49. ProgramScanner = SCons.Scanner.Prog.ProgramScanner()
  50. SourceFileScanner = SCons.Scanner.Base({}, name='SourceFileScanner')
  51. CSuffixes = [".c", ".C", ".cxx", ".cpp", ".c++", ".cc",
  52. ".h", ".H", ".hxx", ".hpp", ".hh",
  53. ".F", ".fpp", ".FPP",
  54. ".m", ".mm",
  55. ".S", ".spp", ".SPP"]
  56. DSuffixes = ['.d']
  57. IDLSuffixes = [".idl", ".IDL"]
  58. LaTeXSuffixes = [".tex", ".ltx", ".latex"]
  59. for suffix in CSuffixes:
  60. SourceFileScanner.add_scanner(suffix, CScanner)
  61. for suffix in DSuffixes:
  62. SourceFileScanner.add_scanner(suffix, DScanner)
  63. # FIXME: what should be done here? Two scanners scan the same extensions,
  64. # but look for different files, e.g., "picture.eps" vs. "picture.pdf".
  65. # The builders for DVI and PDF explicitly reference their scanners
  66. # I think that means this is not needed???
  67. for suffix in LaTeXSuffixes:
  68. SourceFileScanner.add_scanner(suffix, LaTeXScanner)
  69. SourceFileScanner.add_scanner(suffix, PDFLaTeXScanner)
  70. class Tool(object):
  71. def __init__(self, name, toolpath=[], **kw):
  72. self.name = name
  73. self.toolpath = toolpath + DefaultToolpath
  74. # remember these so we can merge them into the call
  75. self.init_kw = kw
  76. module = self._tool_module()
  77. self.generate = module.generate
  78. self.exists = module.exists
  79. if hasattr(module, 'options'):
  80. self.options = module.options
  81. def _tool_module(self):
  82. # TODO: Interchange zipimport with normal initilization for better error reporting
  83. oldpythonpath = sys.path
  84. sys.path = self.toolpath + sys.path
  85. try:
  86. try:
  87. file, path, desc = imp.find_module(self.name, self.toolpath)
  88. try:
  89. return imp.load_module(self.name, file, path, desc)
  90. finally:
  91. if file:
  92. file.close()
  93. except ImportError, e:
  94. if str(e)!="No module named %s"%self.name:
  95. raise SCons.Errors.EnvironmentError(e)
  96. try:
  97. import zipimport
  98. except ImportError:
  99. pass
  100. else:
  101. for aPath in self.toolpath:
  102. try:
  103. importer = zipimport.zipimporter(aPath)
  104. return importer.load_module(self.name)
  105. except ImportError, e:
  106. pass
  107. finally:
  108. sys.path = oldpythonpath
  109. full_name = 'SCons.Tool.' + self.name
  110. try:
  111. return sys.modules[full_name]
  112. except KeyError:
  113. try:
  114. smpath = sys.modules['SCons.Tool'].__path__
  115. try:
  116. file, path, desc = imp.find_module(self.name, smpath)
  117. module = imp.load_module(full_name, file, path, desc)
  118. setattr(SCons.Tool, self.name, module)
  119. if file:
  120. file.close()
  121. return module
  122. except ImportError, e:
  123. if str(e)!="No module named %s"%self.name:
  124. raise SCons.Errors.EnvironmentError(e)
  125. try:
  126. import zipimport
  127. importer = zipimport.zipimporter( sys.modules['SCons.Tool'].__path__[0] )
  128. module = importer.load_module(full_name)
  129. setattr(SCons.Tool, self.name, module)
  130. return module
  131. except ImportError, e:
  132. m = "No tool named '%s': %s" % (self.name, e)
  133. raise SCons.Errors.EnvironmentError(m)
  134. except ImportError, e:
  135. m = "No tool named '%s': %s" % (self.name, e)
  136. raise SCons.Errors.EnvironmentError(m)
  137. def __call__(self, env, *args, **kw):
  138. if self.init_kw is not None:
  139. # Merge call kws into init kws;
  140. # but don't bash self.init_kw.
  141. if kw is not None:
  142. call_kw = kw
  143. kw = self.init_kw.copy()
  144. kw.update(call_kw)
  145. else:
  146. kw = self.init_kw
  147. env.Append(TOOLS = [ self.name ])
  148. if hasattr(self, 'options'):
  149. import SCons.Variables
  150. if 'options' not in env:
  151. from SCons.Script import ARGUMENTS
  152. env['options']=SCons.Variables.Variables(args=ARGUMENTS)
  153. opts=env['options']
  154. self.options(opts)
  155. opts.Update(env)
  156. self.generate(env, *args, **kw)
  157. def __str__(self):
  158. return self.name
  159. ##########################################################################
  160. # Create common executable program / library / object builders
  161. def createProgBuilder(env):
  162. """This is a utility function that creates the Program
  163. Builder in an Environment if it is not there already.
  164. If it is already there, we return the existing one.
  165. """
  166. try:
  167. program = env['BUILDERS']['Program']
  168. except KeyError:
  169. import SCons.Defaults
  170. program = SCons.Builder.Builder(action = SCons.Defaults.LinkAction,
  171. emitter = '$PROGEMITTER',
  172. prefix = '$PROGPREFIX',
  173. suffix = '$PROGSUFFIX',
  174. src_suffix = '$OBJSUFFIX',
  175. src_builder = 'Object',
  176. target_scanner = ProgramScanner)
  177. env['BUILDERS']['Program'] = program
  178. return program
  179. def createStaticLibBuilder(env):
  180. """This is a utility function that creates the StaticLibrary
  181. Builder in an Environment if it is not there already.
  182. If it is already there, we return the existing one.
  183. """
  184. try:
  185. static_lib = env['BUILDERS']['StaticLibrary']
  186. except KeyError:
  187. action_list = [ SCons.Action.Action("$ARCOM", "$ARCOMSTR") ]
  188. if env.Detect('ranlib'):
  189. ranlib_action = SCons.Action.Action("$RANLIBCOM", "$RANLIBCOMSTR")
  190. action_list.append(ranlib_action)
  191. static_lib = SCons.Builder.Builder(action = action_list,
  192. emitter = '$LIBEMITTER',
  193. prefix = '$LIBPREFIX',
  194. suffix = '$LIBSUFFIX',
  195. src_suffix = '$OBJSUFFIX',
  196. src_builder = 'StaticObject')
  197. env['BUILDERS']['StaticLibrary'] = static_lib
  198. env['BUILDERS']['Library'] = static_lib
  199. return static_lib
  200. def createSharedLibBuilder(env):
  201. """This is a utility function that creates the SharedLibrary
  202. Builder in an Environment if it is not there already.
  203. If it is already there, we return the existing one.
  204. """
  205. try:
  206. shared_lib = env['BUILDERS']['SharedLibrary']
  207. except KeyError:
  208. import SCons.Defaults
  209. action_list = [ SCons.Defaults.SharedCheck,
  210. SCons.Defaults.ShLinkAction ]
  211. shared_lib = SCons.Builder.Builder(action = action_list,
  212. emitter = "$SHLIBEMITTER",
  213. prefix = '$SHLIBPREFIX',
  214. suffix = '$SHLIBSUFFIX',
  215. target_scanner = ProgramScanner,
  216. src_suffix = '$SHOBJSUFFIX',
  217. src_builder = 'SharedObject')
  218. env['BUILDERS']['SharedLibrary'] = shared_lib
  219. return shared_lib
  220. def createLoadableModuleBuilder(env):
  221. """This is a utility function that creates the LoadableModule
  222. Builder in an Environment if it is not there already.
  223. If it is already there, we return the existing one.
  224. """
  225. try:
  226. ld_module = env['BUILDERS']['LoadableModule']
  227. except KeyError:
  228. import SCons.Defaults
  229. action_list = [ SCons.Defaults.SharedCheck,
  230. SCons.Defaults.LdModuleLinkAction ]
  231. ld_module = SCons.Builder.Builder(action = action_list,
  232. emitter = "$LDMODULEEMITTER",
  233. prefix = '$LDMODULEPREFIX',
  234. suffix = '$LDMODULESUFFIX',
  235. target_scanner = ProgramScanner,
  236. src_suffix = '$SHOBJSUFFIX',
  237. src_builder = 'SharedObject')
  238. env['BUILDERS']['LoadableModule'] = ld_module
  239. return ld_module
  240. def createObjBuilders(env):
  241. """This is a utility function that creates the StaticObject
  242. and SharedObject Builders in an Environment if they
  243. are not there already.
  244. If they are there already, we return the existing ones.
  245. This is a separate function because soooo many Tools
  246. use this functionality.
  247. The return is a 2-tuple of (StaticObject, SharedObject)
  248. """
  249. try:
  250. static_obj = env['BUILDERS']['StaticObject']
  251. except KeyError:
  252. static_obj = SCons.Builder.Builder(action = {},
  253. emitter = {},
  254. prefix = '$OBJPREFIX',
  255. suffix = '$OBJSUFFIX',
  256. src_builder = ['CFile', 'CXXFile'],
  257. source_scanner = SourceFileScanner,
  258. single_source = 1)
  259. env['BUILDERS']['StaticObject'] = static_obj
  260. env['BUILDERS']['Object'] = static_obj
  261. try:
  262. shared_obj = env['BUILDERS']['SharedObject']
  263. except KeyError:
  264. shared_obj = SCons.Builder.Builder(action = {},
  265. emitter = {},
  266. prefix = '$SHOBJPREFIX',
  267. suffix = '$SHOBJSUFFIX',
  268. src_builder = ['CFile', 'CXXFile'],
  269. source_scanner = SourceFileScanner,
  270. single_source = 1)
  271. env['BUILDERS']['SharedObject'] = shared_obj
  272. return (static_obj, shared_obj)
  273. def createCFileBuilders(env):
  274. """This is a utility function that creates the CFile/CXXFile
  275. Builders in an Environment if they
  276. are not there already.
  277. If they are there already, we return the existing ones.
  278. This is a separate function because soooo many Tools
  279. use this functionality.
  280. The return is a 2-tuple of (CFile, CXXFile)
  281. """
  282. try:
  283. c_file = env['BUILDERS']['CFile']
  284. except KeyError:
  285. c_file = SCons.Builder.Builder(action = {},
  286. emitter = {},
  287. suffix = {None:'$CFILESUFFIX'})
  288. env['BUILDERS']['CFile'] = c_file
  289. env.SetDefault(CFILESUFFIX = '.c')
  290. try:
  291. cxx_file = env['BUILDERS']['CXXFile']
  292. except KeyError:
  293. cxx_file = SCons.Builder.Builder(action = {},
  294. emitter = {},
  295. suffix = {None:'$CXXFILESUFFIX'})
  296. env['BUILDERS']['CXXFile'] = cxx_file
  297. env.SetDefault(CXXFILESUFFIX = '.cc')
  298. return (c_file, cxx_file)
  299. ##########################################################################
  300. # Create common Java builders
  301. def CreateJarBuilder(env):
  302. try:
  303. java_jar = env['BUILDERS']['Jar']
  304. except KeyError:
  305. fs = SCons.Node.FS.get_default_fs()
  306. jar_com = SCons.Action.Action('$JARCOM', '$JARCOMSTR')
  307. java_jar = SCons.Builder.Builder(action = jar_com,
  308. suffix = '$JARSUFFIX',
  309. src_suffix = '$JAVACLASSSUFIX',
  310. src_builder = 'JavaClassFile',
  311. source_factory = fs.Entry)
  312. env['BUILDERS']['Jar'] = java_jar
  313. return java_jar
  314. def CreateJavaHBuilder(env):
  315. try:
  316. java_javah = env['BUILDERS']['JavaH']
  317. except KeyError:
  318. fs = SCons.Node.FS.get_default_fs()
  319. java_javah_com = SCons.Action.Action('$JAVAHCOM', '$JAVAHCOMSTR')
  320. java_javah = SCons.Builder.Builder(action = java_javah_com,
  321. src_suffix = '$JAVACLASSSUFFIX',
  322. target_factory = fs.Entry,
  323. source_factory = fs.File,
  324. src_builder = 'JavaClassFile')
  325. env['BUILDERS']['JavaH'] = java_javah
  326. return java_javah
  327. def CreateJavaClassFileBuilder(env):
  328. try:
  329. java_class_file = env['BUILDERS']['JavaClassFile']
  330. except KeyError:
  331. fs = SCons.Node.FS.get_default_fs()
  332. javac_com = SCons.Action.Action('$JAVACCOM', '$JAVACCOMSTR')
  333. java_class_file = SCons.Builder.Builder(action = javac_com,
  334. emitter = {},
  335. #suffix = '$JAVACLASSSUFFIX',
  336. src_suffix = '$JAVASUFFIX',
  337. src_builder = ['JavaFile'],
  338. target_factory = fs.Entry,
  339. source_factory = fs.File)
  340. env['BUILDERS']['JavaClassFile'] = java_class_file
  341. return java_class_file
  342. def CreateJavaClassDirBuilder(env):
  343. try:
  344. java_class_dir = env['BUILDERS']['JavaClassDir']
  345. except KeyError:
  346. fs = SCons.Node.FS.get_default_fs()
  347. javac_com = SCons.Action.Action('$JAVACCOM', '$JAVACCOMSTR')
  348. java_class_dir = SCons.Builder.Builder(action = javac_com,
  349. emitter = {},
  350. target_factory = fs.Dir,
  351. source_factory = fs.Dir)
  352. env['BUILDERS']['JavaClassDir'] = java_class_dir
  353. return java_class_dir
  354. def CreateJavaFileBuilder(env):
  355. try:
  356. java_file = env['BUILDERS']['JavaFile']
  357. except KeyError:
  358. java_file = SCons.Builder.Builder(action = {},
  359. emitter = {},
  360. suffix = {None:'$JAVASUFFIX'})
  361. env['BUILDERS']['JavaFile'] = java_file
  362. env['JAVASUFFIX'] = '.java'
  363. return java_file
  364. class ToolInitializerMethod(object):
  365. """
  366. This is added to a construction environment in place of a
  367. method(s) normally called for a Builder (env.Object, env.StaticObject,
  368. etc.). When called, it has its associated ToolInitializer
  369. object search the specified list of tools and apply the first
  370. one that exists to the construction environment. It then calls
  371. whatever builder was (presumably) added to the construction
  372. environment in place of this particular instance.
  373. """
  374. def __init__(self, name, initializer):
  375. """
  376. Note: we store the tool name as __name__ so it can be used by
  377. the class that attaches this to a construction environment.
  378. """
  379. self.__name__ = name
  380. self.initializer = initializer
  381. def get_builder(self, env):
  382. """
  383. Returns the appropriate real Builder for this method name
  384. after having the associated ToolInitializer object apply
  385. the appropriate Tool module.
  386. """
  387. builder = getattr(env, self.__name__)
  388. self.initializer.apply_tools(env)
  389. builder = getattr(env, self.__name__)
  390. if builder is self:
  391. # There was no Builder added, which means no valid Tool
  392. # for this name was found (or possibly there's a mismatch
  393. # between the name we were called by and the Builder name
  394. # added by the Tool module).
  395. return None
  396. self.initializer.remove_methods(env)
  397. return builder
  398. def __call__(self, env, *args, **kw):
  399. """
  400. """
  401. builder = self.get_builder(env)
  402. if builder is None:
  403. return [], []
  404. return builder(*args, **kw)
  405. class ToolInitializer(object):
  406. """
  407. A class for delayed initialization of Tools modules.
  408. Instances of this class associate a list of Tool modules with
  409. a list of Builder method names that will be added by those Tool
  410. modules. As part of instantiating this object for a particular
  411. construction environment, we also add the appropriate
  412. ToolInitializerMethod objects for the various Builder methods
  413. that we want to use to delay Tool searches until necessary.
  414. """
  415. def __init__(self, env, tools, names):
  416. if not SCons.Util.is_List(tools):
  417. tools = [tools]
  418. if not SCons.Util.is_List(names):
  419. names = [names]
  420. self.env = env
  421. self.tools = tools
  422. self.names = names
  423. self.methods = {}
  424. for name in names:
  425. method = ToolInitializerMethod(name, self)
  426. self.methods[name] = method
  427. env.AddMethod(method)
  428. def remove_methods(self, env):
  429. """
  430. Removes the methods that were added by the tool initialization
  431. so we no longer copy and re-bind them when the construction
  432. environment gets cloned.
  433. """
  434. for method in self.methods.values():
  435. env.RemoveMethod(method)
  436. def apply_tools(self, env):
  437. """
  438. Searches the list of associated Tool modules for one that
  439. exists, and applies that to the construction environment.
  440. """
  441. for t in self.tools:
  442. tool = SCons.Tool.Tool(t)
  443. if tool.exists(env):
  444. env.Tool(tool)
  445. return
  446. # If we fall through here, there was no tool module found.
  447. # This is where we can put an informative error message
  448. # about the inability to find the tool. We'll start doing
  449. # this as we cut over more pre-defined Builder+Tools to use
  450. # the ToolInitializer class.
  451. def Initializers(env):
  452. ToolInitializer(env, ['install'], ['_InternalInstall', '_InternalInstallAs'])
  453. def Install(self, *args, **kw):
  454. return self._InternalInstall(*args, **kw)
  455. def InstallAs(self, *args, **kw):
  456. return self._InternalInstallAs(*args, **kw)
  457. env.AddMethod(Install)
  458. env.AddMethod(InstallAs)
  459. def FindTool(tools, env):
  460. for tool in tools:
  461. t = Tool(tool)
  462. if t.exists(env):
  463. return tool
  464. return None
  465. def FindAllTools(tools, env):
  466. def ToolExists(tool, env=env):
  467. return Tool(tool).exists(env)
  468. return list(filter (ToolExists, tools))
  469. def tool_list(platform, env):
  470. other_plat_tools=[]
  471. # XXX this logic about what tool to prefer on which platform
  472. # should be moved into either the platform files or
  473. # the tool files themselves.
  474. # The search orders here are described in the man page. If you
  475. # change these search orders, update the man page as well.
  476. if str(platform) == 'win32':
  477. "prefer Microsoft tools on Windows"
  478. linkers = ['mslink', 'gnulink', 'ilink', 'linkloc', 'ilink32' ]
  479. c_compilers = ['msvc', 'mingw', 'gcc', 'intelc', 'icl', 'icc', 'cc', 'bcc32' ]
  480. cxx_compilers = ['msvc', 'intelc', 'icc', 'g++', 'c++', 'bcc32' ]
  481. assemblers = ['masm', 'nasm', 'gas', '386asm' ]
  482. fortran_compilers = ['gfortran', 'g77', 'ifl', 'cvf', 'f95', 'f90', 'fortran']
  483. ars = ['mslib', 'ar', 'tlib']
  484. other_plat_tools=['msvs','midl']
  485. elif str(platform) == 'os2':
  486. "prefer IBM tools on OS/2"
  487. linkers = ['ilink', 'gnulink', ]#'mslink']
  488. c_compilers = ['icc', 'gcc',]# 'msvc', 'cc']
  489. cxx_compilers = ['icc', 'g++',]# 'msvc', 'c++']
  490. assemblers = ['nasm',]# 'masm', 'gas']
  491. fortran_compilers = ['ifl', 'g77']
  492. ars = ['ar',]# 'mslib']
  493. elif str(platform) == 'irix':
  494. "prefer MIPSPro on IRIX"
  495. linkers = ['sgilink', 'gnulink']
  496. c_compilers = ['sgicc', 'gcc', 'cc']
  497. cxx_compilers = ['sgic++', 'g++', 'c++']
  498. assemblers = ['as', 'gas']
  499. fortran_compilers = ['f95', 'f90', 'f77', 'g77', 'fortran']
  500. ars = ['sgiar']
  501. elif str(platform) == 'sunos':
  502. "prefer Forte tools on SunOS"
  503. linkers = ['sunlink', 'gnulink']
  504. c_compilers = ['suncc', 'gcc', 'cc']
  505. cxx_compilers = ['sunc++', 'g++', 'c++']
  506. assemblers = ['as', 'gas']
  507. fortran_compilers = ['sunf95', 'sunf90', 'sunf77', 'f95', 'f90', 'f77',
  508. 'gfortran', 'g77', 'fortran']
  509. ars = ['sunar']
  510. elif str(platform) == 'hpux':
  511. "prefer aCC tools on HP-UX"
  512. linkers = ['hplink', 'gnulink']
  513. c_compilers = ['hpcc', 'gcc', 'cc']
  514. cxx_compilers = ['hpc++', 'g++', 'c++']
  515. assemblers = ['as', 'gas']
  516. fortran_compilers = ['f95', 'f90', 'f77', 'g77', 'fortran']
  517. ars = ['ar']
  518. elif str(platform) == 'aix':
  519. "prefer AIX Visual Age tools on AIX"
  520. linkers = ['aixlink', 'gnulink']
  521. c_compilers = ['aixcc', 'gcc', 'cc']
  522. cxx_compilers = ['aixc++', 'g++', 'c++']
  523. assemblers = ['as', 'gas']
  524. fortran_compilers = ['f95', 'f90', 'aixf77', 'g77', 'fortran']
  525. ars = ['ar']
  526. elif str(platform) == 'darwin':
  527. "prefer GNU tools on Mac OS X, except for some linkers and IBM tools"
  528. linkers = ['applelink', 'gnulink']
  529. c_compilers = ['gcc', 'cc']
  530. cxx_compilers = ['g++', 'c++']
  531. assemblers = ['as']
  532. fortran_compilers = ['gfortran', 'f95', 'f90', 'g77']
  533. ars = ['ar']
  534. else:
  535. "prefer GNU tools on all other platforms"
  536. linkers = ['gnulink', 'mslink', 'ilink']
  537. c_compilers = ['gcc', 'msvc', 'intelc', 'icc', 'cc']
  538. cxx_compilers = ['g++', 'msvc', 'intelc', 'icc', 'c++']
  539. assemblers = ['gas', 'nasm', 'masm']
  540. fortran_compilers = ['gfortran', 'g77', 'ifort', 'ifl', 'f95', 'f90', 'f77']
  541. ars = ['ar', 'mslib']
  542. c_compiler = FindTool(c_compilers, env) or c_compilers[0]
  543. # XXX this logic about what tool provides what should somehow be
  544. # moved into the tool files themselves.
  545. if c_compiler and c_compiler == 'mingw':
  546. # MinGW contains a linker, C compiler, C++ compiler,
  547. # Fortran compiler, archiver and assembler:
  548. cxx_compiler = None
  549. linker = None
  550. assembler = None
  551. fortran_compiler = None
  552. ar = None
  553. else:
  554. # Don't use g++ if the C compiler has built-in C++ support:
  555. if c_compiler in ('msvc', 'intelc', 'icc'):
  556. cxx_compiler = None
  557. else:
  558. cxx_compiler = FindTool(cxx_compilers, env) or cxx_compilers[0]
  559. linker = FindTool(linkers, env) or linkers[0]
  560. assembler = FindTool(assemblers, env) or assemblers[0]
  561. fortran_compiler = FindTool(fortran_compilers, env) or fortran_compilers[0]
  562. ar = FindTool(ars, env) or ars[0]
  563. other_tools = FindAllTools(other_plat_tools + [
  564. 'dmd',
  565. #TODO: merge 'install' into 'filesystem' and
  566. # make 'filesystem' the default
  567. 'filesystem',
  568. 'm4',
  569. 'wix', #'midl', 'msvs',
  570. # Parser generators
  571. 'lex', 'yacc',
  572. # Foreign function interface
  573. 'rpcgen', 'swig',
  574. # Java
  575. 'jar', 'javac', 'javah', 'rmic',
  576. # TeX
  577. 'dvipdf', 'dvips', 'gs',
  578. 'tex', 'latex', 'pdflatex', 'pdftex',
  579. # Archivers
  580. 'tar', 'zip', 'rpm',
  581. # SourceCode factories
  582. 'BitKeeper', 'CVS', 'Perforce',
  583. 'RCS', 'SCCS', # 'Subversion',
  584. ], env)
  585. tools = ([linker, c_compiler, cxx_compiler,
  586. fortran_compiler, assembler, ar]
  587. + other_tools)
  588. return [x for x in tools if x]
  589. # Local Variables:
  590. # tab-width:4
  591. # indent-tabs-mode:nil
  592. # End:
  593. # vim: set expandtab tabstop=4 shiftwidth=4: