diff options
author | Corentin Noël <corentin@elementary.io> | 2017-10-03 20:26:16 +0200 |
---|---|---|
committer | Corentin Noël <corentin@elementary.io> | 2017-10-03 20:26:16 +0200 |
commit | 1320a98a33e4e9f188e5daa143316b24d0dce819 (patch) | |
tree | 82ea281b163115277e1c9524283b0d371b6c21ac /mesonbuild/compilers | |
parent | f13887b64a9d535682668960493158ae15bfbb2d (diff) | |
parent | 0c3d58baba4a61558ed9b4905f26155a3e95cf6c (diff) | |
download | meson-1320a98a33e4e9f188e5daa143316b24d0dce819.zip meson-1320a98a33e4e9f188e5daa143316b24d0dce819.tar.gz meson-1320a98a33e4e9f188e5daa143316b24d0dce819.tar.bz2 |
Merge github.com:mesonbuild/meson into vala-target-dirs
Diffstat (limited to 'mesonbuild/compilers')
-rw-r--r-- | mesonbuild/compilers/c.py | 34 | ||||
-rw-r--r-- | mesonbuild/compilers/compilers.py | 39 |
2 files changed, 73 insertions, 0 deletions
diff --git a/mesonbuild/compilers/c.py b/mesonbuild/compilers/c.py index 82b1ef0..3f9ba5c 100644 --- a/mesonbuild/compilers/c.py +++ b/mesonbuild/compilers/c.py @@ -172,6 +172,9 @@ class CCompiler(Compiler): def get_linker_search_args(self, dirname): return ['-L' + dirname] + def get_default_include_dirs(self): + return [] + def gen_import_library_args(self, implibname): """ The name of the outputted import library @@ -1056,3 +1059,34 @@ class VisualStudioCCompiler(CCompiler): # and the can not be called. return None return vs32_instruction_set_args.get(instruction_set, None) + + def get_toolset_version(self): + # See boost/config/compiler/visualc.cpp for up to date mapping + try: + version = int(''.join(self.version.split('.')[0:2])) + except: + return None + if version < 1310: + return '7.0' + elif version < 1400: + return '7.1' # (Visual Studio 2003) + elif version < 1500: + return '8.0' # (Visual Studio 2005) + elif version < 1600: + return '9.0' # (Visual Studio 2008) + elif version < 1700: + return '10.0' # (Visual Studio 2010) + elif version < 1800: + return '11.0' # (Visual Studio 2012) + elif version < 1900: + return '12.0' # (Visual Studio 2013) + elif version < 1910: + return '14.0' # (Visual Studio 2015) + elif version < 1920: + return '14.1' # (Visual Studio 2017) + return None + + def get_default_include_dirs(self): + if 'INCLUDE' not in os.environ: + return [] + return os.environ['INCLUDE'].split(os.pathsep) diff --git a/mesonbuild/compilers/compilers.py b/mesonbuild/compilers/compilers.py index 89208e0..3f088b0 100644 --- a/mesonbuild/compilers/compilers.py +++ b/mesonbuild/compilers/compilers.py @@ -13,6 +13,7 @@ # limitations under the License. import contextlib, os.path, re, tempfile +import subprocess from ..linkers import StaticLinker from .. import coredata @@ -917,6 +918,35 @@ def get_largefile_args(compiler): # those features explicitly. return [] +# TODO: The result from calling compiler should be cached. So that calling this +# function multiple times don't add latency. +def gnulike_default_include_dirs(compiler, lang): + if lang == 'cpp': + lang = 'c++' + p = subprocess.Popen( + compiler + ['-x{}'.format(lang), '-E', '-v', '-'], + stdin=subprocess.DEVNULL, + stderr=subprocess.PIPE, + stdout=subprocess.PIPE + ) + stderr = p.stderr.read().decode('utf-8') + parse_state = 0 + paths = [] + for line in stderr.split('\n'): + if parse_state == 0: + if line == '#include "..." search starts here:': + parse_state = 1 + elif parse_state == 1: + if line == '#include <...> search starts here:': + parse_state = 2 + else: + paths.append(line[1:]) + elif parse_state == 2: + if line == 'End of search list.': + break + else: + paths.append(line[1:]) + return paths class GnuCompiler: # Functionality that is common to all GNU family compilers. @@ -998,6 +1028,9 @@ class GnuCompiler: def get_instruction_set_args(self, instruction_set): return gnulike_instruction_set_args.get(instruction_set, None) + def get_default_include_dirs(self): + return gnulike_default_include_dirs(self.exelist, self.language) + class ClangCompiler: def __init__(self, clang_type): @@ -1082,6 +1115,9 @@ class ClangCompiler: def get_instruction_set_args(self, instruction_set): return gnulike_instruction_set_args.get(instruction_set, None) + def get_default_include_dirs(self): + return gnulike_default_include_dirs(self.exelist, self.language) + # Tested on linux for ICC 14.0.3, 15.0.6, 16.0.4, 17.0.1 class IntelCompiler: @@ -1132,3 +1168,6 @@ class IntelCompiler: # if self.icc_type == ICC_OSX: # return ['-bundle'] return ['-shared'] + + def get_default_include_dirs(self): + return gnulike_default_include_dirs(self.exelist, self.language) |