files.new_contents: # Copyright 2013-2019 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.
  
  # This file contains the detection logic for external dependencies useful for
  # development purposes, such as testing, debugging, etc..
  
  import functools
  import glob
  import os
  import re
  
  from .. import mesonlib, mlog
  from ..mesonlib import version_compare, stringlistify, extract_as_list, MachineChoice
  from ..environment import get_llvm_tool_names
  from .base import (
      DependencyException, DependencyMethods, ExternalDependency, PkgConfigDependency,
      strip_system_libdirs, ConfigToolDependency, CMakeDependency, HasNativeKwarg
  )
  from .misc import ThreadDependency
  
  from typing import List, Tuple
  
  
  def get_shared_library_suffix(environment, for_machine: MachineChoice):
      """This is only gauranteed to work for languages that compile to machine
      code, not for languages like C# that use a bytecode and always end in .dll
      """
      m = environment.machines[for_machine]
      if m.is_windows():
          return '.dll'
      elif m.is_darwin():
          return '.dylib'
      return '.so'
  
  
  class GTestDependency(ExternalDependency):
      def __init__(self, environment, kwargs):
          super().__init__('gtest', environment, 'cpp', kwargs)
          self.main = kwargs.get('main', False)
          self.src_dirs = ['/usr/src/gtest/src', '/usr/src/googletest/googletest/src']
          self.detect()
          self._add_sub_dependency(ThreadDependency, environment, kwargs)
  
      def detect(self):
          gtest_detect = self.clib_compiler.find_library("gtest", self.env, [])
          gtest_main_detect = self.clib_compiler.find_library("gtest_main", self.env, [])
          if gtest_detect and (not self.main or gtest_main_detect):
              self.is_found = True
              self.compile_args = []
              self.link_args = gtest_detect
              if self.main:
                  self.link_args += gtest_main_detect
              self.sources = []
              self.prebuilt = True
          elif self.detect_srcdir():
              self.is_found = True
              self.compile_args = ['-I' + d for d in self.src_include_dirs]
              self.link_args = []
              if self.main:
                  self.sources = [self.all_src, self.main_src]
              else:
                  self.sources = [self.all_src]
              self.prebuilt = False
          else:
              self.is_found = False
  
      def detect_srcdir(self):
          for s in self.src_dirs:
              if os.path.exists(s):
                  self.src_dir = s
                  self.all_src = mesonlib.File.from_absolute_file(
                      os.path.join(self.src_dir, 'gtest-all.cc'))
                  self.main_src = mesonlib.File.from_absolute_file(
                      os.path.join(self.src_dir, 'gtest_main.cc'))
                  self.src_include_dirs = [os.path.normpath(os.path.join(self.src_dir, '..')),
                                           os.path.normpath(os.path.join(self.src_dir, '../include')),
                                           ]
                  return True
          return False
  
      def log_info(self):
          if self.prebuilt:
              return 'prebuilt'
          else:
              return 'building self'
  
      def log_tried(self):
          return 'system'
  
      @classmethod
      def _factory(cls, environment, kwargs):
          methods = cls._process_method_kw(kwargs)
          candidates = []
  
          if DependencyMethods.PKGCONFIG in methods:
              pcname = 'gtest_main' if kwargs.get('main', False) else 'gtest'
              candidates.append(functools.partial(PkgConfigDependency, pcname, environment, kwargs))
  
          if DependencyMethods.SYSTEM in methods:
              candidates.append(functools.partial(GTestDependency, environment, kwargs))
  
          return candidates
  
     
  
  [... the rest is omitted ...]
