aboutsummaryrefslogtreecommitdiff
path: root/mesonbuild/build.py
diff options
context:
space:
mode:
authorJohn Ericson <git@JohnEricson.me>2020-08-03 11:48:27 -0400
committerJohn Ericson <git@JohnEricson.me>2020-08-03 11:48:27 -0400
commiteaf6343c065842b9719793066e765b2e5f1c2f3b (patch)
tree1bfeac5297ba489721e704e63c28f33d0fb98990 /mesonbuild/build.py
parent87aa98c1787d800145853a8e84654e4c54ee1078 (diff)
parent70edf82c6c77902cd64f44848302bbac92d611d8 (diff)
downloadmeson-lang-enum.zip
meson-lang-enum.tar.gz
meson-lang-enum.tar.bz2
Merge remote-tracking branch 'upstream/master' into lang-enumlang-enum
Diffstat (limited to 'mesonbuild/build.py')
-rw-r--r--mesonbuild/build.py57
1 files changed, 32 insertions, 25 deletions
diff --git a/mesonbuild/build.py b/mesonbuild/build.py
index ddecb6e..e3b67de 100644
--- a/mesonbuild/build.py
+++ b/mesonbuild/build.py
@@ -12,12 +12,14 @@
# See the License for the specific language governing permissions and
# limitations under the License.
-import copy, os, re
from collections import OrderedDict, defaultdict
-import itertools, pathlib
+from functools import lru_cache
+import copy
import hashlib
+import itertools, pathlib
+import os
import pickle
-from functools import lru_cache
+import re
import typing as T
from . import environment
@@ -82,6 +84,7 @@ buildtarget_kwargs = set([
'override_options',
'sources',
'gnu_symbol_visibility',
+ 'link_language',
])
known_build_target_kwargs = (
@@ -92,7 +95,7 @@ known_build_target_kwargs = (
rust_kwargs |
cs_kwargs)
-known_exe_kwargs = known_build_target_kwargs | {'implib', 'export_dynamic', 'link_language', 'pie'}
+known_exe_kwargs = known_build_target_kwargs | {'implib', 'export_dynamic', 'pie'}
known_shlib_kwargs = known_build_target_kwargs | {'version', 'soversion', 'vs_module_defs', 'darwin_versions'}
known_shmod_kwargs = known_build_target_kwargs | {'vs_module_defs'}
known_stlib_kwargs = known_build_target_kwargs | {'pic'}
@@ -495,6 +498,7 @@ class BuildTarget(Target):
self.link_targets = []
self.link_whole_targets = []
self.link_depends = []
+ self.added_deps = set()
self.name_prefix_set = False
self.name_suffix_set = False
self.filename = 'no_name'
@@ -509,6 +513,8 @@ class BuildTarget(Target):
self.d_features = {}
self.pic = False
self.pie = False
+ # Track build_rpath entries so we can remove them at install time
+ self.rpath_dirs_to_remove = set()
# Sources can be:
# 1. Pre-existing source files in the source tree
# 2. Pre-existing sources generated by configure_file in the build tree
@@ -532,6 +538,9 @@ class BuildTarget(Target):
repr_str = "<{0} {1}: {2}>"
return repr_str.format(self.__class__.__name__, self.get_id(), self.filename)
+ def __str__(self):
+ return "{}".format(self.name)
+
def validate_install(self, environment):
if self.for_machine is MachineChoice.BUILD and self.need_install:
if environment.is_cross_build():
@@ -729,7 +738,7 @@ class BuildTarget(Target):
File.from_source_file(environment.source_dir, self.subdir, s))
elif hasattr(s, 'get_outputs'):
self.link_depends.extend(
- [File.from_built_file(s.subdir, p) for p in s.get_outputs()])
+ [File.from_built_file(s.get_subdir(), p) for p in s.get_outputs()])
else:
raise InvalidArguments(
'Link_depends arguments must be strings, Files, '
@@ -772,7 +781,7 @@ class BuildTarget(Target):
if isinstance(src, str):
src = File(False, self.subdir, src)
elif isinstance(src, File):
- FeatureNew('File argument for extract_objects', '0.50.0').use(self.subproject)
+ FeatureNew.single_use('File argument for extract_objects', '0.50.0', self.subproject)
else:
raise MesonException('Object extraction arguments must be strings or Files.')
# FIXME: It could be a generated source
@@ -813,7 +822,8 @@ class BuildTarget(Target):
def get_link_dep_subdirs(self):
result = OrderedSet()
for i in self.link_targets:
- result.add(i.get_subdir())
+ if not isinstance(i, StaticLibrary):
+ result.add(i.get_subdir())
result.update(i.get_link_dep_subdirs())
return result
@@ -1012,23 +1022,16 @@ This will become a hard error in a future Meson release.''')
def get_extra_args(self, language):
return self.extra_args.get(language, [])
- def get_dependencies(self, exclude=None, for_pkgconfig=False):
+ def get_dependencies(self, exclude=None):
transitive_deps = []
if exclude is None:
exclude = []
for t in itertools.chain(self.link_targets, self.link_whole_targets):
if t in transitive_deps or t in exclude:
continue
- # When generating `Libs:` and `Libs.private:` lists in pkg-config
- # files we don't want to include static libraries that we link_whole
- # or are uninstalled (they're implicitly promoted to link_whole).
- # But we still need to include their transitive dependencies,
- # a static library we link_whole would itself link to a shared
- # library or an installed static library.
- if not for_pkgconfig or (not t.is_internal() and t not in self.link_whole_targets):
- transitive_deps.append(t)
+ transitive_deps.append(t)
if isinstance(t, StaticLibrary):
- transitive_deps += t.get_dependencies(transitive_deps + exclude, for_pkgconfig)
+ transitive_deps += t.get_dependencies(transitive_deps + exclude)
return transitive_deps
def get_source_subdir(self):
@@ -1061,6 +1064,8 @@ This will become a hard error in a future Meson release.''')
def add_deps(self, deps):
deps = listify(deps)
for dep in unholder(deps):
+ if dep in self.added_deps:
+ continue
if isinstance(dep, dependencies.InternalDependency):
# Those parts that are internal.
self.process_sourcelist(dep.sources)
@@ -1099,6 +1104,7 @@ You probably should put it in link_with instead.''')
'either an external dependency (returned by find_library() or '
'dependency()) or an internal dependency (returned by '
'declare_dependency()).'.format(type(dep).__name__))
+ self.added_deps.add(dep)
def get_external_deps(self):
return self.external_deps
@@ -1115,7 +1121,7 @@ You probably should put it in link_with instead.''')
if not isinstance(t, (Target, CustomTargetIndex)):
raise InvalidArguments('{!r} is not a target.'.format(t))
if not t.is_linkable_target():
- raise InvalidArguments('Link target {!r} is not linkable.'.format(t))
+ raise InvalidArguments("Link target '{!s}' is not linkable.".format(t))
if isinstance(self, SharedLibrary) and isinstance(t, StaticLibrary) and not t.pic:
msg = "Can't link non-PIC static library {!r} into shared library {!r}. ".format(t.name, self.name)
msg += "Use the 'pic' option to static_library to build with PIC."
@@ -1228,11 +1234,7 @@ You probably should put it in link_with instead.''')
See: https://github.com/mesonbuild/meson/issues/1653
'''
- langs = []
-
- # User specified link_language of target (for multi-language targets)
- if self.link_language:
- return [self.link_language]
+ langs = [] # type: T.List[str]
# Check if any of the external libraries were written in this language
for dep in self.external_deps:
@@ -1264,6 +1266,12 @@ You probably should put it in link_with instead.''')
# Populate list of all compilers, not just those being used to compile
# sources in this target
all_compilers = self.environment.coredata.compilers[self.for_machine]
+
+ # If the user set the link_language, just return that.
+ if self.link_language:
+ comp = all_compilers[self.link_language]
+ return comp, comp.language_stdlib_only_link_flags()
+
# Languages used by dependencies
dep_langs = self.get_langs_used_by_deps()
# Pick a compiler based on the language priority-order
@@ -2159,7 +2167,7 @@ class CustomTarget(Target):
'when installing a target')
if isinstance(kwargs['install_dir'], list):
- FeatureNew('multiple install_dir for custom_target', '0.40.0').use(self.subproject)
+ FeatureNew.single_use('multiple install_dir for custom_target', '0.40.0', self.subproject)
# If an item in this list is False, the output corresponding to
# the list index of that item will not be installed
self.install_dir = typeslistify(kwargs['install_dir'], (str, bool))
@@ -2171,7 +2179,6 @@ class CustomTarget(Target):
if 'build_always' in kwargs and 'build_always_stale' in kwargs:
raise InvalidArguments('build_always and build_always_stale are mutually exclusive. Combine build_by_default and build_always_stale.')
elif 'build_always' in kwargs:
- mlog.deprecation('build_always is deprecated. Combine build_by_default and build_always_stale instead.')
if 'build_by_default' not in kwargs:
self.build_by_default = kwargs['build_always']
self.build_always_stale = kwargs['build_always']