diff options
author | Dylan Baker <dylan@pnwbakers.com> | 2020-06-08 12:00:19 -0700 |
---|---|---|
committer | Dylan Baker <dylan@pnwbakers.com> | 2020-06-12 11:16:24 -0700 |
commit | 01e0cc6735f4633cc3f179a0b0f877ab863a33f0 (patch) | |
tree | c37114773a730ee046e1eeab6704deacf779d126 | |
parent | 85be45ea1169c6383a252c5c2235b024c50a9672 (diff) | |
download | meson-01e0cc6735f4633cc3f179a0b0f877ab863a33f0.zip meson-01e0cc6735f4633cc3f179a0b0f877ab863a33f0.tar.gz meson-01e0cc6735f4633cc3f179a0b0f877ab863a33f0.tar.bz2 |
cmake: Use shared find_external_program instead of open coding
-rw-r--r-- | mesonbuild/cmake/executor.py | 27 |
1 files changed, 5 insertions, 22 deletions
diff --git a/mesonbuild/cmake/executor.py b/mesonbuild/cmake/executor.py index 5ca8196..ae48918 100644 --- a/mesonbuild/cmake/executor.py +++ b/mesonbuild/cmake/executor.py @@ -79,25 +79,7 @@ class CMakeExecutor: self.extra_cmake_args += ['-DCMAKE_PREFIX_PATH={}'.format(';'.join(self.prefix_paths))] def find_cmake_binary(self, environment: Environment, silent: bool = False) -> T.Tuple['ExternalProgram', str]: - from ..dependencies.base import ExternalProgram - - # Create an iterator of options - def search(): - # Lookup in cross or machine file. - potential_cmakepath = environment.lookup_binary_entry(self.for_machine, 'cmake') - if potential_cmakepath is not None: - mlog.debug('CMake binary for %s specified from cross file, native file, or env var as %s.', self.for_machine, potential_cmakepath) - yield ExternalProgram.from_entry('cmake', potential_cmakepath) - # We never fallback if the user-specified option is no good, so - # stop returning options. - return - mlog.debug('CMake binary missing from cross or native file, or env var undefined.') - # Fallback on hard-coded defaults. - # TODO prefix this for the cross case instead of ignoring thing. - if environment.machines.matches_build_machine(self.for_machine): - for potential_cmakepath in environment.default_cmake: - mlog.debug('Trying a default CMake fallback at', potential_cmakepath) - yield ExternalProgram(potential_cmakepath, silent=True) + from ..dependencies.base import find_external_program # Only search for CMake the first time and store the result in the class # definition @@ -107,10 +89,11 @@ class CMakeExecutor: mlog.debug('CMake binary for %s is cached.' % self.for_machine) else: assert CMakeExecutor.class_cmakebin[self.for_machine] is None + mlog.debug('CMake binary for %s is not cached' % self.for_machine) - for potential_cmakebin in search(): - mlog.debug('Trying CMake binary {} for machine {} at {}' - .format(potential_cmakebin.name, self.for_machine, potential_cmakebin.command)) + for potential_cmakebin in find_external_program( + environment, self.for_machine, 'cmake', 'CMake', + environment.default_cmake): version_if_ok = self.check_cmake(potential_cmakebin) if not version_if_ok: continue |