blob: 2b22531dd0c1d67e08bc377565e4c0e98ac99788 [file] [log] [blame]
Brad Bishop1a4b7ee2018-12-16 17:11:34 -08001From e762d85c823adfefc27ba6128c7b997aa50166ce Mon Sep 17 00:00:00 2001
Brad Bishop316dfdd2018-06-25 12:45:53 -04002From: Ricardo Ribalda Delgado <ricardo.ribalda@gmail.com>
3Date: Wed, 15 Nov 2017 15:05:01 +0100
Brad Bishop1a4b7ee2018-12-16 17:11:34 -08004Subject: [PATCH] native_bindir
Brad Bishop316dfdd2018-06-25 12:45:53 -04005
6Some libraries, like QT, have pre-processors that convert their input
7files into something that the cross-compiler can process. We find the
8path of those pre-processors via pkg-config-native instead of
9pkg-config.
10
11This path forces the use of pkg-config-native for host_bins arguments.
12
13There are some discussions upstream to merge this patch, but I presonaly believe
14that is is OE only. https://github.com/mesonbuild/meson/issues/1849#issuecomment-303730323
15
16Upstream-Status: Inappropriate [OE specific]
17Signed-off-by: Ricardo Ribalda Delgado <ricardo.ribalda@gmail.com>
18
19---
Brad Bishop1a4b7ee2018-12-16 17:11:34 -080020 mesonbuild/dependencies/base.py | 19 +++++++++++--------
Brad Bishop316dfdd2018-06-25 12:45:53 -040021 mesonbuild/dependencies/ui.py | 6 +++---
Brad Bishop1a4b7ee2018-12-16 17:11:34 -080022 2 files changed, 14 insertions(+), 11 deletions(-)
Brad Bishop316dfdd2018-06-25 12:45:53 -040023
24diff --git a/mesonbuild/dependencies/base.py b/mesonbuild/dependencies/base.py
Brad Bishop1a4b7ee2018-12-16 17:11:34 -080025index 6d3678f..90fdb80 100644
Brad Bishop316dfdd2018-06-25 12:45:53 -040026--- a/mesonbuild/dependencies/base.py
27+++ b/mesonbuild/dependencies/base.py
Brad Bishop1a4b7ee2018-12-16 17:11:34 -080028@@ -146,7 +146,7 @@ class Dependency:
Brad Bishop316dfdd2018-06-25 12:45:53 -040029 def need_threads(self):
30 return False
31
32- def get_pkgconfig_variable(self, variable_name, kwargs):
33+ def get_pkgconfig_variable(self, variable_name, kwargs, use_native=False):
34 raise DependencyException('{!r} is not a pkgconfig dependency'.format(self.name))
35
36 def get_configtool_variable(self, variable_name):
Brad Bishop1a4b7ee2018-12-16 17:11:34 -080037@@ -183,7 +183,7 @@ class InternalDependency(Dependency):
Brad Bishop316dfdd2018-06-25 12:45:53 -040038 self.sources = sources
39 self.ext_deps = ext_deps
40
41- def get_pkgconfig_variable(self, variable_name, kwargs):
42+ def get_pkgconfig_variable(self, variable_name, kwargs, use_native=False):
43 raise DependencyException('Method "get_pkgconfig_variable()" is '
44 'invalid for an internal dependency')
45
Brad Bishop1a4b7ee2018-12-16 17:11:34 -080046@@ -523,15 +523,18 @@ class PkgConfigDependency(ExternalDependency):
Brad Bishop316dfdd2018-06-25 12:45:53 -040047 return s.format(self.__class__.__name__, self.name, self.is_found,
48 self.version_reqs)
49
Brad Bishop1a4b7ee2018-12-16 17:11:34 -080050- def _call_pkgbin_real(self, args, env):
51- cmd = self.pkgbin.get_command() + args
52+ def _call_pkgbin_real(self, args, env, use_native=False):
53+ if use_native:
Brad Bishopf3fd2882019-06-21 08:06:37 -040054+ cmd = [self.pkgbin.get_command()[0] + "-native"] + args
Brad Bishop1a4b7ee2018-12-16 17:11:34 -080055+ else:
56+ cmd = self.pkgbin.get_command() + args
57 p, out = Popen_safe(cmd, env=env)[0:2]
58 rc, out = p.returncode, out.strip()
59 call = ' '.join(cmd)
60 mlog.debug("Called `{}` -> {}\n{}".format(call, rc, out))
61 return rc, out
62
Brad Bishop316dfdd2018-06-25 12:45:53 -040063- def _call_pkgbin(self, args, env=None):
64+ def _call_pkgbin(self, args, env=None, use_native=False):
Brad Bishop1a4b7ee2018-12-16 17:11:34 -080065 if env is None:
66 fenv = env
Brad Bishop316dfdd2018-06-25 12:45:53 -040067 env = os.environ
Brad Bishop1a4b7ee2018-12-16 17:11:34 -080068@@ -540,7 +543,7 @@ class PkgConfigDependency(ExternalDependency):
69 targs = tuple(args)
70 cache = PkgConfigDependency.pkgbin_cache
71 if (self.pkgbin, targs, fenv) not in cache:
72- cache[(self.pkgbin, targs, fenv)] = self._call_pkgbin_real(args, env)
73+ cache[(self.pkgbin, targs, fenv)] = self._call_pkgbin_real(args, env, use_native)
74 return cache[(self.pkgbin, targs, fenv)]
Brad Bishop316dfdd2018-06-25 12:45:53 -040075
76 def _convert_mingw_paths(self, args):
Brad Bishop1a4b7ee2018-12-16 17:11:34 -080077@@ -718,7 +721,7 @@ class PkgConfigDependency(ExternalDependency):
78 (self.name, out_raw))
79 self.link_args, self.raw_link_args = self._search_libs(out, out_raw)
Brad Bishop316dfdd2018-06-25 12:45:53 -040080
81- def get_pkgconfig_variable(self, variable_name, kwargs):
82+ def get_pkgconfig_variable(self, variable_name, kwargs, use_native=False):
83 options = ['--variable=' + variable_name, self.name]
84
85 if 'define_variable' in kwargs:
Brad Bishop1a4b7ee2018-12-16 17:11:34 -080086@@ -731,7 +734,7 @@ class PkgConfigDependency(ExternalDependency):
Brad Bishop316dfdd2018-06-25 12:45:53 -040087
88 options = ['--define-variable=' + '='.join(definition)] + options
89
90- ret, out = self._call_pkgbin(options)
91+ ret, out = self._call_pkgbin(options, use_native=use_native)
92 variable = ''
93 if ret != 0:
94 if self.required:
95diff --git a/mesonbuild/dependencies/ui.py b/mesonbuild/dependencies/ui.py
Brad Bishop1a4b7ee2018-12-16 17:11:34 -080096index 197d22c..c683d21 100644
Brad Bishop316dfdd2018-06-25 12:45:53 -040097--- a/mesonbuild/dependencies/ui.py
98+++ b/mesonbuild/dependencies/ui.py
Brad Bishop1a4b7ee2018-12-16 17:11:34 -080099@@ -285,7 +285,7 @@ class QtBaseDependency(ExternalDependency):
Brad Bishop316dfdd2018-06-25 12:45:53 -0400100 self.bindir = self.get_pkgconfig_host_bins(core)
101 if not self.bindir:
102 # If exec_prefix is not defined, the pkg-config file is broken
103- prefix = core.get_pkgconfig_variable('exec_prefix', {})
104+ prefix = core.get_pkgconfig_variable('exec_prefix', {}, use_native=True)
105 if prefix:
106 self.bindir = os.path.join(prefix, 'bin')
107
Brad Bishop1a4b7ee2018-12-16 17:11:34 -0800108@@ -427,7 +427,7 @@ class Qt4Dependency(QtBaseDependency):
Brad Bishop316dfdd2018-06-25 12:45:53 -0400109 applications = ['moc', 'uic', 'rcc', 'lupdate', 'lrelease']
110 for application in applications:
111 try:
112- return os.path.dirname(core.get_pkgconfig_variable('%s_location' % application, {}))
113+ return os.path.dirname(core.get_pkgconfig_variable('%s_location' % application, {}, use_native=True))
114 except MesonException:
115 pass
116
Brad Bishop1a4b7ee2018-12-16 17:11:34 -0800117@@ -437,7 +437,7 @@ class Qt5Dependency(QtBaseDependency):
Brad Bishop316dfdd2018-06-25 12:45:53 -0400118 QtBaseDependency.__init__(self, 'qt5', env, kwargs)
119
120 def get_pkgconfig_host_bins(self, core):
121- return core.get_pkgconfig_variable('host_bins', {})
122+ return core.get_pkgconfig_variable('host_bins', {}, use_native=True)
123
Brad Bishop1a4b7ee2018-12-16 17:11:34 -0800124 def get_private_includes(self, mod_inc_dir, module):
125 return _qt_get_private_includes(mod_inc_dir, module, self.version)