aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDaniel Mensinger <daniel@mensinger-ka.de>2019-09-29 21:27:05 +0200
committerDaniel Mensinger <daniel@mensinger-ka.de>2019-10-03 10:06:04 +0200
commit73d52266b5cf8e6b62d715328f0c66b1734c3026 (patch)
treeb8e0b6cbc1d9c378c802c235fdbb2713cbee7a7c
parente5c720ff607cdf3101de031ff3a36f434d77b0d1 (diff)
downloadmeson-73d52266b5cf8e6b62d715328f0c66b1734c3026.zip
meson-73d52266b5cf8e6b62d715328f0c66b1734c3026.tar.gz
meson-73d52266b5cf8e6b62d715328f0c66b1734c3026.tar.bz2
Use include_type instead of is_system
-rw-r--r--docs/markdown/Reference-manual.md17
-rw-r--r--docs/markdown/snippets/force_system.md11
-rw-r--r--docs/markdown/snippets/is_system.md9
-rw-r--r--mesonbuild/build.py11
-rw-r--r--mesonbuild/dependencies/base.py52
-rw-r--r--mesonbuild/interpreter.py16
-rw-r--r--test cases/common/157 wrap file should not failed/subprojects/foo-1.0/foo.c3
-rw-r--r--test cases/common/157 wrap file should not failed/subprojects/foo-1.0/meson.build2
-rw-r--r--test cases/common/226 include_type dependency/meson.build27
-rw-r--r--test cases/common/226 include_type dependency/subprojects/subDep/meson.build (renamed from test cases/common/226 is_system dependency/subprojects/subDep/meson.build)0
-rw-r--r--test cases/common/226 is_system dependency/meson.build27
11 files changed, 96 insertions, 79 deletions
diff --git a/docs/markdown/Reference-manual.md b/docs/markdown/Reference-manual.md
index 25c803d..c50a611 100644
--- a/docs/markdown/Reference-manual.md
+++ b/docs/markdown/Reference-manual.md
@@ -461,10 +461,12 @@ arguments:
You can also specify multiple restrictions by passing a list to this
keyword argument, such as: `['>=3.14.0', '<=4.1.0']`.
These requirements are never met if the version is unknown.
-- `is_system` *(added 0.52.0)* is a boolean flag, marking the dependency
- as a system dependency. System dependencies may be handled differently
- on some platforms, for instance using `-isystem` instead of `-I`, where
- possible. The default value is `false`.
+- `include_type` *(added 0.52.0)* is an enum flag, marking how the dependency
+ flags should be converted. Supported values are `'preserve'`, `'system'` and
+ `'non-system'`. System dependencies may be handled differently on some
+ platforms, for instance, using `-isystem` instead of `-I`, where possible.
+ If `include_type` is set to `'preserve'`, no additional conversion will be
+ performed. The default value is `'preserve'`.
- other
[library-specific](Dependencies.md#dependencies-with-custom-lookup-functionality)
keywords may also be accepted (e.g. `modules` specifies submodules to use for
@@ -2228,12 +2230,11 @@ an external dependency with the following methods:
`unknown` if the dependency provider doesn't support determining the
version.
- - `is_system()` returns whether the dependency object was marked as a
- system dependency
+ - `include_type()` returns whether the value set by the `include_type` kwarg
- `as_system(value)` returns a copy of the dependency object, which has changed
- the value of `is_system` to `value`. The `value` argument is optional and
- defaults to `true`.
+ the value of `include_type` to `value`. The `value` argument is optional and
+ defaults to `'preserve'`.
- `partial_dependency(compile_args : false, link_args : false, links
: false, includes : false, source : false)` *(Added 0.46.0)* returns
diff --git a/docs/markdown/snippets/force_system.md b/docs/markdown/snippets/force_system.md
new file mode 100644
index 0000000..fd983e0
--- /dev/null
+++ b/docs/markdown/snippets/force_system.md
@@ -0,0 +1,11 @@
+## Added `include_type` kwarg to `dependency`
+
+The `dependency()` function now has a `include_type` kwarg. It can take the
+values `'preserve'`, `'system'` and `'non-system'`. If it is set to `'system'`,
+all include directories of the dependency are marked as system dependencies.
+
+The default value of `include_type` is `'preserve'`.
+
+Additionally, it is also possible to check and change the `include_type`
+state of an existing dependency object with the new `include_type()` and
+`as_system()` methods.
diff --git a/docs/markdown/snippets/is_system.md b/docs/markdown/snippets/is_system.md
deleted file mode 100644
index cb1da0a..0000000
--- a/docs/markdown/snippets/is_system.md
+++ /dev/null
@@ -1,9 +0,0 @@
-## Added `is_system` kwarg to `dependency`
-
-Similar to `include_directories()`, the `dependency()` function now
-also has a `is_system` kwarg. If it is enabled, all include directories
-of the dependency are marked as system dependencies.
-
-Additionally, it is also possible to check and change the `is_system`
-state of an existing dependency object with the new `is_system()` and
-`as_system()` methods.
diff --git a/mesonbuild/build.py b/mesonbuild/build.py
index e9b2a4a..267bd16 100644
--- a/mesonbuild/build.py
+++ b/mesonbuild/build.py
@@ -1024,7 +1024,7 @@ This will become a hard error in a future Meson release.''')
if isinstance(dep, dependencies.InternalDependency):
# Those parts that are internal.
self.process_sourcelist(dep.sources)
- self.add_include_dirs(dep.include_directories)
+ self.add_include_dirs(dep.include_directories, dep.get_include_type())
for l in dep.libraries:
self.link(l)
for l in dep.whole_libraries:
@@ -1150,7 +1150,7 @@ You probably should put it in link_with instead.''')
raise MesonException('File %s does not exist.' % f)
self.pch[language] = pchlist
- def add_include_dirs(self, args, set_is_system: typing.Optional[bool] = None):
+ def add_include_dirs(self, args, set_is_system: typing.Optional[str] = None):
ids = []
for a in args:
# FIXME same hack, forcibly unpack from holder.
@@ -1159,8 +1159,11 @@ You probably should put it in link_with instead.''')
if not isinstance(a, IncludeDirs):
raise InvalidArguments('Include directory to be added is not an include directory object.')
ids.append(a)
- if set_is_system is not None:
- ids = [IncludeDirs(x.get_curdir(), x.get_incdirs(), set_is_system, x.get_extra_build_dirs()) for x in ids]
+ if set_is_system is None:
+ set_is_system = 'preserve'
+ if set_is_system != 'preserve':
+ is_system = set_is_system == 'system'
+ ids = [IncludeDirs(x.get_curdir(), x.get_incdirs(), is_system, x.get_extra_build_dirs()) for x in ids]
self.include_dirs += ids
def add_compiler_args(self, language, args):
diff --git a/mesonbuild/dependencies/base.py b/mesonbuild/dependencies/base.py
index 1ccc343..3c55a56 100644
--- a/mesonbuild/dependencies/base.py
+++ b/mesonbuild/dependencies/base.py
@@ -105,12 +105,14 @@ class Dependency:
return methods
@classmethod
- def _process_is_system_kw(cls, kwargs):
- if 'is_system' not in kwargs:
- return False
- if not isinstance(kwargs['is_system'], bool):
- raise DependencyException('The is_system kwarg must be a boolean type')
- return kwargs['is_system']
+ def _process_include_type_kw(cls, kwargs) -> str:
+ if 'include_type' not in kwargs:
+ return 'preserve'
+ if not isinstance(kwargs['include_type'], str):
+ raise DependencyException('The include_type kwarg must be a string type')
+ if kwargs['include_type'] not in ['preserve', 'system', 'non-system']:
+ raise DependencyException("include_type may only be one of ['preserve', 'system', 'non-system']")
+ return kwargs['include_type']
def __init__(self, type_name, kwargs):
self.name = "null"
@@ -125,7 +127,7 @@ class Dependency:
self.raw_link_args = None
self.sources = []
self.methods = self._process_method_kw(kwargs)
- self.is_system = self._process_is_system_kw(kwargs)
+ self.include_type = self._process_include_type_kw(kwargs)
self.ext_deps = [] # type: List[Dependency]
def __repr__(self):
@@ -133,17 +135,23 @@ class Dependency:
return s.format(self.__class__.__name__, self.name, self.is_found)
def get_compile_args(self):
- if not self.is_system:
- return self.compile_args
-
- system_args = []
- for i in self.compile_args:
- if i.startswith('-I') or i.startswith('/I'):
- system_args += ['-isystem' + i[2:]]
- else:
- system_args += [i]
-
- return system_args
+ if self.include_type == 'system':
+ converted = []
+ for i in self.compile_args:
+ if i.startswith('-I') or i.startswith('/I'):
+ converted += ['-isystem' + i[2:]]
+ else:
+ converted += [i]
+ return converted
+ if self.include_type == 'non-system':
+ converted = []
+ for i in self.compile_args:
+ if i.startswith('-isystem'):
+ converted += ['-I' + i[8:]]
+ else:
+ converted += [i]
+ return converted
+ return self.compile_args
def get_link_args(self, raw=False):
if raw and self.raw_link_args is not None:
@@ -171,8 +179,8 @@ class Dependency:
else:
return 'unknown'
- def get_is_system(self) -> bool:
- return self.is_system
+ def get_include_type(self) -> str:
+ return self.include_type
def get_exe_args(self, compiler):
return []
@@ -222,9 +230,9 @@ class Dependency:
return default_value
raise DependencyException('No default provided for dependency {!r}, which is not pkg-config, cmake, or config-tool based.'.format(self))
- def generate_system_dependency(self, is_system: bool) -> typing.Type['Dependency']:
+ def generate_system_dependency(self, include_type: str) -> typing.Type['Dependency']:
new_dep = copy.deepcopy(self)
- new_dep.is_system = is_system
+ new_dep.include_type = self._process_include_type_kw({'include_type': include_type})
return new_dep
class InternalDependency(Dependency):
diff --git a/mesonbuild/interpreter.py b/mesonbuild/interpreter.py
index eb0eaf7..eae5a16 100644
--- a/mesonbuild/interpreter.py
+++ b/mesonbuild/interpreter.py
@@ -412,7 +412,7 @@ class DependencyHolder(InterpreterObject, ObjectHolder):
'get_configtool_variable': self.configtool_method,
'get_variable': self.variable_method,
'partial_dependency': self.partial_dependency_method,
- 'is_system': self.is_system_method,
+ 'include_type': self.include_type_method,
'as_system': self.as_system_method,
})
@@ -475,22 +475,20 @@ class DependencyHolder(InterpreterObject, ObjectHolder):
def variable_method(self, args, kwargs):
return self.held_object.get_variable(**kwargs)
- @FeatureNew('dep.is_system', '0.52.0')
+ @FeatureNew('dep.include_type', '0.52.0')
@noPosargs
@permittedKwargs({})
- def is_system_method(self, args, kwargs):
- return self.held_object.get_is_system()
+ def include_type_method(self, args, kwargs):
+ return self.held_object.get_include_type()
@FeatureNew('dep.as_system', '0.52.0')
@permittedKwargs({})
def as_system_method(self, args, kwargs):
args = listify(args)
- new_is_system = True
+ new_is_system = 'system'
if len(args) > 1:
raise InterpreterException('as_system takes only one optional value')
if len(args) == 1:
- if not isinstance(args[0], bool):
- raise InterpreterException('as_system takes only a boolean value')
new_is_system = args[0]
new_dep = self.held_object.generate_system_dependency(new_is_system)
return DependencyHolder(new_dep, self.subproject)
@@ -2019,7 +2017,7 @@ permitted_kwargs = {'add_global_arguments': {'language', 'native'},
'version',
'private_headers',
'cmake_args',
- 'is_system',
+ 'include_type',
},
'declare_dependency': {'include_directories',
'link_with',
@@ -3071,7 +3069,7 @@ external dependencies (including libraries) must go to "dependencies".''')
elif name == 'openmp':
FeatureNew('OpenMP Dependency', '0.46.0').use(self.subproject)
- @FeatureNewKwargs('dependency', '0.52.0', ['is_system'])
+ @FeatureNewKwargs('dependency', '0.52.0', ['include_type'])
@FeatureNewKwargs('dependency', '0.50.0', ['not_found_message', 'cmake_module_path', 'cmake_args'])
@FeatureNewKwargs('dependency', '0.49.0', ['disabler'])
@FeatureNewKwargs('dependency', '0.40.0', ['method'])
diff --git a/test cases/common/157 wrap file should not failed/subprojects/foo-1.0/foo.c b/test cases/common/157 wrap file should not failed/subprojects/foo-1.0/foo.c
new file mode 100644
index 0000000..019f2ba
--- /dev/null
+++ b/test cases/common/157 wrap file should not failed/subprojects/foo-1.0/foo.c
@@ -0,0 +1,3 @@
+int dummy_func() {
+ return 42;
+}
diff --git a/test cases/common/157 wrap file should not failed/subprojects/foo-1.0/meson.build b/test cases/common/157 wrap file should not failed/subprojects/foo-1.0/meson.build
new file mode 100644
index 0000000..318e81d
--- /dev/null
+++ b/test cases/common/157 wrap file should not failed/subprojects/foo-1.0/meson.build
@@ -0,0 +1,2 @@
+project('shared lib', 'c')
+libfoo = shared_library('foo', 'foo.c')
diff --git a/test cases/common/226 include_type dependency/meson.build b/test cases/common/226 include_type dependency/meson.build
new file mode 100644
index 0000000..eaac820
--- /dev/null
+++ b/test cases/common/226 include_type dependency/meson.build
@@ -0,0 +1,27 @@
+project(
+ 'dependency include_type',
+ ['c', 'cpp'],
+)
+
+dep = dependency('zlib', method: 'pkg-config', required : false)
+if not dep.found()
+ error('MESON_SKIP_TEST zlib was not found')
+endif
+
+assert(dep.include_type() == 'preserve', 'include_type must default to "preserve"')
+
+dep_sys = dep.as_system()
+assert(dep_sys.include_type() == 'system', 'as_system must return a system dep')
+
+dep2 = dependency('zlib', method: 'pkg-config', include_type : 'system')
+assert(dep2.include_type() == 'system', 'include_type must be true when set')
+
+dep2_sys = dep2.as_system('non-system')
+assert(dep2_sys.include_type() == 'non-system', 'as_system must set include_type correctly')
+
+sp = subproject('subDep')
+sp_dep = sp.get_variable('subDep_dep')
+assert(sp_dep.include_type() == 'preserve', 'default is preserve')
+
+sp_dep_sys = sp_dep.as_system('system')
+assert(sp_dep_sys.include_type() == 'system', 'changing include_type works')
diff --git a/test cases/common/226 is_system dependency/subprojects/subDep/meson.build b/test cases/common/226 include_type dependency/subprojects/subDep/meson.build
index c3e87c4..c3e87c4 100644
--- a/test cases/common/226 is_system dependency/subprojects/subDep/meson.build
+++ b/test cases/common/226 include_type dependency/subprojects/subDep/meson.build
diff --git a/test cases/common/226 is_system dependency/meson.build b/test cases/common/226 is_system dependency/meson.build
deleted file mode 100644
index a3f60d2..0000000
--- a/test cases/common/226 is_system dependency/meson.build
+++ /dev/null
@@ -1,27 +0,0 @@
-project(
- 'dependency is_system',
- ['c', 'cpp'],
-)
-
-dep = dependency('zlib', method: 'pkg-config', required : false)
-if not dep.found()
- error('MESON_SKIP_TEST zlib was not found')
-endif
-
-assert(dep.is_system() == false, 'is_system must default to false')
-
-dep_sys = dep.as_system()
-assert(dep_sys.is_system() == true, 'as_system must default to true')
-
-dep2 = dependency('zlib', method: 'pkg-config', is_system : true)
-assert(dep2.is_system() == true, 'is_system must be true when set')
-
-dep2_sys = dep2.as_system(false)
-assert(dep2_sys.is_system() == false, 'as_system must set is_system correctly')
-
-sp = subproject('subDep')
-sp_dep = sp.get_variable('subDep_dep')
-assert(sp_dep.is_system() == false, 'default is false')
-
-sp_dep_sys = sp_dep.as_system(true)
-assert(sp_dep_sys.is_system() == true, 'changing is_system works')