File: compiler_cxx.py

package info (click to toggle)
lv2fil 2.0%2B20100312.git18130f5a%2Bdfsg0-2
  • links: PTS, VCS
  • area: main
  • in suites: wheezy
  • size: 888 kB
  • sloc: python: 10,590; ansic: 1,180; makefile: 27; sh: 11
file content (56 lines) | stat: -rw-r--r-- 1,814 bytes parent folder | download | duplicates (3)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
#! /usr/bin/env python
# encoding: utf-8

#! /usr/bin/env python
# encoding: utf-8
# Matthias Jahn <jahn.matthias@freenet.de>, 2007 (pmarat)

import os, sys, imp, types
import optparse
import Utils, Action, Params, checks, Configure

def __list_possible_compiler(plattform):
	c_compiler = {
'win32':  ['msvc', 'g++'],
'cygwin': ['g++'],
'darwin': ['g++'],
'aix5':   ['g++'],
'linux':  ['g++', 'sunc++'],
'sunos':  ['sunc++', 'g++'],
'irix':   ['g++'],
'hpux':   ['g++'],
'default': ['g++']
	}
	try:
		return(c_compiler[plattform])
	except KeyError:
		return(c_compiler["default"])

def detect(conf):
	try: test_for_compiler = Params.g_options.check_cxx_compiler
	except AttributeError: raise Configure.ConfigurationError("Add set_options(opt): opt.tool_options('compiler_cxx')")
	for cxx_compiler in test_for_compiler.split():
		conf.check_tool(cxx_compiler)
		if conf.env['CXX']:
			conf.check_message("%s" %cxx_compiler, '', True)
			conf.env["COMPILER_CXX"] = "%s" %cxx_compiler #store the choosen c++ compiler
			return
		conf.check_message("%s" %cxx_compiler, '', False)
	conf.env["COMPILER_CXX"] = None

def set_options(opt):
	detected_plattform = checks.detect_platform(None)
	possible_compiler_list = __list_possible_compiler(detected_plattform)
	test_for_compiler = str(" ").join(possible_compiler_list)
	cxx_compiler_opts = opt.add_option_group("C++ Compiler Options")
	try:
		cxx_compiler_opts.add_option('--check-cxx-compiler', default="%s" % test_for_compiler,
			help='On this platform (%s) the following C++ Compiler will be checked by default: "%s"' %
								(detected_plattform, test_for_compiler),
			dest="check_cxx_compiler")
	except optparse.OptionConflictError:
		pass
	for cxx_compiler in test_for_compiler.split():
		opt.tool_options('%s' % cxx_compiler, option_group=cxx_compiler_opts)