files.new_path: mesonbuild/dependencies/dev.py
files.old_contents: # Copyright 2013-2019 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.
  
  # This file contains the detection logic for external dependencies useful for
  # development purposes, such as testing, debugging, etc..
  
  import functools
  import glob
  import os
  import re
  
  from .. import mesonlib, mlog
  from ..mesonlib import version_compare, stringlistify, extract_as_list, MachineChoice
  from .base import (
      DependencyException, DependencyMethods, ExternalDependency, PkgConfigDependency,
      strip_system_libdirs, ConfigToolDependency, CMakeDependency, HasNativeKwarg
  )
  from .misc import ThreadDependency
  
  from typing import List, Tuple
  
  
  def get_shared_library_suffix(environment, for_machine: MachineChoice):
      """This is only gauranteed to work for languages that compile to machine
      code, not for languages like C# that use a bytecode and always end in .dll
      """
      m = environment.machines[for_machine]
      if m.is_windows():
          return '.dll'
      elif m.is_darwin():
          return '.dylib'
      return '.so'
  
  
  class GTestDependency(ExternalDependency):
      def __init__(self, environment, kwargs):
          super().__init__('gtest', environment, 'cpp', kwargs)
          self.main = kwargs.get('main', False)
          self.src_dirs = ['/usr/src/gtest/src', '/usr/src/googletest/googletest/src']
          self.detect()
          self._add_sub_dependency(ThreadDependency, environment, kwargs)
  
      def detect(self):
          gtest_detect = self.clib_compiler.find_library("gtest", self.env, [])
          gtest_main_detect = self.clib_compiler.find_library("gtest_main", self.env, [])
          if gtest_detect and (not self.main or gtest_main_detect):
              self.is_found = True
              self.compile_args = []
              self.link_args = gtest_detect
              if self.main:
                  self.link_args += gtest_main_detect
              self.sources = []
              self.prebuilt = True
          elif self.detect_srcdir():
              self.is_found = True
              self.compile_args = ['-I' + d for d in self.src_include_dirs]
              self.link_args = []
              if self.main:
                  self.sources = [self.all_src, self.main_src]
              else:
                  self.sources = [self.all_src]
              self.prebuilt = False
          else:
              self.is_found = False
  
      def detect_srcdir(self):
          for s in self.src_dirs:
              if os.path.exists(s):
                  self.src_dir = s
                  self.all_src = mesonlib.File.from_absolute_file(
                      os.path.join(self.src_dir, 'gtest-all.cc'))
                  self.main_src = mesonlib.File.from_absolute_file(
                      os.path.join(self.src_dir, 'gtest_main.cc'))
                  self.src_include_dirs = [os.path.normpath(os.path.join(self.src_dir, '..')),
                                           os.path.normpath(os.path.join(self.src_dir, '../include')),
                                           ]
                  return True
          return False
  
      def log_info(self):
          if self.prebuilt:
              return 'prebuilt'
          else:
              return 'building self'
  
      def log_tried(self):
          return 'system'
  
      @classmethod
      def _factory(cls, environment, kwargs):
          methods = cls._process_method_kw(kwargs)
          candidates = []
  
          if DependencyMethods.PKGCONFIG in methods:
              pcname = 'gtest_main' if kwargs.get('main', False) else 'gtest'
              candidates.append(functools.partial(PkgConfigDependency, pcname, environment, kwargs))
  
          if DependencyMethods.SYSTEM in methods:
              candidates.append(functools.partial(GTestDependency, environment, kwargs))
  
          return candidates
  
      @staticmethod
      def get_methods():
          return [
  
  [... the rest is omitted ...]
files.old_path: mesonbuild/dependencies/dev.py
files.new_contents: # 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 os, platform, re, sys, shutil, subprocess, typing
  import tempfile
  import shlex
  
  from . import coredata
  from .linkers import ArLinker, ArmarLinker, VisualStudioLinker, DLinker, CcrxLinker, IntelVisualStudioLinker
  from . import mesonlib
  from .mesonlib import (
      MesonException, EnvironmentException, MachineChoice, Popen_safe,
      PerMachineDefaultable, PerThreeMachineDefaultable, split_args, quote_arg
  )
  from . import mlog
  
  from .envconfig import (
      BinaryTable, Directories, MachineInfo, MesonConfigFile,
      Properties, known_cpu_families,
  )
  from . import compilers
  from .compilers import (
      Compiler,
      CompilerType,
      is_assembly,
      is_header,
      is_library,
      is_llvm_ir,
      is_object,
      is_source,
  )
  from .linkers import (
      AppleDynamicLinker,
      ArmClangDynamicLinker,
      ArmDynamicLinker,
      CcrxDynamicLinker,
      ClangClDynamicLinker,
      DynamicLinker,
      GnuDynamicLinker,
      LLVMDynamicLinker,
      MSVCDynamicLinker,
      OptlinkDynamicLinker,
      PGIDynamicLinker,
      PGIStaticLinker,
      SolarisDynamicLinker,
      XildAppleDynamicLinker,
      XildLinuxDynamicLinker,
      XilinkDynamicLinker,
      CudaLinker,
  )
  from functools import lru_cache
  from .compilers import (
      ArmCCompiler,
      ArmCPPCompiler,
      ArmclangCCompiler,
      ArmclangCPPCompiler,
      ClangCCompiler,
      ClangCPPCompiler,
      ClangObjCCompiler,
      ClangObjCPPCompiler,
      ClangClCCompiler,
      ClangClCPPCompiler,
      FlangFortranCompiler,
      G95FortranCompiler,
      GnuCCompiler,
      GnuCPPCompiler,
      GnuFortranCompiler,
      GnuObjCCompiler,
      GnuObjCPPCompiler,
      ElbrusCCompiler,
      ElbrusCPPCompiler,
      ElbrusFortranCompiler,
      EmscriptenCCompiler,
      EmscriptenCPPCompiler,
      IntelCCompiler,
      IntelClCCompiler,
      IntelCPPCompiler,
      IntelClCPPCompiler,
      IntelFortranCompiler,
      IntelClFortranCompiler,
      JavaCompiler,
      MonoCompiler,
      CudaCompiler,
      VisualStudioCsCompiler,
      NAGFortranCompiler,
      Open64FortranCompiler,
      PathScaleFortranCompiler,
      PGICCompiler,
      PGICPPCompiler,
      PGIFortranCompiler,
      RustCompiler,
      CcrxCCompiler,
      CcrxCPPCompiler,
      SunFortranCompiler,
      ValaCompiler,
      VisualStudioCCompiler,
      VisualStudioCPPCompiler,
  )
  
  build_filename = 'meson.build'
  
  CompilersDict = typing.Dict[str, Compiler]
  
  def detect_gcovr(min_version='3.3', new_rootdir_version='4.2', 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 and mesonlib.version_compare(found, '>=' + min_version):
          if log:
              mlog.log('Found gcovr-{} at {}'.format(found, quote_arg(shutil.which(gcovr_exe))))
          return gcovr_exe, mesonlib.version_compare(found, '>=' + new_rootdir_version)
      return None, None
  
  def find_coverage_tools():
      gcovr
  
  [... the rest is omitted ...]
files.new_path: mesonbuild/environment.py
files.old_contents: # 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 os, platform, re, sys, shutil, subprocess, typing
  import tempfile
  import shlex
  
  from . import coredata
  from .linkers import ArLinker, ArmarLinker, VisualStudioLinker, DLinker, CcrxLinker, IntelVisualStudioLinker
  from . import mesonlib
  from .mesonlib import (
      MesonException, EnvironmentException, MachineChoice, Popen_safe,
      PerMachineDefaultable, PerThreeMachineDefaultable, split_args, quote_arg
  )
  from . import mlog
  
  from .envconfig import (
      BinaryTable, Directories, MachineInfo, MesonConfigFile,
      Properties, known_cpu_families,
  )
  from . import compilers
  from .compilers import (
      Compiler,
      CompilerType,
      is_assembly,
      is_header,
      is_library,
      is_llvm_ir,
      is_object,
      is_source,
  )
  from .linkers import (
      AppleDynamicLinker,
      ArmClangDynamicLinker,
      ArmDynamicLinker,
      CcrxDynamicLinker,
      ClangClDynamicLinker,
      DynamicLinker,
      GnuDynamicLinker,
      LLVMDynamicLinker,
      MSVCDynamicLinker,
      OptlinkDynamicLinker,
      PGIDynamicLinker,
      PGIStaticLinker,
      SolarisDynamicLinker,
      XildAppleDynamicLinker,
      XildLinuxDynamicLinker,
      XilinkDynamicLinker,
      CudaLinker,
  )
  from functools import lru_cache
  from .compilers import (
      ArmCCompiler,
      ArmCPPCompiler,
      ArmclangCCompiler,
      ArmclangCPPCompiler,
      ClangCCompiler,
      ClangCPPCompiler,
      ClangObjCCompiler,
      ClangObjCPPCompiler,
      ClangClCCompiler,
      ClangClCPPCompiler,
      FlangFortranCompiler,
      G95FortranCompiler,
      GnuCCompiler,
      GnuCPPCompiler,
      GnuFortranCompiler,
      GnuObjCCompiler,
      GnuObjCPPCompiler,
      ElbrusCCompiler,
      ElbrusCPPCompiler,
      ElbrusFortranCompiler,
      EmscriptenCCompiler,
      EmscriptenCPPCompiler,
      IntelCCompiler,
      IntelClCCompiler,
      IntelCPPCompiler,
      IntelClCPPCompiler,
      IntelFortranCompiler,
      IntelClFortranCompiler,
      JavaCompiler,
      MonoCompiler,
      CudaCompiler,
      VisualStudioCsCompiler,
      NAGFortranCompiler,
      Open64FortranCompiler,
      PathScaleFortranCompiler,
      PGICCompiler,
      PGICPPCompiler,
      PGIFortranCompiler,
      RustCompiler,
      CcrxCCompiler,
      CcrxCPPCompiler,
      SunFortranCompiler,
      ValaCompiler,
      VisualStudioCCompiler,
      VisualStudioCPPCompiler,
  )
  
  build_filename = 'meson.build'
  
  CompilersDict = typing.Dict[str, Compiler]
  
  def detect_gcovr(min_version='3.3', new_rootdir_version='4.2', 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 and mesonlib.version_compare(found, '>=' + min_version):
          if log:
              mlog.log('Found gcovr-{} at {}'.format(found, quote_arg(shutil.which(gcovr_exe))))
          return gcovr_exe, mesonlib.version_compare(found, '>=' + new_rootdir_version)
      return None, None
  
  def find_coverage_tools():
      gcovr
  
  [... the rest is omitted ...]
files.old_path: mesonbuild/environment.py