files: # Copyright 2017 The Meson development team
  
  # Licensed under the Apache License, Version 2.0 (the "License");
  # you may not use this file except in compliance with the License.
  # You may obtain a copy of the License at
  
  #     http://www.apache.org/licenses/LICENSE-2.0
  
  # Unless required by applicable law or agreed to in writing, software
  # distributed under the License is distributed on an "AS IS" BASIS,
  # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  # See the License for the specific language governing permissions and
  # limitations under the License.
  
  # Public symbols for compilers sub-package when using 'from . import compilers'
  __all__ = [
      'CompilerType',
  
      'all_languages',
      'base_options',
      'clib_langs',
      'clink_langs',
      'c_suffixes',
      'cpp_suffixes',
      'get_macos_dylib_install_name',
      'get_base_compile_args',
      'get_base_link_args',
      'is_assembly',
      'is_header',
      'is_library',
      'is_llvm_ir',
      'is_object',
      'is_source',
      'lang_suffixes',
      'sanitizer_compile_args',
      'sort_clink',
  
      'ArmCCompiler',
      'ArmCPPCompiler',
      'ArmclangCCompiler',
      'ArmclangCPPCompiler',
      'CCompiler',
      'ClangCCompiler',
      'ClangCompiler',
      'ClangCPPCompiler',
      'ClangObjCCompiler',
      'ClangObjCPPCompiler',
      'CompilerArgs',
      'CPPCompiler',
      'DCompiler',
      'DmdDCompiler',
      'FortranCompiler',
      'G95FortranCompiler',
      'GnuCCompiler',
      'ElbrusCCompiler',
      'GnuCompiler',
      'GnuCPPCompiler',
      'ElbrusCPPCompiler',
      'GnuDCompiler',
      'GnuFortranCompiler',
      'ElbrusFortranCompiler',
      'GnuObjCCompiler',
      'GnuObjCPPCompiler',
      'IntelCompiler',
      'IntelCCompiler',
      'IntelCPPCompiler',
      'IntelFortranCompiler',
      'JavaCompiler',
      'LLVMDCompiler',
      'MonoCompiler',
      'VisualStudioCsCompiler',
      'NAGFortranCompiler',
      'ObjCCompiler',
      'ObjCPPCompiler',
      'Open64FortranCompiler',
      'PathScaleFortranCompiler',
      'PGIFortranCompiler',
      'RustCompiler',
      'SunFortranCompiler',
      'SwiftCompiler',
      'ValaCompiler',
      'VisualStudioCCompiler',
      'VisualStudioCPPCompiler',
  ]
  
  # Bring symbols from each module into compilers sub-package namespace
  from .compilers import (
      CompilerType,
      all_languages,
      base_options,
      clib_langs,
      clink_langs,
      c_suffixes,
      cpp_suffixes,
      get_macos_dylib_install_name,
      get_base_compile_args,
      get_base_link_args,
      is_header,
      is_source,
      is_assembly,
      is_llvm_ir,
      is_object,
      is_library,
      lang_suffixes,
      sanitizer_compile_args,
      sort_clink,
      ClangCompiler,
      CompilerArgs,
      GnuCompiler,
      IntelCompiler,
  )
  from .c import (
      CCompiler,
      ArmCCompiler,
      ArmclangCCompiler,
      ClangCCompiler,
      GnuCCompiler,
      ElbrusCCompiler,
      IntelCCompiler
  
  [... the rest is omitted ...]
files: mesonbuild/compilers/__init__.py
files: # Copyright 2017 The Meson development team
  
  # Licensed under the Apache License, Version 2.0 (the "License");
  # you may not use this file except in compliance with the License.
  # You may obtain a copy of the License at
  
  #     http://www.apache.org/licenses/LICENSE-2.0
  
  # Unless required by applicable law or agreed to in writing, software
  # distributed under the License is distributed on an "AS IS" BASIS,
  # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  # See the License for the specific language governing permissions and
  # limitations under the License.
  
  # Public symbols for compilers sub-package when using 'from . import compilers'
  __all__ = [
      'CLANG_OSX',
      'CLANG_STANDARD',
      'CLANG_WIN',
      'GCC_CYGWIN',
      'GCC_MINGW',
      'GCC_OSX',
      'GCC_STANDARD',
      'ICC_OSX',
      'ICC_STANDARD',
      'ICC_WIN',
  
      'all_languages',
      'base_options',
      'clib_langs',
      'clink_langs',
      'c_suffixes',
      'cpp_suffixes',
      'get_macos_dylib_install_name',
      'get_base_compile_args',
      'get_base_link_args',
      'is_assembly',
      'is_header',
      'is_library',
      'is_llvm_ir',
      'is_object',
      'is_source',
      'lang_suffixes',
      'sanitizer_compile_args',
      'sort_clink',
  
      'ArmCCompiler',
      'ArmCPPCompiler',
      'ArmclangCCompiler',
      'ArmclangCPPCompiler',
      'CCompiler',
      'ClangCCompiler',
      'ClangCompiler',
      'ClangCPPCompiler',
      'ClangObjCCompiler',
      'ClangObjCPPCompiler',
      'CompilerArgs',
      'CPPCompiler',
      'DCompiler',
      'DmdDCompiler',
      'FortranCompiler',
      'G95FortranCompiler',
      'GnuCCompiler',
      'ElbrusCCompiler',
      'GnuCompiler',
      'GnuCPPCompiler',
      'ElbrusCPPCompiler',
      'GnuDCompiler',
      'GnuFortranCompiler',
      'ElbrusFortranCompiler',
      'GnuObjCCompiler',
      'GnuObjCPPCompiler',
      'IntelCompiler',
      'IntelCCompiler',
      'IntelCPPCompiler',
      'IntelFortranCompiler',
      'JavaCompiler',
      'LLVMDCompiler',
      'MonoCompiler',
      'VisualStudioCsCompiler',
      'NAGFortranCompiler',
      'ObjCCompiler',
      'ObjCPPCompiler',
      'Open64FortranCompiler',
      'PathScaleFortranCompiler',
      'PGIFortranCompiler',
      'RustCompiler',
      'SunFortranCompiler',
      'SwiftCompiler',
      'ValaCompiler',
      'VisualStudioCCompiler',
      'VisualStudioCPPCompiler',
  ]
  
  # Bring symbols from each module into compilers sub-package namespace
  from .compilers import (
      GCC_OSX,
      GCC_MINGW,
      GCC_CYGWIN,
      GCC_STANDARD,
      CLANG_OSX,
      CLANG_WIN,
      CLANG_STANDARD,
      ICC_OSX,
      ICC_WIN,
      ICC_STANDARD,
      all_languages,
      base_options,
      clib_langs,
      clink_langs,
      c_suffixes,
      cpp_suffixes,
      get_macos_dylib_
  
  [... the rest is omitted ...]
files: mesonbuild/compilers/__init__.py
files: # Copyright 2012-2017 The Meson development team
  
  # Licensed under the Apache License, Version 2.0 (the "License");
  # you may not use this file except in compliance with the License.
  # You may obtain a copy of the License at
  
  #     http://www.apache.org/licenses/LICENSE-2.0
  
  # Unless required by applicable law or agreed to in writing, software
  # distributed under the License is distributed on an "AS IS" BASIS,
  # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  # See the License for the specific language governing permissions and
  # limitations under the License.
  
  import re
  import glob
  import os.path
  import subprocess
  import functools
  import itertools
  from pathlib import Path
  
  from .. import mlog
  from .. import coredata
  from . import compilers
  from ..mesonlib import (
      EnvironmentException, MesonException, version_compare, Popen_safe, listify,
      for_windows, for_darwin, for_cygwin, for_haiku, for_openbsd,
  )
  from .c_function_attributes import C_FUNC_ATTRIBUTES
  
  from .compilers import (
      CompilerType,
      get_largefile_args,
      gnu_winlibs,
      msvc_winlibs,
      vs32_instruction_set_args,
      vs64_instruction_set_args,
      ArmCompiler,
      ArmclangCompiler,
      ClangCompiler,
      Compiler,
      CompilerArgs,
      CrossNoRunException,
      GnuCompiler,
      ElbrusCompiler,
      IntelCompiler,
      RunResult,
  )
  
  gnu_compiler_internal_libs = ('m', 'c', 'pthread', 'dl', 'rt')
  
  
  class CCompiler(Compiler):
      # TODO: Replace this manual cache with functools.lru_cache
      library_dirs_cache = {}
      program_dirs_cache = {}
      find_library_cache = {}
      internal_libs = gnu_compiler_internal_libs
  
      @staticmethod
      def attribute_check_func(name):
          try:
              return C_FUNC_ATTRIBUTES[name]
          except KeyError:
              raise MesonException('Unknown function attribute "{}"'.format(name))
  
      def __init__(self, exelist, version, is_cross, exe_wrapper=None, **kwargs):
          # If a child ObjC or CPP class has already set it, don't set it ourselves
          if not hasattr(self, 'language'):
              self.language = 'c'
          super().__init__(exelist, version, **kwargs)
          self.id = 'unknown'
          self.is_cross = is_cross
          self.can_compile_suffixes.add('h')
          # If the exe wrapper was not found, pretend it wasn't set so that the
          # sanity check is skipped and compiler checks use fallbacks.
          if not exe_wrapper or not exe_wrapper.found():
              self.exe_wrapper = None
          else:
              self.exe_wrapper = exe_wrapper.get_command()
  
          # Set to None until we actually need to check this
          self.has_fatal_warnings_link_arg = None
  
      def needs_static_linker(self):
          return True # When compiling static libraries, so yes.
  
      def get_always_args(self):
          '''
          Args that are always-on for all C compilers other than MSVC
          '''
          return ['-pipe'] + get_largefile_args(self)
  
      def get_linker_debug_crt_args(self):
          """
          Arguments needed to select a debug crt for the linker
          This is only needed for MSVC
          """
          return []
  
      def get_no_stdinc_args(self):
          return
  
  [... the rest is omitted ...]
files: mesonbuild/compilers/c.py
files: # Copyright 2012-2017 The Meson development team
  
  # Licensed under the Apache License, Version 2.0 (the "License");
  # you may not use this file except in compliance with the License.
  # You may obtain a copy of the License at
  
  #     http://www.apache.org/licenses/LICENSE-2.0
  
  # Unless required by applicable law or agreed to in writing, software
  # distributed under the License is distributed on an "AS IS" BASIS,
  # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  # See the License for the specific language governing permissions and
  # limitations under the License.
  
  import re
  import glob
  import os.path
  import subprocess
  import functools
  import itertools
  from pathlib import Path
  
  from .. import mlog
  from .. import coredata
  from . import compilers
  from ..mesonlib import (
      EnvironmentException, MesonException, version_compare, Popen_safe, listify,
      for_windows, for_darwin, for_cygwin, for_haiku, for_openbsd,
  )
  from .c_function_attributes import C_FUNC_ATTRIBUTES
  
  from .compilers import (
      GCC_MINGW,
      get_largefile_args,
      gnu_winlibs,
      msvc_winlibs,
      vs32_instruction_set_args,
      vs64_instruction_set_args,
      ArmCompiler,
      ArmclangCompiler,
      ClangCompiler,
      Compiler,
      CompilerArgs,
      CrossNoRunException,
      GnuCompiler,
      ElbrusCompiler,
      IntelCompiler,
      RunResult,
  )
  
  gnu_compiler_internal_libs = ('m', 'c', 'pthread', 'dl', 'rt')
  
  
  class CCompiler(Compiler):
      # TODO: Replace this manual cache with functools.lru_cache
      library_dirs_cache = {}
      program_dirs_cache = {}
      find_library_cache = {}
      internal_libs = gnu_compiler_internal_libs
  
      @staticmethod
      def attribute_check_func(name):
          try:
              return C_FUNC_ATTRIBUTES[name]
          except KeyError:
              raise MesonException('Unknown function attribute "{}"'.format(name))
  
      def __init__(self, exelist, version, is_cross, exe_wrapper=None, **kwargs):
          # If a child ObjC or CPP class has already set it, don't set it ourselves
          if not hasattr(self, 'language'):
              self.language = 'c'
          super().__init__(exelist, version, **kwargs)
          self.id = 'unknown'
          self.is_cross = is_cross
          self.can_compile_suffixes.add('h')
          # If the exe wrapper was not found, pretend it wasn't set so that the
          # sanity check is skipped and compiler checks use fallbacks.
          if not exe_wrapper or not exe_wrapper.found():
              self.exe_wrapper = None
          else:
              self.exe_wrapper = exe_wrapper.get_command()
  
          # Set to None until we actually need to check this
          self.has_fatal_warnings_link_arg = None
  
      def needs_static_linker(self):
          return True # When compiling static libraries, so yes.
  
      def get_always_args(self):
          '''
          Args that are always-on for all C compilers other than MSVC
          '''
          return ['-pipe'] + get_largefile_args(self)
  
      def get_linker_debug_crt_args(self):
          """
          Arguments needed to select a debug crt for the linker
          This is only needed for MSVC
          """
          return []
  
      def get_no_stdinc_args(self):
         
  
  [... the rest is omitted ...]
files: mesonbuild/compilers/c.py
files: # Copyright 2012-2017 The Meson development team
  
  # Licensed under the Apache License, Version 2.0 (the "License");
  # you may not use this file except in compliance with the License.
  # You may obtain a copy of the License at
  
  #     http://www.apache.org/licenses/LICENSE-2.0
  
  # Unless required by applicable law or agreed to in writing, software
  # distributed under the License is distributed on an "AS IS" BASIS,
  # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  # See the License for the specific language governing permissions and
  # limitations under the License.
  
  import contextlib, enum, os.path, re, tempfile, shlex
  import subprocess
  
  from ..linkers import StaticLinker
  from .. import coredata
  from .. import mlog
  from .. import mesonlib
  from ..mesonlib import EnvironmentException, MesonException, OrderedSet, version_compare, Popen_safe
  
  """This file contains the data files of all compilers Meson knows
  about. To support a new compiler, add its information below.
  Also add corresponding autodetection code in environment.py."""
  
  header_suffixes = ('h', 'hh', 'hpp', 'hxx', 'H', 'ipp', 'moc', 'vapi', 'di')
  obj_suffixes = ('o', 'obj', 'res')
  lib_suffixes = ('a', 'lib', 'dll', 'dylib', 'so')
  # Mapping of language to suffixes of files that should always be in that language
  # This means we can't include .h headers here since they could be C, C++, ObjC, etc.
  lang_suffixes = {
      'c': ('c',),
      'cpp': ('cpp', 'cc', 'cxx', 'c++', 'hh', 'hpp', 'ipp', 'hxx'),
      # f90, f95, f03, f08 are for free-form fortran ('f90' recommended)
      # f, for, ftn, fpp are for fixed-form fortran ('f' or 'for' recommended)
      'fortran': ('f90', 'f95', 'f03', 'f08', 'f', 'for', 'ftn', 'fpp'),
      'd': ('d', 'di'),
      'objc': ('m',),
      'objcpp': ('mm',),
      'rust': ('rs',),
      'vala': ('vala', 'vapi', 'gs'),
      'cs': ('cs',),
      'swift': ('swift',),
      'java': ('java',),
  }
  all_languages = lang_suffixes.keys()
  cpp_suffixes = lang_suffixes['cpp'] + ('h',)
  c_suffixes = lang_suffixes['c'] + ('h',)
  # List of languages that by default consume and output libraries following the
  # C ABI; these can generally be used interchangebly
  clib_langs = ('objcpp', 'cpp', 'objc', 'c', 'fortran',)
  # List of languages that can be linked with C code directly by the linker
  # used in build.py:process_compilers() and build.py:get_dynamic_linker()
  # XXX: Add Rust to this?
  clink_langs = ('d',) + clib_langs
  clink_suffixes = ()
  for _l in clink_langs + ('vala',):
      clink_suffixes += lang_suffixes[_l]
  clink_suffixes += ('h', 'll', 's')
  
  soregex = re.compile(r'.*\.so(\.[0-9]+)?(\.[0-9
  
  [... the rest is omitted ...]
files: mesonbuild/compilers/compilers.py
files: # Copyright 2012-2017 The Meson development team
  
  # Licensed under the Apache License, Version 2.0 (the "License");
  # you may not use this file except in compliance with the License.
  # You may obtain a copy of the License at
  
  #     http://www.apache.org/licenses/LICENSE-2.0
  
  # Unless required by applicable law or agreed to in writing, software
  # distributed under the License is distributed on an "AS IS" BASIS,
  # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  # See the License for the specific language governing permissions and
  # limitations under the License.
  
  import contextlib, os.path, re, tempfile, shlex
  import subprocess
  
  from ..linkers import StaticLinker
  from .. import coredata
  from .. import mlog
  from .. import mesonlib
  from ..mesonlib import EnvironmentException, MesonException, OrderedSet, version_compare, Popen_safe
  
  """This file contains the data files of all compilers Meson knows
  about. To support a new compiler, add its information below.
  Also add corresponding autodetection code in environment.py."""
  
  header_suffixes = ('h', 'hh', 'hpp', 'hxx', 'H', 'ipp', 'moc', 'vapi', 'di')
  obj_suffixes = ('o', 'obj', 'res')
  lib_suffixes = ('a', 'lib', 'dll', 'dylib', 'so')
  # Mapping of language to suffixes of files that should always be in that language
  # This means we can't include .h headers here since they could be C, C++, ObjC, etc.
  lang_suffixes = {
      'c': ('c',),
      'cpp': ('cpp', 'cc', 'cxx', 'c++', 'hh', 'hpp', 'ipp', 'hxx'),
      # f90, f95, f03, f08 are for free-form fortran ('f90' recommended)
      # f, for, ftn, fpp are for fixed-form fortran ('f' or 'for' recommended)
      'fortran': ('f90', 'f95', 'f03', 'f08', 'f', 'for', 'ftn', 'fpp'),
      'd': ('d', 'di'),
      'objc': ('m',),
      'objcpp': ('mm',),
      'rust': ('rs',),
      'vala': ('vala', 'vapi', 'gs'),
      'cs': ('cs',),
      'swift': ('swift',),
      'java': ('java',),
  }
  all_languages = lang_suffixes.keys()
  cpp_suffixes = lang_suffixes['cpp'] + ('h',)
  c_suffixes = lang_suffixes['c'] + ('h',)
  # List of languages that by default consume and output libraries following the
  # C ABI; these can generally be used interchangebly
  clib_langs = ('objcpp', 'cpp', 'objc', 'c', 'fortran',)
  # List of languages that can be linked with C code directly by the linker
  # used in build.py:process_compilers() and build.py:get_dynamic_linker()
  # XXX: Add Rust to this?
  clink_langs = ('d',) + clib_langs
  clink_suffixes = ()
  for _l in clink_langs + ('vala',):
      clink_suffixes += lang_suffixes[_l]
  clink_suffixes += ('h', 'll', 's')
  
  soregex = re.compile(r'.*\.so(\.[0-9]+)?(\.[0-9]+)?
  
  [... the rest is omitted ...]
files: mesonbuild/compilers/compilers.py
files: # Copyright 2012-2017 The Meson development team
  
  # Licensed under the Apache License, Version 2.0 (the "License");
  # you may not use this file except in compliance with the License.
  # You may obtain a copy of the License at
  
  #     http://www.apache.org/licenses/LICENSE-2.0
  
  # Unless required by applicable law or agreed to in writing, software
  # distributed under the License is distributed on an "AS IS" BASIS,
  # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  # See the License for the specific language governing permissions and
  # limitations under the License.
  
  import functools
  import os.path
  
  from .. import coredata
  from .. import mlog
  from ..mesonlib import MesonException, version_compare
  
  from .c import CCompiler, VisualStudioCCompiler
  from .compilers import (
      CompilerType,
      gnu_winlibs,
      msvc_winlibs,
      ClangCompiler,
      GnuCompiler,
      ElbrusCompiler,
      IntelCompiler,
      ArmCompiler,
      ArmclangCompiler,
  )
  from .c_function_attributes import CXX_FUNC_ATTRIBUTES
  
  class CPPCompiler(CCompiler):
  
      @classmethod
      def attribute_check_func(cls, name):
          return CXX_FUNC_ATTRIBUTES.get(name, super().attribute_check_func(name))
  
      def __init__(self, exelist, version, is_cross, exe_wrap, **kwargs):
          # If a child ObjCPP class has already set it, don't set it ourselves
          if not hasattr(self, 'language'):
              self.language = 'cpp'
          CCompiler.__init__(self, exelist, version, is_cross, exe_wrap, **kwargs)
  
      def get_display_language(self):
          return 'C++'
  
      def get_no_stdinc_args(self):
          return ['-nostdinc++']
  
      def sanity_check(self, work_dir, environment):
          code = 'class breakCCompiler;int main(int argc, char **argv) { return 0; }\n'
          return self.sanity_check_impl(work_dir, environment, 'sanitycheckcpp.cc', code)
  
      def get_compiler_check_args(self):
          # -fpermissive allows non-conforming code to compile which is necessary
          # for many C++ checks. Particularly, the has_header_symbol check is
          # too strict without this and always fails.
          return super().get_compiler_check_args() + ['-fpermissive']
  
      def has_header_symbol(self, hname, symbol, prefix, env, extra_args=None, dependencies=None):
          # Check if it's a C-like symbol
          if super().has_header_symbol(hname, symbol, prefix, env, extra_args, dependencies):
              return True
          # Check if it's a class or a template
          if extra_args is None:
              extra_args = []
          fargs = {'prefix': prefix, 'header': hname, 'symbol': symbol}
          t = '''{prefix}
          #include <{header}>
          using {symbol};
          int main () {{ return 0; }}'''
          return self.compiles(t.format(**fargs), env, extra_args, dependencies)
  
      def _test_cpp_std_arg(self, cpp_std_value):
          # Test whether the compiler understands a -std=XY argument
          assert(cpp_std_value.startswith('-std='))
  
          # This test does not use has_multi_arguments() for two reasons:
          # 1. has_multi_arguments() requires an env argument, which the compiler
          #    object does not have at this point.
          # 2. even if
  
  [... the rest is omitted ...]
files: mesonbuild/compilers/cpp.py
files: # Copyright 2012-2017 The Meson development team
  
  # Licensed under the Apache License, Version 2.0 (the "License");
  # you may not use this file except in compliance with the License.
  # You may obtain a copy of the License at
  
  #     http://www.apache.org/licenses/LICENSE-2.0
  
  # Unless required by applicable law or agreed to in writing, software
  # distributed under the License is distributed on an "AS IS" BASIS,
  # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  # See the License for the specific language governing permissions and
  # limitations under the License.
  
  import functools
  import os.path
  
  from .. import coredata
  from .. import mlog
  from ..mesonlib import MesonException, version_compare
  
  from .c import CCompiler, VisualStudioCCompiler
  from .compilers import (
      GCC_MINGW,
      gnu_winlibs,
      msvc_winlibs,
      ClangCompiler,
      GnuCompiler,
      ElbrusCompiler,
      IntelCompiler,
      ArmCompiler,
      ArmclangCompiler,
  )
  from .c_function_attributes import CXX_FUNC_ATTRIBUTES
  
  class CPPCompiler(CCompiler):
  
      @classmethod
      def attribute_check_func(cls, name):
          return CXX_FUNC_ATTRIBUTES.get(name, super().attribute_check_func(name))
  
      def __init__(self, exelist, version, is_cross, exe_wrap, **kwargs):
          # If a child ObjCPP class has already set it, don't set it ourselves
          if not hasattr(self, 'language'):
              self.language = 'cpp'
          CCompiler.__init__(self, exelist, version, is_cross, exe_wrap, **kwargs)
  
      def get_display_language(self):
          return 'C++'
  
      def get_no_stdinc_args(self):
          return ['-nostdinc++']
  
      def sanity_check(self, work_dir, environment):
          code = 'class breakCCompiler;int main(int argc, char **argv) { return 0; }\n'
          return self.sanity_check_impl(work_dir, environment, 'sanitycheckcpp.cc', code)
  
      def get_compiler_check_args(self):
          # -fpermissive allows non-conforming code to compile which is necessary
          # for many C++ checks. Particularly, the has_header_symbol check is
          # too strict without this and always fails.
          return super().get_compiler_check_args() + ['-fpermissive']
  
      def has_header_symbol(self, hname, symbol, prefix, env, extra_args=None, dependencies=None):
          # Check if it's a C-like symbol
          if super().has_header_symbol(hname, symbol, prefix, env, extra_args, dependencies):
              return True
          # Check if it's a class or a template
          if extra_args is None:
              extra_args = []
          fargs = {'prefix': prefix, 'header': hname, 'symbol': symbol}
          t = '''{prefix}
          #include <{header}>
          using {symbol};
          int main () {{ return 0; }}'''
          return self.compiles(t.format(**fargs), env, extra_args, dependencies)
  
      def _test_cpp_std_arg(self, cpp_std_value):
          # Test whether the compiler understands a -std=XY argument
          assert(cpp_std_value.startswith('-std='))
  
          # This test does not use has_multi_arguments() for two reasons:
          # 1. has_multi_arguments() requires an env argument, which the compiler
          #    object does not have at this point.
          # 2. even
  
  [... the rest is omitted ...]
files: mesonbuild/compilers/cpp.py
files: # Copyright 2012-2017 The Meson development team
  
  # Licensed under the Apache License, Version 2.0 (the "License");
  # you may not use this file except in compliance with the License.
  # You may obtain a copy of the License at
  
  #     http://www.apache.org/licenses/LICENSE-2.0
  
  # Unless required by applicable law or agreed to in writing, software
  # distributed under the License is distributed on an "AS IS" BASIS,
  # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  # See the License for the specific language governing permissions and
  # limitations under the License.
  
  import os.path, subprocess
  
  from ..mesonlib import EnvironmentException, version_compare, is_windows, is_osx
  
  from .compilers import (
      CompilerType,
      d_dmd_buildtype_args,
      d_gdc_buildtype_args,
      d_ldc_buildtype_args,
      get_gcc_soname_args,
      gnu_color_args,
      gnu_optimization_args,
      clike_debug_args,
      Compiler,
      CompilerArgs,
  )
  
  d_feature_args = {'gcc':  {'unittest': '-funittest',
                             'version': '-fversion',
                             'import_dir': '-J'
                             },
                    'llvm': {'unittest': '-unittest',
                             'version': '-d-version',
                             'import_dir': '-J'
                             },
                    'dmd':  {'unittest': '-unittest',
                             'version': '-version',
                             'import_dir': '-J'
                             }
                    }
  
  ldc_optimization_args = {'0': [],
                           'g': [],
                           '1': ['-O1'],
                           '2': ['-O2'],
                           '3': ['-O3'],
                           's': ['-Os'],
                           }
  
  dmd_optimization_args = {'0': [],
                           'g': [],
                           '1': ['-O'],
                           '2': ['-O'],
                           '3': ['-O'],
                           's': ['-O'],
                           }
  
  class DCompiler(Compiler):
      mscrt_args = {
          'none': ['-mscrtlib='],
          'md': ['-mscrtlib=msvcrt'],
          'mdd': ['-mscrtlib=msvcrtd'],
          'mt': ['-mscrtlib=libcmt'],
          'mtd': ['-mscrtlib=libcmtd'],
      }
  
      def __init__(self, exelist, version, is_cross, is_64, **kwargs):
          self.language = 'd'
          super().__init__(exelist, version, **kwargs)
          self.id = 'unknown'
          self.is_cross = is_cross
          self.is_64 = is_64
  
      def sanity_check(self, work_dir, environment):
          source_name = os.path.join(work_dir, 'sanity.d')
          output_name = os.path.join(work_dir, 'dtest')
          with open(source_name, 'w') as ofile:
              ofile.write('''void main() { }''')
          pc = subprocess.Popen(self.exelist + self.get_output_args(output_name) + self.get_target_arch_args() + [source_name], cwd=work_dir)
          pc.wait()
          if pc.returncode != 0:
              raise EnvironmentException('D compiler %s can not compile programs.' % self.name_string())
          if subprocess.call(output_name) != 0:
              raise EnvironmentException('Executables created by D compiler %s are not runnable.' % self.name_string())
  
      def needs_static_linker(self):
          return True
  
      def name_string
  
  [... the rest is omitted ...]
files: mesonbuild/compilers/d.py
files: # Copyright 2012-2017 The Meson development team
  
  # Licensed under the Apache License, Version 2.0 (the "License");
  # you may not use this file except in compliance with the License.
  # You may obtain a copy of the License at
  
  #     http://www.apache.org/licenses/LICENSE-2.0
  
  # Unless required by applicable law or agreed to in writing, software
  # distributed under the License is distributed on an "AS IS" BASIS,
  # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  # See the License for the specific language governing permissions and
  # limitations under the License.
  
  import os.path, subprocess
  
  from ..mesonlib import EnvironmentException, version_compare, is_windows, is_osx
  
  from .compilers import (
      GCC_STANDARD,
      GCC_OSX,
      d_dmd_buildtype_args,
      d_gdc_buildtype_args,
      d_ldc_buildtype_args,
      get_gcc_soname_args,
      gnu_color_args,
      gnu_optimization_args,
      clike_debug_args,
      Compiler,
      CompilerArgs,
  )
  
  d_feature_args = {'gcc':  {'unittest': '-funittest',
                             'version': '-fversion',
                             'import_dir': '-J'
                             },
                    'llvm': {'unittest': '-unittest',
                             'version': '-d-version',
                             'import_dir': '-J'
                             },
                    'dmd':  {'unittest': '-unittest',
                             'version': '-version',
                             'import_dir': '-J'
                             }
                    }
  
  ldc_optimization_args = {'0': [],
                           'g': [],
                           '1': ['-O1'],
                           '2': ['-O2'],
                           '3': ['-O3'],
                           's': ['-Os'],
                           }
  
  dmd_optimization_args = {'0': [],
                           'g': [],
                           '1': ['-O'],
                           '2': ['-O'],
                           '3': ['-O'],
                           's': ['-O'],
                           }
  
  class DCompiler(Compiler):
      mscrt_args = {
          'none': ['-mscrtlib='],
          'md': ['-mscrtlib=msvcrt'],
          'mdd': ['-mscrtlib=msvcrtd'],
          'mt': ['-mscrtlib=libcmt'],
          'mtd': ['-mscrtlib=libcmtd'],
      }
  
      def __init__(self, exelist, version, is_cross, is_64, **kwargs):
          self.language = 'd'
          super().__init__(exelist, version, **kwargs)
          self.id = 'unknown'
          self.is_cross = is_cross
          self.is_64 = is_64
  
      def sanity_check(self, work_dir, environment):
          source_name = os.path.join(work_dir, 'sanity.d')
          output_name = os.path.join(work_dir, 'dtest')
          with open(source_name, 'w') as ofile:
              ofile.write('''void main() { }''')
          pc = subprocess.Popen(self.exelist + self.get_output_args(output_name) + self.get_target_arch_args() + [source_name], cwd=work_dir)
          pc.wait()
          if pc.returncode != 0:
              raise EnvironmentException('D compiler %s can not compile programs.' % self.name_string())
          if subprocess.call(output_name) != 0:
              raise EnvironmentException('Executables created by D compiler %s are not runnable.' % self.name_string())
  
      def needs_static_linker(self):
         
  
  [... the rest is omitted ...]
files: mesonbuild/compilers/d.py
files: # Copyright 2012-2017 The Meson development team
  
  # Licensed under the Apache License, Version 2.0 (the "License");
  # you may not use this file except in compliance with the License.
  # You may obtain a copy of the License at
  
  #     http://www.apache.org/licenses/LICENSE-2.0
  
  # Unless required by applicable law or agreed to in writing, software
  # distributed under the License is distributed on an "AS IS" BASIS,
  # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  # See the License for the specific language governing permissions and
  # limitations under the License.
  
  from .c import CCompiler
  from .compilers import (
      CompilerType,
      apple_buildtype_linker_args,
      gnulike_buildtype_args,
      gnulike_buildtype_linker_args,
      gnu_optimization_args,
      clike_debug_args,
      Compiler,
      GnuCompiler,
      ElbrusCompiler,
      IntelCompiler,
  )
  
  from mesonbuild.mesonlib import EnvironmentException, is_osx
  import subprocess, os
  
  class FortranCompiler(Compiler):
      library_dirs_cache = CCompiler.library_dirs_cache
      program_dirs_cache = CCompiler.library_dirs_cache
      find_library_cache = CCompiler.library_dirs_cache
  
      def __init__(self, exelist, version, is_cross, exe_wrapper=None, **kwargs):
          self.language = 'fortran'
          Compiler.__init__(self, exelist, version, **kwargs)
          cc = CCompiler(exelist, version, is_cross, exe_wrapper, **kwargs)
          self.id = 'unknown'
          self.is_cross = cc.is_cross
          self.exe_wrapper = cc.exe_wrapper
  
      def get_display_language(self):
          return 'Fortran'
  
      def needs_static_linker(self):
          return CCompiler.needs_static_linker(self)
  
      def get_always_args(self):
          return CCompiler.get_always_args(self)
  
      def get_linker_debug_crt_args(self):
          return CCompiler.get_linker_debug_crt_args(self)
  
      def get_no_stdinc_args(self):
          return CCompiler.get_no_stdinc_args(self)
  
      def get_no_stdlib_link_args(self):
          return CCompiler.get_no_stdlib_link_args(self)
  
      def get_warn_args(self, level):
          return CCompiler.get_warn_args(self, level)
  
      def get_no_warn_args(self):
          return CCompiler.get_no_warn_args(self)
  
      def get_soname_args(self, *args):
          return CCompiler.get_soname_args(self, *args)
  
      def sanity_check(self, work_dir, environment):
          source_name = os.path.join(work_dir, 'sanitycheckf.f90')
          binary_name = os.path.join(work_dir, 'sanitycheckf')
          with open(source_name, 'w') as ofile:
              ofile.write('''program prog
       print *, "Fortran compilation is working."
  end program prog
  ''')
          extra_flags = self.get_cross_extra_flags(environment, link=True)
          pc = subprocess.Popen(self.exelist + extra_flags + [source_name, '-o', binary_name])
          pc.wait()
          if pc.returncode != 0:
              raise EnvironmentException('Compiler %s can not compile programs.' % self.name_string())
          if self.is_cross:
              if self.exe_wrapper is None:
                  # Can't check if the binaries run so we have to assume they do
                  return
              cmdlist = self.exe_wrapper + [binary_name]
          else:
              cmdlist = [
  
  [... the rest is omitted ...]
files: mesonbuild/compilers/fortran.py
files: # Copyright 2012-2017 The Meson development team
  
  # Licensed under the Apache License, Version 2.0 (the "License");
  # you may not use this file except in compliance with the License.
  # You may obtain a copy of the License at
  
  #     http://www.apache.org/licenses/LICENSE-2.0
  
  # Unless required by applicable law or agreed to in writing, software
  # distributed under the License is distributed on an "AS IS" BASIS,
  # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  # See the License for the specific language governing permissions and
  # limitations under the License.
  
  from .c import CCompiler
  from .compilers import (
      ICC_STANDARD,
      apple_buildtype_linker_args,
      gnulike_buildtype_args,
      gnulike_buildtype_linker_args,
      gnu_optimization_args,
      clike_debug_args,
      Compiler,
      GnuCompiler,
      ElbrusCompiler,
      IntelCompiler,
  )
  
  from mesonbuild.mesonlib import EnvironmentException, is_osx
  import subprocess, os
  
  class FortranCompiler(Compiler):
      library_dirs_cache = CCompiler.library_dirs_cache
      program_dirs_cache = CCompiler.library_dirs_cache
      find_library_cache = CCompiler.library_dirs_cache
  
      def __init__(self, exelist, version, is_cross, exe_wrapper=None, **kwargs):
          self.language = 'fortran'
          Compiler.__init__(self, exelist, version, **kwargs)
          cc = CCompiler(exelist, version, is_cross, exe_wrapper, **kwargs)
          self.id = 'unknown'
          self.is_cross = cc.is_cross
          self.exe_wrapper = cc.exe_wrapper
  
      def get_display_language(self):
          return 'Fortran'
  
      def needs_static_linker(self):
          return CCompiler.needs_static_linker(self)
  
      def get_always_args(self):
          return CCompiler.get_always_args(self)
  
      def get_linker_debug_crt_args(self):
          return CCompiler.get_linker_debug_crt_args(self)
  
      def get_no_stdinc_args(self):
          return CCompiler.get_no_stdinc_args(self)
  
      def get_no_stdlib_link_args(self):
          return CCompiler.get_no_stdlib_link_args(self)
  
      def get_warn_args(self, level):
          return CCompiler.get_warn_args(self, level)
  
      def get_no_warn_args(self):
          return CCompiler.get_no_warn_args(self)
  
      def get_soname_args(self, *args):
          return CCompiler.get_soname_args(self, *args)
  
      def sanity_check(self, work_dir, environment):
          source_name = os.path.join(work_dir, 'sanitycheckf.f90')
          binary_name = os.path.join(work_dir, 'sanitycheckf')
          with open(source_name, 'w') as ofile:
              ofile.write('''program prog
       print *, "Fortran compilation is working."
  end program prog
  ''')
          extra_flags = self.get_cross_extra_flags(environment, link=True)
          pc = subprocess.Popen(self.exelist + extra_flags + [source_name, '-o', binary_name])
          pc.wait()
          if pc.returncode != 0:
              raise EnvironmentException('Compiler %s can not compile programs.' % self.name_string())
          if self.is_cross:
              if self.exe_wrapper is None:
                  # Can't check if the binaries run so we have to assume they do
                  return
              cmdlist = self.exe_wrapper + [binary_name]
          else:
              cmdlist =
  
  [... the rest is omitted ...]
files: mesonbuild/compilers/fortran.py
files: # Copyright 2012-2017 The Meson development team
  
  # Licensed under the Apache License, Version 2.0 (the "License");
  # you may not use this file except in compliance with the License.
  # You may obtain a copy of the License at
  
  #     http://www.apache.org/licenses/LICENSE-2.0
  
  # Unless required by applicable law or agreed to in writing, software
  # distributed under the License is distributed on an "AS IS" BASIS,
  # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  # See the License for the specific language governing permissions and
  # limitations under the License.
  
  import os.path, subprocess
  
  from ..mesonlib import EnvironmentException
  
  from .c import CCompiler
  from .compilers import ClangCompiler, GnuCompiler
  
  class ObjCCompiler(CCompiler):
      def __init__(self, exelist, version, is_cross, exe_wrap):
          self.language = 'objc'
          CCompiler.__init__(self, exelist, version, is_cross, exe_wrap)
  
      def get_display_language(self):
          return 'Objective-C'
  
      def sanity_check(self, work_dir, environment):
          # TODO try to use sanity_check_impl instead of duplicated code
          source_name = os.path.join(work_dir, 'sanitycheckobjc.m')
          binary_name = os.path.join(work_dir, 'sanitycheckobjc')
          extra_flags = self.get_cross_extra_flags(environment, link=False)
          if self.is_cross:
              extra_flags += self.get_compile_only_args()
          with open(source_name, 'w') as ofile:
              ofile.write('#import<stdio.h>\n'
                          'int main(int argc, char **argv) { return 0; }\n')
          pc = subprocess.Popen(self.exelist + extra_flags + [source_name, '-o', binary_name])
          pc.wait()
          if pc.returncode != 0:
              raise EnvironmentException('ObjC compiler %s can not compile programs.' % self.name_string())
          if self.is_cross:
              # Can't check if the binaries run so we have to assume they do
              return
          pe = subprocess.Popen(binary_name)
          pe.wait()
          if pe.returncode != 0:
              raise EnvironmentException('Executables created by ObjC compiler %s are not runnable.' % self.name_string())
  
  
  class GnuObjCCompiler(GnuCompiler, ObjCCompiler):
      def __init__(self, exelist, version, compiler_type, is_cross, exe_wrapper=None, defines=None):
          ObjCCompiler.__init__(self, exelist, version, is_cross, exe_wrapper)
          GnuCompiler.__init__(self, compiler_type, defines)
          default_warn_args = ['-Wall', '-Winvalid-pch']
          self.warn_args = {'1': default_warn_args,
                            '2': default_warn_args + ['-Wextra'],
                            '3': default_warn_args + ['-Wextra', '-Wpedantic']}
  
  
  class ClangObjCCompiler(ClangCompiler, ObjCCompiler):
      def __init__(self, exelist, version, compiler_type, is_cross, exe_wrapper=None):
          ObjCCompiler.__init__(self, exelist, version, is_cross, exe_wrapper)
          ClangCompiler.__init__(self, compiler_type)
          default_warn_args = ['-Wall', '-Winvalid-pch']
          self.warn_args = {'1': default_warn_args,
                            '2': default_warn_args + ['-Wext
  
  [... the rest is omitted ...]
files: mesonbuild/compilers/objc.py
files: # Copyright 2012-2017 The Meson development team
  
  # Licensed under the Apache License, Version 2.0 (the "License");
  # you may not use this file except in compliance with the License.
  # You may obtain a copy of the License at
  
  #     http://www.apache.org/licenses/LICENSE-2.0
  
  # Unless required by applicable law or agreed to in writing, software
  # distributed under the License is distributed on an "AS IS" BASIS,
  # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  # See the License for the specific language governing permissions and
  # limitations under the License.
  
  import os.path, subprocess
  
  from ..mesonlib import EnvironmentException
  
  from .c import CCompiler
  from .compilers import ClangCompiler, GnuCompiler
  
  class ObjCCompiler(CCompiler):
      def __init__(self, exelist, version, is_cross, exe_wrap):
          self.language = 'objc'
          CCompiler.__init__(self, exelist, version, is_cross, exe_wrap)
  
      def get_display_language(self):
          return 'Objective-C'
  
      def sanity_check(self, work_dir, environment):
          # TODO try to use sanity_check_impl instead of duplicated code
          source_name = os.path.join(work_dir, 'sanitycheckobjc.m')
          binary_name = os.path.join(work_dir, 'sanitycheckobjc')
          extra_flags = self.get_cross_extra_flags(environment, link=False)
          if self.is_cross:
              extra_flags += self.get_compile_only_args()
          with open(source_name, 'w') as ofile:
              ofile.write('#import<stdio.h>\n'
                          'int main(int argc, char **argv) { return 0; }\n')
          pc = subprocess.Popen(self.exelist + extra_flags + [source_name, '-o', binary_name])
          pc.wait()
          if pc.returncode != 0:
              raise EnvironmentException('ObjC compiler %s can not compile programs.' % self.name_string())
          if self.is_cross:
              # Can't check if the binaries run so we have to assume they do
              return
          pe = subprocess.Popen(binary_name)
          pe.wait()
          if pe.returncode != 0:
              raise EnvironmentException('Executables created by ObjC compiler %s are not runnable.' % self.name_string())
  
  
  class GnuObjCCompiler(GnuCompiler, ObjCCompiler):
      def __init__(self, exelist, version, gcc_type, is_cross, exe_wrapper=None, defines=None):
          ObjCCompiler.__init__(self, exelist, version, is_cross, exe_wrapper)
          GnuCompiler.__init__(self, gcc_type, defines)
          default_warn_args = ['-Wall', '-Winvalid-pch']
          self.warn_args = {'1': default_warn_args,
                            '2': default_warn_args + ['-Wextra'],
                            '3': default_warn_args + ['-Wextra', '-Wpedantic']}
  
  
  class ClangObjCCompiler(ClangCompiler, GnuObjCCompiler):
      def __init__(self, exelist, version, cltype, is_cross, exe_wrapper=None):
          GnuObjCCompiler.__init__(self, exelist, version, cltype, is_cross, exe_wrapper)
          ClangCompiler.__init__(self, cltype)
          self.base_options = ['b_pch', 'b_lto', 'b_pgo', 'b_sanitize', 'b_coverage']
  
  
  [... the rest is omitted ...]
files: mesonbuild/compilers/objc.py
files: # Copyright 2012-2017 The Meson development team
  
  # Licensed under the Apache License, Version 2.0 (the "License");
  # you may not use this file except in compliance with the License.
  # You may obtain a copy of the License at
  
  #     http://www.apache.org/licenses/LICENSE-2.0
  
  # Unless required by applicable law or agreed to in writing, software
  # distributed under the License is distributed on an "AS IS" BASIS,
  # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  # See the License for the specific language governing permissions and
  # limitations under the License.
  
  import os.path, subprocess
  
  from ..mesonlib import EnvironmentException
  
  from .cpp import CPPCompiler
  from .compilers import ClangCompiler, GnuCompiler
  
  class ObjCPPCompiler(CPPCompiler):
      def __init__(self, exelist, version, is_cross, exe_wrap):
          self.language = 'objcpp'
          CPPCompiler.__init__(self, exelist, version, is_cross, exe_wrap)
  
      def get_display_language(self):
          return 'Objective-C++'
  
      def sanity_check(self, work_dir, environment):
          # TODO try to use sanity_check_impl instead of duplicated code
          source_name = os.path.join(work_dir, 'sanitycheckobjcpp.mm')
          binary_name = os.path.join(work_dir, 'sanitycheckobjcpp')
          extra_flags = self.get_cross_extra_flags(environment, link=False)
          if self.is_cross:
              extra_flags += self.get_compile_only_args()
          with open(source_name, 'w') as ofile:
              ofile.write('#import<stdio.h>\n'
                          'class MyClass;'
                          'int main(int argc, char **argv) { return 0; }\n')
          pc = subprocess.Popen(self.exelist + extra_flags + [source_name, '-o', binary_name])
          pc.wait()
          if pc.returncode != 0:
              raise EnvironmentException('ObjC++ compiler %s can not compile programs.' % self.name_string())
          if self.is_cross:
              # Can't check if the binaries run so we have to assume they do
              return
          pe = subprocess.Popen(binary_name)
          pe.wait()
          if pe.returncode != 0:
              raise EnvironmentException('Executables created by ObjC++ compiler %s are not runnable.' % self.name_string())
  
  
  class GnuObjCPPCompiler(GnuCompiler, ObjCPPCompiler):
      def __init__(self, exelist, version, compiler_type, is_cross, exe_wrapper=None, defines=None):
          ObjCPPCompiler.__init__(self, exelist, version, is_cross, exe_wrapper)
          GnuCompiler.__init__(self, compiler_type, defines)
          default_warn_args = ['-Wall', '-Winvalid-pch', '-Wnon-virtual-dtor']
          self.warn_args = {'1': default_warn_args,
                            '2': default_warn_args + ['-Wextra'],
                            '3': default_warn_args + ['-Wextra', '-Wpedantic']}
  
  
  class ClangObjCPPCompiler(ClangCompiler, ObjCPPCompiler):
      def __init__(self, exelist, version, compiler_type, is_cross, exe_wrapper=None):
          ObjCPPCompiler.__init__(self, exelist, version, is_cross, exe_wrapper)
          ClangCompiler.__init__(self, compiler_type)
          default_warn_args = ['-Wall', '-Winvalid-pch',
  
  [... the rest is omitted ...]
files: mesonbuild/compilers/objcpp.py
files: # Copyright 2012-2017 The Meson development team
  
  # Licensed under the Apache License, Version 2.0 (the "License");
  # you may not use this file except in compliance with the License.
  # You may obtain a copy of the License at
  
  #     http://www.apache.org/licenses/LICENSE-2.0
  
  # Unless required by applicable law or agreed to in writing, software
  # distributed under the License is distributed on an "AS IS" BASIS,
  # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  # See the License for the specific language governing permissions and
  # limitations under the License.
  
  import os.path, subprocess
  
  from ..mesonlib import EnvironmentException
  
  from .cpp import CPPCompiler
  from .compilers import ClangCompiler, GnuCompiler
  
  class ObjCPPCompiler(CPPCompiler):
      def __init__(self, exelist, version, is_cross, exe_wrap):
          self.language = 'objcpp'
          CPPCompiler.__init__(self, exelist, version, is_cross, exe_wrap)
  
      def get_display_language(self):
          return 'Objective-C++'
  
      def sanity_check(self, work_dir, environment):
          # TODO try to use sanity_check_impl instead of duplicated code
          source_name = os.path.join(work_dir, 'sanitycheckobjcpp.mm')
          binary_name = os.path.join(work_dir, 'sanitycheckobjcpp')
          extra_flags = self.get_cross_extra_flags(environment, link=False)
          if self.is_cross:
              extra_flags += self.get_compile_only_args()
          with open(source_name, 'w') as ofile:
              ofile.write('#import<stdio.h>\n'
                          'class MyClass;'
                          'int main(int argc, char **argv) { return 0; }\n')
          pc = subprocess.Popen(self.exelist + extra_flags + [source_name, '-o', binary_name])
          pc.wait()
          if pc.returncode != 0:
              raise EnvironmentException('ObjC++ compiler %s can not compile programs.' % self.name_string())
          if self.is_cross:
              # Can't check if the binaries run so we have to assume they do
              return
          pe = subprocess.Popen(binary_name)
          pe.wait()
          if pe.returncode != 0:
              raise EnvironmentException('Executables created by ObjC++ compiler %s are not runnable.' % self.name_string())
  
  
  class GnuObjCPPCompiler(GnuCompiler, ObjCPPCompiler):
      def __init__(self, exelist, version, gcc_type, is_cross, exe_wrapper=None, defines=None):
          ObjCPPCompiler.__init__(self, exelist, version, is_cross, exe_wrapper)
          GnuCompiler.__init__(self, gcc_type, defines)
          default_warn_args = ['-Wall', '-Winvalid-pch', '-Wnon-virtual-dtor']
          self.warn_args = {'1': default_warn_args,
                            '2': default_warn_args + ['-Wextra'],
                            '3': default_warn_args + ['-Wextra', '-Wpedantic']}
  
  
  class ClangObjCPPCompiler(ClangCompiler, GnuObjCPPCompiler):
      def __init__(self, exelist, version, cltype, is_cross, exe_wrapper=None):
          GnuObjCPPCompiler.__init__(self, exelist, version, cltype, is_cross, exe_wrapper)
          ClangCompiler.__init__(self, cltype)
          self.base_options = ['b_pch
  
  [... the rest is omitted ...]
files: mesonbuild/compilers/objcpp.py
files: # Copyright 2012-2016 The Meson development team
  
  # Licensed under the Apache License, Version 2.0 (the "License");
  # you may not use this file except in compliance with the License.
  # You may obtain a copy of the License at
  
  #     http://www.apache.org/licenses/LICENSE-2.0
  
  # Unless required by applicable law or agreed to in writing, software
  # distributed under the License is distributed on an "AS IS" BASIS,
  # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  # See the License for the specific language governing permissions and
  # limitations under the License.
  
  import configparser, os, platform, re, shlex, shutil, subprocess
  
  from . import coredata
  from .linkers import ArLinker, ArmarLinker, VisualStudioLinker, DLinker
  from . import mesonlib
  from .mesonlib import EnvironmentException, Popen_safe
  from . import mlog
  
  from . import compilers
  from .compilers import (
      CompilerType,
      is_assembly,
      is_header,
      is_library,
      is_llvm_ir,
      is_object,
      is_source,
  )
  from .compilers import (
      ArmCCompiler,
      ArmCPPCompiler,
      ArmclangCCompiler,
      ArmclangCPPCompiler,
      ClangCCompiler,
      ClangCPPCompiler,
      ClangObjCCompiler,
      ClangObjCPPCompiler,
      G95FortranCompiler,
      GnuCCompiler,
      GnuCPPCompiler,
      GnuFortranCompiler,
      GnuObjCCompiler,
      GnuObjCPPCompiler,
      ElbrusCCompiler,
      ElbrusCPPCompiler,
      ElbrusFortranCompiler,
      IntelCCompiler,
      IntelCPPCompiler,
      IntelFortranCompiler,
      JavaCompiler,
      MonoCompiler,
      VisualStudioCsCompiler,
      NAGFortranCompiler,
      Open64FortranCompiler,
      PathScaleFortranCompiler,
      PGIFortranCompiler,
      RustCompiler,
      SunFortranCompiler,
      ValaCompiler,
      VisualStudioCCompiler,
      VisualStudioCPPCompiler,
  )
  
  build_filename = 'meson.build'
  
  known_cpu_families = (
      'aarch64',
      'arm',
      'e2k',
      'ia64',
      'mips',
      'mips64',
      'parisc',
      'ppc',
      'ppc64',
      'riscv32',
      'riscv64',
      's390x',
      'sparc',
      'sparc64',
      'x86',
      'x86_64'
  )
  
  def detect_gcovr(version='3.1', log=False):
      gcovr_exe = 'gcovr'
      try:
          p, found = Popen_safe([gcovr_exe, '--version'])[0:2]
      except (FileNotFoundError, PermissionError):
          # Doesn't exist in PATH or isn't executable
          return None, None
      found = search_version(found)
      if p.returncode == 0:
          if log:
              mlog.log('Found gcovr-{} at {}'.format(found, shlex.quote(shutil.which(gcovr_exe))))
          return gcovr_exe, mesonlib.version_compare(found, '>=' + version)
      return None, None
  
  def find_coverage_tools():
      gcovr_exe, gcovr_new_rootdir = detect_gcovr()
  
      lcov_exe = 'lcov'
      genhtml_exe = 'genhtml'
  
      if not mesonlib.exe_exists([lcov_exe
  
  [... the rest is omitted ...]
files: mesonbuild/environment.py
files: # Copyright 2012-2016 The Meson development team
  
  # Licensed under the Apache License, Version 2.0 (the "License");
  # you may not use this file except in compliance with the License.
  # You may obtain a copy of the License at
  
  #     http://www.apache.org/licenses/LICENSE-2.0
  
  # Unless required by applicable law or agreed to in writing, software
  # distributed under the License is distributed on an "AS IS" BASIS,
  # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  # See the License for the specific language governing permissions and
  # limitations under the License.
  
  import configparser, os, platform, re, shlex, shutil, subprocess
  
  from . import coredata
  from .linkers import ArLinker, ArmarLinker, VisualStudioLinker, DLinker
  from . import mesonlib
  from .mesonlib import EnvironmentException, Popen_safe
  from . import mlog
  
  from . import compilers
  from .compilers import (
      CLANG_OSX,
      CLANG_STANDARD,
      CLANG_WIN,
      GCC_CYGWIN,
      GCC_MINGW,
      GCC_OSX,
      GCC_STANDARD,
      ICC_STANDARD,
      is_assembly,
      is_header,
      is_library,
      is_llvm_ir,
      is_object,
      is_source,
  )
  from .compilers import (
      ArmCCompiler,
      ArmCPPCompiler,
      ArmclangCCompiler,
      ArmclangCPPCompiler,
      ClangCCompiler,
      ClangCPPCompiler,
      ClangObjCCompiler,
      ClangObjCPPCompiler,
      G95FortranCompiler,
      GnuCCompiler,
      GnuCPPCompiler,
      GnuFortranCompiler,
      GnuObjCCompiler,
      GnuObjCPPCompiler,
      ElbrusCCompiler,
      ElbrusCPPCompiler,
      ElbrusFortranCompiler,
      IntelCCompiler,
      IntelCPPCompiler,
      IntelFortranCompiler,
      JavaCompiler,
      MonoCompiler,
      VisualStudioCsCompiler,
      NAGFortranCompiler,
      Open64FortranCompiler,
      PathScaleFortranCompiler,
      PGIFortranCompiler,
      RustCompiler,
      SunFortranCompiler,
      ValaCompiler,
      VisualStudioCCompiler,
      VisualStudioCPPCompiler,
  )
  
  build_filename = 'meson.build'
  
  known_cpu_families = (
      'aarch64',
      'arm',
      'e2k',
      'ia64',
      'mips',
      'mips64',
      'parisc',
      'ppc',
      'ppc64',
      'riscv32',
      'riscv64',
      's390x',
      'sparc',
      'sparc64',
      'x86',
      'x86_64'
  )
  
  def detect_gcovr(version='3.1', log=False):
      gcovr_exe = 'gcovr'
      try:
          p, found = Popen_safe([gcovr_exe, '--version'])[0:2]
      except (FileNotFoundError, PermissionError):
          # Doesn't exist in PATH or isn't executable
          return None, None
      found = search_version(found)
      if p.returncode == 0:
          if log:
              mlog.log('Found gcovr-{} at {}'.format(found, shlex.quote(shutil.which(gcovr_exe))))
          return gcovr_exe, mesonlib.version_compare(found, '>=' + version)
      return None, None
  
  def find_coverage_tools():
      gcovr_exe
  
  [... the rest is omitted ...]
files: mesonbuild/environment.py
files: #!/usr/bin/env python3
  # Copyright 2016-2017 The Meson development team
  
  # Licensed under the Apache License, Version 2.0 (the "License");
  # you may not use this file except in compliance with the License.
  # You may obtain a copy of the License at
  
  #     http://www.apache.org/licenses/LICENSE-2.0
  
  # Unless required by applicable law or agreed to in writing, software
  # distributed under the License is distributed on an "AS IS" BASIS,
  # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  # See the License for the specific language governing permissions and
  # limitations under the License.
  
  import stat
  import shlex
  import subprocess
  import re, json
  import tempfile
  import textwrap
  import os
  import shutil
  import unittest
  import platform
  from itertools import chain
  from unittest import mock
  from configparser import ConfigParser
  from glob import glob
  from pathlib import (PurePath, Path)
  
  import mesonbuild.mlog
  import mesonbuild.compilers
  import mesonbuild.environment
  import mesonbuild.mesonlib
  import mesonbuild.coredata
  import mesonbuild.modules.gnome
  from mesonbuild.interpreter import Interpreter, ObjectHolder
  from mesonbuild.mesonlib import (
      is_windows, is_osx, is_cygwin, is_dragonflybsd, is_openbsd,
      windows_proof_rmtree, python_command, version_compare,
      BuildDirLock, Version
  )
  from mesonbuild.environment import detect_ninja
  from mesonbuild.mesonlib import MesonException, EnvironmentException
  from mesonbuild.dependencies import PkgConfigDependency, ExternalProgram
  import mesonbuild.modules.pkgconfig
  
  from run_tests import exe_suffix, get_fake_env, get_meson_script
  from run_tests import get_builddir_target_args, get_backend_commands, Backend
  from run_tests import ensure_backend_detects_changes, run_configure_inprocess
  from run_tests import run_mtest_inprocess
  from run_tests import FakeBuild, FakeCompilerOptions
  
  def get_dynamic_section_entry(fname, entry):
      if is_cygwin() or is_osx():
              raise unittest.SkipTest('Test only applicable to ELF platforms')
  
      try:
          raw_out = subprocess.check_output(['readelf', '-d', fname],
                                            universal_newlines=True)
      except FileNotFoundError:
          # FIXME: Try using depfixer.py:Elf() as a fallback
          raise unittest.SkipTest('readelf not found')
      pattern = re.compile(entry + r': \[(.*?)\]')
      for line in raw_out.split('\n'):
          m = pattern.search(line)
          if m is not None:
              return m.group(1)
      return None # The file did not contain the specified entry.
  
  def get_soname(fname):
      return get_dynamic_section_entry(fname, 'soname')
  
  def get_rpath(fname):
      return get_dynamic_section_entry(fname, r'(?:rpath|runpath)')
  
  def is_tarball():
      if not os.path.isdir('docs'):
          return True
      return False
  
  def is_ci():
      if 'TRAVIS' in os.environ or 'APPVEYOR' in os.environ:
          return True
      return False
  
  def _git_init(project_dir):
      subprocess.check_call(['git', 'init'], cwd=project_dir, stdout=subprocess.DEVNULL)
      subprocess.check_call(['git', 'config',
                             'user.name', 'Author Person'], cwd=project_dir)
  
  
  [... the rest is omitted ...]
files: run_unittests.py
files: #!/usr/bin/env python3
  # Copyright 2016-2017 The Meson development team
  
  # Licensed under the Apache License, Version 2.0 (the "License");
  # you may not use this file except in compliance with the License.
  # You may obtain a copy of the License at
  
  #     http://www.apache.org/licenses/LICENSE-2.0
  
  # Unless required by applicable law or agreed to in writing, software
  # distributed under the License is distributed on an "AS IS" BASIS,
  # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  # See the License for the specific language governing permissions and
  # limitations under the License.
  
  import stat
  import shlex
  import subprocess
  import re, json
  import tempfile
  import textwrap
  import os
  import shutil
  import unittest
  import platform
  from itertools import chain
  from unittest import mock
  from configparser import ConfigParser
  from glob import glob
  from pathlib import (PurePath, Path)
  
  import mesonbuild.mlog
  import mesonbuild.compilers
  import mesonbuild.environment
  import mesonbuild.mesonlib
  import mesonbuild.coredata
  import mesonbuild.modules.gnome
  from mesonbuild.interpreter import Interpreter, ObjectHolder
  from mesonbuild.mesonlib import (
      is_windows, is_osx, is_cygwin, is_dragonflybsd, is_openbsd,
      windows_proof_rmtree, python_command, version_compare,
      BuildDirLock, Version
  )
  from mesonbuild.environment import detect_ninja
  from mesonbuild.mesonlib import MesonException, EnvironmentException
  from mesonbuild.dependencies import PkgConfigDependency, ExternalProgram
  import mesonbuild.modules.pkgconfig
  
  from run_tests import exe_suffix, get_fake_env, get_meson_script
  from run_tests import get_builddir_target_args, get_backend_commands, Backend
  from run_tests import ensure_backend_detects_changes, run_configure_inprocess
  from run_tests import run_mtest_inprocess
  from run_tests import FakeBuild, FakeCompilerOptions
  
  def get_dynamic_section_entry(fname, entry):
      if is_cygwin() or is_osx():
              raise unittest.SkipTest('Test only applicable to ELF platforms')
  
      try:
          raw_out = subprocess.check_output(['readelf', '-d', fname],
                                            universal_newlines=True)
      except FileNotFoundError:
          # FIXME: Try using depfixer.py:Elf() as a fallback
          raise unittest.SkipTest('readelf not found')
      pattern = re.compile(entry + r': \[(.*?)\]')
      for line in raw_out.split('\n'):
          m = pattern.search(line)
          if m is not None:
              return m.group(1)
      return None # The file did not contain the specified entry.
  
  def get_soname(fname):
      return get_dynamic_section_entry(fname, 'soname')
  
  def get_rpath(fname):
      return get_dynamic_section_entry(fname, r'(?:rpath|runpath)')
  
  def is_tarball():
      if not os.path.isdir('docs'):
          return True
      return False
  
  def is_ci():
      if 'TRAVIS' in os.environ or 'APPVEYOR' in os.environ:
          return True
      return False
  
  def _git_init(project_dir):
      subprocess.check_call(['git', 'init'], cwd=project_dir, stdout=subprocess.DEVNULL)
      subprocess.check_call(['git', 'config',
                             'user.name', 'Author Person'], cwd=project_dir)
  
  
  [... the rest is omitted ...]
files: run_unittests.py