aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDylan Baker <dylan@pnwbakers.com>2017-10-19 15:20:41 -0700
committerDylan Baker <dylan@pnwbakers.com>2017-11-23 20:06:23 -0800
commitf818e9df582e27d73a36c0b7a94dc897a6e6dc62 (patch)
treebb92803d6f33266aca794000da77a642e09cbdd7
parentdf3c0064564760315eb69e78b7c298bf26ad1b59 (diff)
downloadmeson-f818e9df582e27d73a36c0b7a94dc897a6e6dc62.zip
meson-f818e9df582e27d73a36c0b7a94dc897a6e6dc62.tar.gz
meson-f818e9df582e27d73a36c0b7a94dc897a6e6dc62.tar.bz2
Add a configtool_variable method to dependency
This mirrors the get_pkgconfig_variable but for config tool based dependencies.
-rw-r--r--mesonbuild/dependencies/base.py14
-rw-r--r--mesonbuild/interpreter.py10
-rw-r--r--test cases/common/165 config tool variable/meson.build31
3 files changed, 55 insertions, 0 deletions
diff --git a/mesonbuild/dependencies/base.py b/mesonbuild/dependencies/base.py
index 84b20e7..682182c 100644
--- a/mesonbuild/dependencies/base.py
+++ b/mesonbuild/dependencies/base.py
@@ -132,6 +132,9 @@ class Dependency:
def get_pkgconfig_variable(self, variable_name):
raise NotImplementedError('{!r} is not a pkgconfig dependency'.format(self.name))
+ def get_configtool_variable(self, variable_name):
+ raise NotImplementedError('{!r} is not a config-tool dependency'.format(self.name))
+
class InternalDependency(Dependency):
def __init__(self, version, incdirs, compile_args, link_args, libraries, sources, ext_deps):
@@ -288,6 +291,17 @@ class ConfigToolDependency(ExternalDependency):
def get_methods(self):
return [DependencyMethods.AUTO, DependencyMethods.CONFIG_TOOL]
+ def get_configtool_variable(self, variable_name):
+ p, out, _ = Popen_safe([self.config, '--{}'.format(variable_name)])
+ if p.returncode != 0:
+ if self.required:
+ raise DependencyException(
+ 'Could not get variable "{}" for dependency {}'.format(
+ variable_name, self.name))
+ variable = out.strip()
+ mlog.debug('Got config-tool variable {} : {}'.format(variable_name, variable))
+ return variable
+
class PkgConfigDependency(ExternalDependency):
# The class's copy of the pkg-config path. Avoids having to search for it
diff --git a/mesonbuild/interpreter.py b/mesonbuild/interpreter.py
index fbf9a21..dd0e0e6 100644
--- a/mesonbuild/interpreter.py
+++ b/mesonbuild/interpreter.py
@@ -274,6 +274,7 @@ class DependencyHolder(InterpreterObject, ObjectHolder):
'type_name': self.type_name_method,
'version': self.version_method,
'get_pkgconfig_variable': self.pkgconfig_method,
+ 'get_configtool_variable': self.configtool_method,
})
def type_name_method(self, args, kwargs):
@@ -296,6 +297,15 @@ class DependencyHolder(InterpreterObject, ObjectHolder):
raise InterpreterException('Variable name must be a string.')
return self.held_object.get_pkgconfig_variable(varname)
+ def configtool_method(self, args, kwargs):
+ args = listify(args)
+ if len(args) != 1:
+ raise InterpreterException('get_configtool_variable takes exactly one argument.')
+ varname = args[0]
+ if not isinstance(varname, str):
+ raise InterpreterException('Variable name must be a string.')
+ return self.held_object.get_configtool_variable(varname)
+
class InternalDependencyHolder(InterpreterObject, ObjectHolder):
def __init__(self, dep):
InterpreterObject.__init__(self)
diff --git a/test cases/common/165 config tool variable/meson.build b/test cases/common/165 config tool variable/meson.build
new file mode 100644
index 0000000..0643042
--- /dev/null
+++ b/test cases/common/165 config tool variable/meson.build
@@ -0,0 +1,31 @@
+# Copyright © 2017 Intel Corporation
+#
+# 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.
+
+project('config tool variable', 'cpp')
+
+
+dep_llvm = dependency('llvm', required : false)
+if not dep_llvm.found()
+ error('MESON_SKIP_TEST LLVM not installed.')
+endif
+
+includedir = dep_llvm.get_configtool_variable('includedir')
+includedir = join_paths(includedir, 'llvm')
+if host_machine.system() == 'windows'
+ cmd = run_command(['dir', includedir])
+else
+ cmd = run_command(['ls', includedir])
+endif
+
+assert(cmd.returncode() == 0, 'did not run successfully')