compiler_cc.py :  » Build » Waf » waf-1.5.17 » wafadmin » Tools » Python Open Source

Home
Python Open Source
1.3.1.2 Python
2.Ajax
3.Aspect Oriented
4.Blog
5.Build
6.Business Application
7.Chart Report
8.Content Management Systems
9.Cryptographic
10.Database
11.Development
12.Editor
13.Email
14.ERP
15.Game 2D 3D
16.GIS
17.GUI
18.IDE
19.Installer
20.IRC
21.Issue Tracker
22.Language Interface
23.Log
24.Math
25.Media Sound Audio
26.Mobile
27.Network
28.Parser
29.PDF
30.Project Management
31.RSS
32.Search
33.Security
34.Template Engines
35.Test
36.UML
37.USB Serial
38.Web Frameworks
39.Web Server
40.Web Services
41.Web Unit
42.Wiki
43.Windows
44.XML
Python Open Source » Build » Waf 
Waf » waf 1.5.17 » wafadmin » Tools » compiler_cc.py
#!/usr/bin/env python
# encoding: utf-8
# Matthias Jahn jahn dt matthias t freenet dt de, 2007 (pmarat)

import os, sys, imp, types, ccroot
import optparse
import Utils, Configure, Options
from Logs import debug

c_compiler = {
  'win32':  ['msvc', 'gcc'],
  'cygwin': ['gcc'],
  'darwin': ['gcc'],
  'aix':    ['xlc', 'gcc'],
  'linux':  ['gcc', 'icc', 'suncc'],
  'sunos':  ['gcc', 'suncc'],
  'irix':   ['gcc'],
  'hpux':   ['gcc'],
  'gnu':    ['gcc'],
  'default': ['gcc']
}

def __list_possible_compiler(platform):
  try:
    return c_compiler[platform]
  except KeyError:
    return c_compiler["default"]

def detect(conf):
  """
  for each compiler for the platform, try to configure the compiler
  in theory the tools should raise a configuration error if the compiler
  pretends to be something it is not (setting CC=icc and trying to configure gcc)
  """
  try: test_for_compiler = Options.options.check_c_compiler
  except AttributeError: conf.fatal("Add set_options(opt): opt.tool_options('compiler_cc')")
  orig = conf.env
  for compiler in test_for_compiler.split():
    conf.env = orig.copy()
    try:
      conf.check_tool(compiler)
    except Configure.ConfigurationError, e:
      debug('compiler_cc: %r' % e)
    else:
      if conf.env['CC']:
        orig.table = conf.env.get_merged_dict()
        conf.env = orig
        conf.check_message(compiler, '', True)
        conf.env['COMPILER_CC'] = compiler
        break
      conf.check_message(compiler, '', False)
      break
  else:
    conf.fatal('could not configure a c compiler!')

def set_options(opt):
  build_platform = Utils.unversioned_sys_platform()
  possible_compiler_list = __list_possible_compiler(build_platform)
  test_for_compiler = ' '.join(possible_compiler_list)
  cc_compiler_opts = opt.add_option_group("C Compiler Options")
  cc_compiler_opts.add_option('--check-c-compiler', default="%s" % test_for_compiler,
    help='On this platform (%s) the following C-Compiler will be checked by default: "%s"' % (build_platform, test_for_compiler),
    dest="check_c_compiler")

  for c_compiler in test_for_compiler.split():
    opt.tool_options('%s' % c_compiler, option_group=cc_compiler_opts)

www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.