files.new_contents: # Copyright 2014-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
  import pickle
  import xml.dom.minidom
  import xml.etree.ElementTree as ET
  import uuid
  from pathlib import Path, PurePath
  
  from . import backends
  from .. import build
  from .. import dependencies
  from .. import mlog
  from .. import compilers
  from ..compilers import CompilerArgs
  from ..mesonlib import MesonException, File, python_command
  from ..environment import Environment, build_filename
  
  def autodetect_vs_version(build):
      vs_version = os.getenv('VisualStudioVersion', None)
      vs_install_dir = os.getenv('VSINSTALLDIR', None)
      if not vs_install_dir:
          raise MesonException('Could not detect Visual Studio: Environment variable VSINSTALLDIR is not set!\n'
                               'Are you running meson from the Visual Studio Developer Command Prompt?')
      # VisualStudioVersion is set since Visual Studio 12.0, but sometimes
      # vcvarsall.bat doesn't set it, so also use VSINSTALLDIR
      if vs_version == '14.0' or 'Visual Studio 14' in vs_install_dir:
          from mesonbuild.backend.vs2015backend import Vs2015Backend
          return Vs2015Backend(build)
      if vs_version == '15.0' or 'Visual Studio 17' in vs_install_dir or \
         'Visual Studio\\2017' in vs_install_dir:
          from mesonbuild.backend.vs2017backend import Vs2017Backend
          return Vs2017Backend(build)
      if 'Visual Studio 10.0' in vs_install_dir:
          return Vs2010Backend(build)
      raise MesonException('Could not detect Visual Studio using VisualStudioVersion: {!r} or VSINSTALLDIR: {!r}!\n'
                           'Please specify the exact backend to use.'.format(vs_version, vs_install_dir))
  
  def split_o_flags_args(args):
      """
      Splits any /O args and returns them. Does not take care of flags overriding
      previous ones. Skips non-O flag arguments.
  
      ['/Ox', '/Ob1'] returns ['/Ox', '/Ob1']
      ['/Oxj', '/MP'] returns ['/Ox', '/Oj']
      """
      o_flags = []
      for arg in args:
          if not arg.startswith('/O'):
              continue
          flags = list(arg[2:])
          # Assume that this one can't be clumped with the others since it takes
          # an argument itself
          if 'b' in flags:
              o_flags.append(arg)
          else:
              o_flags += ['/O' + f for f in flags]
      return o_flags
  
  class RegenInfo:
      def __init__(self, source_dir, build_dir, depfiles):
          self.source_dir = source_dir
          self.build_dir = build_dir
          self.depfiles = depfiles
  
  class Vs2010Backend(backends.Backend):
      def __init__(self, build):
          super().__init__(build)
          self.name = 'vs2010'
          self.project_file_version = '10.0.30319.1'
          self.platform_toolset = None
          self.vs_version = '2010'
          self.windows_target_platform_version = None
          self.subdirs = {}
  
      def generate_custom_generator_commands(self, target, parent_node):
          generator_output_files = []
          custom_target_include_dirs = []
          custom_target_output_files = []
          target_private_dir = self.relpath(self.get_target_private_dir(target), self.get_target_dir(target))
          down = self.target_to_build_root(target)
          for genlist in target.get_generated_sources():
              if isinstance(genlist, (build.CustomTarget, build.CustomTargetIndex)):
                  for i in genlist.get_outputs():
                      # Path to the generated source from the current vcxproj dir via the build root
  
  [... the rest is omitted ...]
files.new_path: mesonbuild/backend/vs2010backend.py
files.old_contents: # Copyright 2014-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
  import pickle
  import xml.dom.minidom
  import xml.etree.ElementTree as ET
  import uuid
  from pathlib import Path, PurePath
  
  from . import backends
  from .. import build
  from .. import dependencies
  from .. import mlog
  from .. import compilers
  from ..compilers import CompilerArgs
  from ..mesonlib import MesonException, File, python_command
  from ..environment import Environment, build_filename
  
  def autodetect_vs_version(build):
      vs_version = os.getenv('VisualStudioVersion', None)
      vs_install_dir = os.getenv('VSINSTALLDIR', None)
      if not vs_install_dir:
          raise MesonException('Could not detect Visual Studio: Environment variable VSINSTALLDIR is not set!\n'
                               'Are you running meson from the Visual Studio Developer Command Prompt?')
      # VisualStudioVersion is set since Visual Studio 12.0, but sometimes
      # vcvarsall.bat doesn't set it, so also use VSINSTALLDIR
      if vs_version == '14.0' or 'Visual Studio 14' in vs_install_dir:
          from mesonbuild.backend.vs2015backend import Vs2015Backend
          return Vs2015Backend(build)
      if vs_version == '15.0' or 'Visual Studio 17' in vs_install_dir or \
         'Visual Studio\\2017' in vs_install_dir:
          from mesonbuild.backend.vs2017backend import Vs2017Backend
          return Vs2017Backend(build)
      if 'Visual Studio 10.0' in vs_install_dir:
          return Vs2010Backend(build)
      raise MesonException('Could not detect Visual Studio using VisualStudioVersion: {!r} or VSINSTALLDIR: {!r}!\n'
                           'Please specify the exact backend to use.'.format(vs_version, vs_install_dir))
  
  def split_o_flags_args(args):
      """
      Splits any /O args and returns them. Does not take care of flags overriding
      previous ones. Skips non-O flag arguments.
  
      ['/Ox', '/Ob1'] returns ['/Ox', '/Ob1']
      ['/Oxj', '/MP'] returns ['/Ox', '/Oj']
      """
      o_flags = []
      for arg in args:
          if not arg.startswith('/O'):
              continue
          flags = list(arg[2:])
          # Assume that this one can't be clumped with the others since it takes
          # an argument itself
          if 'b' in flags:
              o_flags.append(arg)
          else:
              o_flags += ['/O' + f for f in flags]
      return o_flags
  
  class RegenInfo:
      def __init__(self, source_dir, build_dir, depfiles):
          self.source_dir = source_dir
          self.build_dir = build_dir
          self.depfiles = depfiles
  
  class Vs2010Backend(backends.Backend):
      def __init__(self, build):
          super().__init__(build)
          self.name = 'vs2010'
          self.project_file_version = '10.0.30319.1'
          self.platform_toolset = None
          self.vs_version = '2010'
          self.windows_target_platform_version = None
          self.subdirs = {}
  
      def generate_custom_generator_commands(self, target, parent_node):
          generator_output_files = []
          custom_target_include_dirs = []
          custom_target_output_files = []
          target_private_dir = self.relpath(self.get_target_private_dir(target), self.get_target_dir(target))
          down = self.target_to_build_root(target)
          for genlist in target.get_generated_sources():
              if isinstance(genlist, (build.CustomTarget, build.CustomTargetIndex)):
                  for i in genlist.get_outputs():
                      # Path to the generated source from the current vcxproj dir via the build root
  
  [... the rest is omitted ...]
