Can extract compiler ID string.

pull/15/head
Jussi Pakkanen 12 years ago
parent 140f30470b
commit bf62937711
  1. 17
      environment.py
  2. 10
      interpreter.py
  3. 7
      test cases/common/34 compiler id/meson.build

@ -35,6 +35,10 @@ class CCompiler():
raise TypeError('Unknown argument to CCompiler')
self.language = 'c'
self.default_suffix = 'c'
self.id = 'unknown'
def get_id(self):
return self.id
def get_dependency_gen_flags(self, outtarget, outfile):
return ['-MMD', '-MT', outtarget, '-MF', outfile]
@ -201,6 +205,7 @@ class VisualStudioCCompiler(CCompiler):
def __init__(self, exelist):
CCompiler.__init__(self, exelist)
self.id = 'msvc'
def get_std_warn_flags(self):
return VisualStudioCCompiler.std_warn_flags
@ -287,6 +292,7 @@ class GnuCCompiler(CCompiler):
def __init__(self, exelist):
CCompiler.__init__(self, exelist)
self.id = 'gcc'
def get_std_warn_flags(self):
return GnuCCompiler.std_warn_flags
@ -300,6 +306,10 @@ class GnuCCompiler(CCompiler):
class GnuObjCCompiler(ObjCCompiler):
std_warn_flags = ['-Wall', '-Winvalid-pch']
std_opt_flags = ['-O2']
def __init__(self, exelist):
ObjCCompiler.__init__(self, exelist)
self.id = 'gcc'
def get_std_warn_flags(self):
return GnuObjCCompiler.std_warn_flags
@ -314,6 +324,10 @@ class GnuObjCXXCompiler(ObjCXXCompiler):
std_warn_flags = ['-Wall', '-Winvalid-pch']
std_opt_flags = ['-O2']
def __init__(self, exelist):
ObjCCompiler.__init__(self, exelist)
self.id = 'gcc'
def get_std_warn_flags(self):
return GnuObjCXXCompiler.std_warn_flags
@ -329,6 +343,7 @@ class ClangCCompiler(CCompiler):
def __init__(self, exelist):
CCompiler.__init__(self, exelist)
self.id = 'clang'
def get_std_warn_flags(self):
return ClangCCompiler.std_warn_flags
@ -345,6 +360,7 @@ class GnuCXXCompiler(CXXCompiler):
def __init__(self, exelist):
CXXCompiler.__init__(self, exelist)
self.id = 'gcc'
def get_std_warn_flags(self):
return GnuCXXCompiler.std_warn_flags
@ -361,6 +377,7 @@ class ClangCXXCompiler(CXXCompiler):
def __init__(self, exelist):
CXXCompiler.__init__(self, exelist)
self.id = 'clang'
def get_std_warn_flags(self):
return ClangCXXCompiler.std_warn_flags

@ -500,7 +500,12 @@ class CompilerHolder(InterpreterObject):
def __init__(self, compiler):
InterpreterObject.__init__(self)
self.compiler = compiler
self.methods.update({'compiles': self.compiles_method})
self.methods.update({'compiles': self.compiles_method,
'get_id': self.get_id_method,
})
def get_id_method(self, args, kwargs):
return self.compiler.get_id()
def compiles_method(self, args, kwargs):
if len(args) != 1:
@ -665,7 +670,7 @@ class Interpreter():
print('Project name is "%s".' % self.build.project)
self.add_languages(node, args[1:])
def func_message(self, node, args):
def func_message(self, node, args, kwargs):
self.validate_arguments(args, 1, [str])
print('Message: %s' % args[0])
@ -874,6 +879,7 @@ class Interpreter():
if isinstance(value, InterpreterObject) or \
isinstance(value, dependencies.Dependency) or\
isinstance(value, nodes.StringStatement) or\
isinstance(value, str) or\
isinstance(value, nodes.BoolStatement) or\
isinstance(value, nodes.IntStatement) or\
isinstance(value, list):

@ -0,0 +1,7 @@
project('compiler id', 'c')
comp = meson.get_compiler('c')
str = comp.get_id()
message('Compiler name is:')
message(str)
Loading…
Cancel
Save