diff options
author | Jussi Pakkanen <jpakkane@gmail.com> | 2019-06-19 00:23:47 +0300 |
---|---|---|
committer | GitHub <noreply@github.com> | 2019-06-19 00:23:47 +0300 |
commit | 7d8bd4ffaba30e603f256ec6605f826a7ea75a7e (patch) | |
tree | 00d2a151705bdcbb5397be8e891612367fb57469 /mesonbuild/cmake/interpreter.py | |
parent | a1ea5fd16b5b5cb4d406b1185bb4b9653d85f1eb (diff) | |
parent | b1cf0fd3806d9b159a3c6cc6b1bd2ef4d14a6021 (diff) | |
download | meson-7d8bd4ffaba30e603f256ec6605f826a7ea75a7e.zip meson-7d8bd4ffaba30e603f256ec6605f826a7ea75a7e.tar.gz meson-7d8bd4ffaba30e603f256ec6605f826a7ea75a7e.tar.bz2 |
Merge pull request #5457 from mensinda/cmakeRefactor
CMake code refactor
Diffstat (limited to 'mesonbuild/cmake/interpreter.py')
-rw-r--r-- | mesonbuild/cmake/interpreter.py | 19 |
1 files changed, 9 insertions, 10 deletions
diff --git a/mesonbuild/cmake/interpreter.py b/mesonbuild/cmake/interpreter.py index 435f8d2..88700f1 100644 --- a/mesonbuild/cmake/interpreter.py +++ b/mesonbuild/cmake/interpreter.py @@ -17,18 +17,20 @@ from .common import CMakeException from .client import CMakeClient, RequestCMakeInputs, RequestConfigure, RequestCompute, RequestCodeModel, CMakeTarget +from .executor import CMakeExecutor from .. import mlog -from ..build import Build from ..environment import Environment from ..mesonlib import MachineChoice from ..mparser import Token, BaseNode, CodeBlockNode, FunctionNode, ArrayNode, ArgumentNode, AssignmentNode, BooleanNode, StringNode, IdNode, MethodNode -from ..backend.backends import Backend from ..compilers.compilers import lang_suffixes, header_suffixes, obj_suffixes -from ..dependencies.base import CMakeDependency, ExternalProgram from subprocess import Popen, PIPE, STDOUT -from typing import List, Dict, Optional +from typing import List, Dict, Optional, TYPE_CHECKING import os, re +if TYPE_CHECKING: + from ..build import Build + from ..backend.backends import Backend + backend_generator_map = { 'ninja': 'Ninja', 'xcode': 'Xcode', @@ -276,7 +278,7 @@ class ConverterTarget: mlog.log(' -', key, '=', mlog.bold(str(val))) class CMakeInterpreter: - def __init__(self, build: Build, subdir: str, src_dir: str, install_prefix: str, env: Environment, backend: Backend): + def __init__(self, build: 'Build', subdir: str, src_dir: str, install_prefix: str, env: Environment, backend: 'Backend'): assert(hasattr(backend, 'name')) self.build = build self.subdir = subdir @@ -303,10 +305,7 @@ class CMakeInterpreter: def configure(self, extra_cmake_options: List[str]) -> None: for_machine = MachineChoice.HOST # TODO make parameter # Find CMake - cmake_exe, cmake_vers, _ = CMakeDependency.find_cmake_binary(self.env, for_machine) - if cmake_exe is None or cmake_exe is False: - raise CMakeException('Unable to find CMake') - assert(isinstance(cmake_exe, ExternalProgram)) + cmake_exe = CMakeExecutor(self.env, '>=3.7', for_machine) if not cmake_exe.found(): raise CMakeException('Unable to find CMake') @@ -333,7 +332,7 @@ class CMakeInterpreter: # Run CMake mlog.log() with mlog.nested(): - mlog.log('Configuring the build directory with', mlog.bold('CMake'), 'version', mlog.cyan(cmake_vers)) + mlog.log('Configuring the build directory with', mlog.bold('CMake'), 'version', mlog.cyan(cmake_exe.version())) mlog.log(mlog.bold('Running:'), ' '.join(cmake_args)) mlog.log() os.makedirs(self.build_dir, exist_ok=True) |