files.old_path: mesonbuild/backend/vs2010backend.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 configparser, os, platform, re, sys, shlex, shutil, subprocess
  
  from . import coredata
  from .linkers import ArLinker, ArmarLinker, VisualStudioLinker, DLinker, CcrxLinker
  from . import mesonlib
  from .mesonlib import MesonException, EnvironmentException, PerMachine, 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,
      ClangClCCompiler,
      ClangClCPPCompiler,
      G95FortranCompiler,
      GnuCCompiler,
      GnuCPPCompiler,
      GnuFortranCompiler,
      GnuObjCCompiler,
      GnuObjCPPCompiler,
      ElbrusCCompiler,
      ElbrusCPPCompiler,
      ElbrusFortranCompiler,
      IntelCCompiler,
      IntelCPPCompiler,
      IntelFortranCompiler,
      JavaCompiler,
      MonoCompiler,
      VisualStudioCsCompiler,
      NAGFortranCompiler,
      Open64FortranCompiler,
      PathScaleFortranCompiler,
      PGIFortranCompiler,
      RustCompiler,
      CcrxCCompiler,
      CcrxCPPCompiler,
      SunFortranCompiler,
      ValaCompiler,
      VisualStudioCCompiler,
      VisualStudioCPPCompiler,
  )
  
  build_filename = 'meson.build'
  
  known_cpu_families = (
      'aarch64',
      'arc',
      'arm',
      'e2k',
      'ia64',
      'mips',
      'mips64',
      'parisc',
      'ppc',
      'ppc64',
      'riscv32',
      'riscv64',
      'rx',
      '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, '--version']):
          lcov_exe = None
      if not mesonlib.exe_exists([genhtml_exe, '--version']):
          genhtml_exe = None
  
      return gcovr_exe, gcovr_new_rootdir, lcov_exe, genhtml_exe
  
  def detect_ninja(version='1.5', log=False):
      for n in ['ninja', 'ninja-build', 'samu']:
          try:
              p, found = Popen_safe([n, '--version'])[0:2]
          except (FileNotFoundError, PermissionError):
              # Doesn't exist in PATH or isn't executable
              continue
  
  
  [... 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 configparser, os, platform, re, sys, shlex, shutil, subprocess
  
  from . import coredata
  from .linkers import ArLinker, ArmarLinker, VisualStudioLinker, DLinker, CcrxLinker
  from . import mesonlib
  from .mesonlib import MesonException, EnvironmentException, PerMachine, 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,
      ClangClCCompiler,
      ClangClCPPCompiler,
      G95FortranCompiler,
      GnuCCompiler,
      GnuCPPCompiler,
      GnuFortranCompiler,
      GnuObjCCompiler,
      GnuObjCPPCompiler,
      ElbrusCCompiler,
      ElbrusCPPCompiler,
      ElbrusFortranCompiler,
      IntelCCompiler,
      IntelCPPCompiler,
      IntelFortranCompiler,
      JavaCompiler,
      MonoCompiler,
      VisualStudioCsCompiler,
      NAGFortranCompiler,
      Open64FortranCompiler,
      PathScaleFortranCompiler,
      PGIFortranCompiler,
      RustCompiler,
      CcrxCCompiler,
      CcrxCPPCompiler,
      SunFortranCompiler,
      ValaCompiler,
      VisualStudioCCompiler,
      VisualStudioCPPCompiler,
  )
  
  build_filename = 'meson.build'
  
  known_cpu_families = (
      'aarch64',
      'arc',
      'arm',
      'e2k',
      'ia64',
      'mips',
      'mips64',
      'parisc',
      'ppc',
      'ppc64',
      'riscv32',
      'riscv64',
      'rx',
      '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, '--version']):
          lcov_exe = None
      if not mesonlib.exe_exists([genhtml_exe, '--version']):
          genhtml_exe = None
  
      return gcovr_exe, gcovr_new_rootdir, lcov_exe, genhtml_exe
  
  def detect_ninja(version='1.5', log=False):
      for n in ['ninja', 'ninja-build', 'samu']:
          try:
              p, found = Popen_safe([n, '--version'])[0:2]
          except (FileNotFoundError, PermissionError):
              # Doesn't exist in PATH or isn't executable
              continue
  
  
  [... the rest is omitted ...]
files.old_path: mesonbuild/environment.py