diff options
author | Nirbheek Chauhan <nirbheek@centricular.com> | 2018-06-29 19:33:17 +0530 |
---|---|---|
committer | Nirbheek Chauhan <nirbheek.chauhan@gmail.com> | 2018-07-01 13:59:48 +0000 |
commit | ec29f19c1274d72e3a2639e47caf4a7f17ffa436 (patch) | |
tree | 70ffad6c031159508e92b05ff69acbc052262480 /mesonbuild/dependencies | |
parent | ae8d044cb6dca20c1d6504a27660bcbed16db438 (diff) | |
download | meson-ec29f19c1274d72e3a2639e47caf4a7f17ffa436.zip meson-ec29f19c1274d72e3a2639e47caf4a7f17ffa436.tar.gz meson-ec29f19c1274d72e3a2639e47caf4a7f17ffa436.tar.bz2 |
Add a helper for fetching of binaries from cross files
A number of cases have to be taken care of while doing this, so
refactor it into a helper on ExternalProgram and use it everywhere.
1. Command is a list of len > 1, use it as-is
2. Command is a list of len == 1 (or a string), use as a string
3. If command is an absolute path, use it as-is
4. If command is not an absolute path, search for it
Diffstat (limited to 'mesonbuild/dependencies')
-rw-r--r-- | mesonbuild/dependencies/base.py | 21 | ||||
-rw-r--r-- | mesonbuild/dependencies/ui.py | 6 |
2 files changed, 22 insertions, 5 deletions
diff --git a/mesonbuild/dependencies/base.py b/mesonbuild/dependencies/base.py index 8319cb7..07d06a1 100644 --- a/mesonbuild/dependencies/base.py +++ b/mesonbuild/dependencies/base.py @@ -438,8 +438,7 @@ class PkgConfigDependency(ExternalDependency): if self.required: raise DependencyException('Pkg-config binary missing from cross file') else: - pkgname = environment.cross_info.config['binaries']['pkgconfig'] - potential_pkgbin = ExternalProgram(pkgname, silent=True) + potential_pkgbin = ExternalProgram.from_cross_info(environment.cross_info, 'pkgconfig') if potential_pkgbin.found(): self.pkgbin = potential_pkgbin PkgConfigDependency.class_pkgbin = self.pkgbin @@ -799,6 +798,24 @@ class ExternalProgram: return r.format(self.__class__.__name__, self.name, self.command) @staticmethod + def from_cross_info(cross_info, name): + if name not in cross_info.config['binaries']: + return NonExistingExternalProgram() + command = cross_info.config['binaries'][name] + if not isinstance(command, (list, str)): + raise MesonException('Invalid type {!r} for binary {!r} in cross file' + ''.format(command, name)) + if isinstance(command, list): + if len(command) == 1: + command = command[0] + # We cannot do any searching if the command is a list, and we don't + # need to search if the path is an absolute path. + if isinstance(command, list) or os.path.isabs(command): + return ExternalProgram(name, command=command, silent=True) + # Search for the command using the specified string! + return ExternalProgram(command, silent=True) + + @staticmethod def _shebang_to_cmd(script): """ Check if the file has a shebang and manually parse it to figure out diff --git a/mesonbuild/dependencies/ui.py b/mesonbuild/dependencies/ui.py index 72958dd..324f9fa 100644 --- a/mesonbuild/dependencies/ui.py +++ b/mesonbuild/dependencies/ui.py @@ -291,10 +291,10 @@ class QtBaseDependency(ExternalDependency): self.bindir = os.path.join(prefix, 'bin') def _find_qmake(self, qmake): - # Even when cross-compiling, if we don't get a cross-info qmake, we + # Even when cross-compiling, if a cross-info qmake is not specified, we # fallback to using the qmake in PATH because that's what we used to do - if self.env.is_cross_build(): - qmake = self.env.cross_info.config['binaries'].get('qmake', qmake) + if self.env.is_cross_build() and 'qmake' in self.env.cross_info.config['binaries']: + return ExternalProgram.from_cross_info(self.env.cross_info, 'qmake') return ExternalProgram(qmake, silent=True) def _qmake_detect(self, mods, kwargs): |