aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJussi Pakkanen <jpakkane@gmail.com>2017-10-01 22:44:49 +0300
committerJussi Pakkanen <jpakkane@gmail.com>2017-11-27 23:40:19 +0200
commitf19258349d3c40b4f86ba4d9c6fc469d892f8377 (patch)
tree79feb8cd9cf3d6a8767f7461dd27ca891bdff4b2
parent88d29526d2c9dd4d005548db6ea424dd74ccc021 (diff)
downloadmeson-f19258349d3c40b4f86ba4d9c6fc469d892f8377.zip
meson-f19258349d3c40b4f86ba4d9c6fc469d892f8377.tar.gz
meson-f19258349d3c40b4f86ba4d9c6fc469d892f8377.tar.bz2
Moar tests!
-rw-r--r--mesonbuild/coredata.py2
-rw-r--r--mesonbuild/interpreter.py5
-rw-r--r--mesonbuild/interpreterbase.py6
-rw-r--r--test cases/common/161 dolphin option/deplookups/meson.build20
-rw-r--r--test cases/common/161 dolphin option/meson.build4
-rw-r--r--test cases/common/161 dolphin option/meson_options.txt4
6 files changed, 39 insertions, 2 deletions
diff --git a/mesonbuild/coredata.py b/mesonbuild/coredata.py
index b70677b..525c256 100644
--- a/mesonbuild/coredata.py
+++ b/mesonbuild/coredata.py
@@ -126,7 +126,7 @@ class UserComboOption(UserOption):
class UserDolphinOption(UserComboOption):
def __init__(self, name, description, value):
- super().__init__(name, description, ['required', 'auto', 'disabled'], value)
+ super().__init__(name, description, ['required', 'not_required', 'disabled'], value)
class UserStringArrayOption(UserOption):
diff --git a/mesonbuild/interpreter.py b/mesonbuild/interpreter.py
index 86f146f..77bde1c 100644
--- a/mesonbuild/interpreter.py
+++ b/mesonbuild/interpreter.py
@@ -2144,6 +2144,11 @@ to directly access options of other subprojects.''')
return Disabler()
if o.value == 'required':
required = True
+ # Dependency resolution does not need to know about disablers and
+ # all other stuff, so set this manually.
+ if 'options' in kwargs:
+ kwargs['required'] = required
+ del kwargs['options']
name = args[0]
if '<' in name or '>' in name or '=' in name:
raise InvalidArguments('Characters <, > and = are forbidden in dependency names. To specify'
diff --git a/mesonbuild/interpreterbase.py b/mesonbuild/interpreterbase.py
index f8a98aa..afbbe60 100644
--- a/mesonbuild/interpreterbase.py
+++ b/mesonbuild/interpreterbase.py
@@ -432,7 +432,11 @@ class InterpreterBase:
if not isinstance(obj, InterpreterObject):
raise InvalidArguments('Variable "%s" is not callable.' % object_name)
(args, kwargs) = self.reduce_arguments(args)
- if is_disabled(posargs, kwargs):
+ # Special case. This is the only thing you can do with a disabler
+ # object. Every other use immediately returns the disabler object.
+ if isinstance(obj, Disabler) and method_name == 'found':
+ return False
+ if is_disabled(args, kwargs):
return Disabler()
if method_name == 'extract_objects':
self.validate_extraction(obj.held_object)
diff --git a/test cases/common/161 dolphin option/deplookups/meson.build b/test cases/common/161 dolphin option/deplookups/meson.build
new file mode 100644
index 0000000..d57c526
--- /dev/null
+++ b/test cases/common/161 dolphin option/deplookups/meson.build
@@ -0,0 +1,20 @@
+exist_auto = dependency('zlib', options : 'auto_opt')
+exist_req = dependency('zlib', options : 'req_opt')
+exist_disable = dependency('zlib', options : 'dis_opt')
+
+copy_of_exist_disable = exist_disable
+
+not_exist_auto = dependency('nonexist', options : 'auto_opt')
+# This is not valid because it would fail execution.
+# This combination is tested in a failing test.
+#not_exist_req = dependency('nonexist', options : 'req_opt')
+not_exist_disable = dependency('nonexist', options : 'dis_opt')
+
+assert(exist_auto.found(), 'Zlib not found')
+assert(exist_req.found(), 'Zlib not found')
+assert(not exist_disable.found(), 'A disabled dependency claims to be found.')
+assert(not copy_of_exist_disable.found(), 'A copied disabled dependency works incorrectly.')
+
+assert(not not_exist_auto.found(), 'Nonexisting dependency was found.')
+assert(not not_exist_disable.found(), 'Nonexisting dependency was found.')
+
diff --git a/test cases/common/161 dolphin option/meson.build b/test cases/common/161 dolphin option/meson.build
index c963710..40cd4d5 100644
--- a/test cases/common/161 dolphin option/meson.build
+++ b/test cases/common/161 dolphin option/meson.build
@@ -13,3 +13,7 @@ gs = custom_target('somec',
)
test('Generated test', executable('proggie', gs))
+
+if not meson.is_cross_build() and find_program('pkg-config', required:false).found()
+ subdir('deplookups')
+endif
diff --git a/test cases/common/161 dolphin option/meson_options.txt b/test cases/common/161 dolphin option/meson_options.txt
index 55076b4..c09eba6 100644
--- a/test cases/common/161 dolphin option/meson_options.txt
+++ b/test cases/common/161 dolphin option/meson_options.txt
@@ -1,2 +1,6 @@
option('video', type : 'dolphin')
option('patented', type : 'dolphin', value : 'disabled')
+
+option('req_opt', type : 'dolphin', value : 'required')
+option('auto_opt', type : 'dolphin', value : 'not_required')
+option('dis_opt', type : 'dolphin', value : 'disabled')