diff options
author | Martin Kelly <mkelly@xevo.com> | 2017-09-06 15:21:50 -0700 |
---|---|---|
committer | Jussi Pakkanen <jpakkane@gmail.com> | 2017-10-31 01:04:38 +0200 |
commit | 02bea7d5bf5c98c586e59e60357fc5ca11826172 (patch) | |
tree | 45657b5848ce1a30ff30451dc360e3ba3f39ee0a /mesonbuild/build.py | |
parent | 68af8449d8576e27fb0390340f149f3001e8ea5f (diff) | |
download | meson-02bea7d5bf5c98c586e59e60357fc5ca11826172.zip meson-02bea7d5bf5c98c586e59e60357fc5ca11826172.tar.gz meson-02bea7d5bf5c98c586e59e60357fc5ca11826172.tar.bz2 |
namespace run_targets by subproject
Currently, run_target does not get namespaced for each subproject,
unlike executable and others. This means that two subprojects sharing
the same run_target name cause meson to crash.
Fix this by moving the subproject namespacing logic from the BuildTarget
class to the Target class.
Diffstat (limited to 'mesonbuild/build.py')
-rw-r--r-- | mesonbuild/build.py | 35 |
1 files changed, 16 insertions, 19 deletions
diff --git a/mesonbuild/build.py b/mesonbuild/build.py index 2840f29..12f4bdb 100644 --- a/mesonbuild/build.py +++ b/mesonbuild/build.py @@ -279,7 +279,7 @@ class EnvironmentVariables: return env class Target: - def __init__(self, name, subdir, build_by_default): + def __init__(self, name, subdir, subproject, build_by_default): if '/' in name or '\\' in name: # Fix failing test 53 when this becomes an error. mlog.warning('''Target "%s" has a path separator in its name. @@ -287,6 +287,7 @@ This is not supported, it can cause unexpected failures and will become a hard error in the future.''' % name) self.name = name self.subdir = subdir + self.subproject = subproject self.build_by_default = build_by_default self.install = False self.build_always = False @@ -298,6 +299,15 @@ a hard error in the future.''' % name) def get_subdir(self): return self.subdir + def get_id(self): + # This ID must also be a valid file name on all OSs. + # It should also avoid shell metacharacters for obvious + # reasons. + base = self.name + self.type_suffix() + if self.subproject == '': + return base + return self.subproject + '@@' + base + def process_kwargs(self, kwargs): if 'build_by_default' in kwargs: self.build_by_default = kwargs['build_by_default'] @@ -320,8 +330,7 @@ a hard error in the future.''' % name) class BuildTarget(Target): def __init__(self, name, subdir, subproject, is_cross, sources, objects, environment, kwargs): - super().__init__(name, subdir, True) - self.subproject = subproject # Can not be calculated from subdir as subproject dirname can be changed per project. + super().__init__(name, subdir, subproject, True) self.is_cross = is_cross unity_opt = environment.coredata.get_builtin_option('unity') self.is_unity = unity_opt == 'on' or (unity_opt == 'subprojects' and subproject != '') @@ -374,15 +383,6 @@ class BuildTarget(Target): if environment.is_cross_build() and not self.is_cross and self.install: raise InvalidArguments('Tried to install a natively built target in a cross build.') - def get_id(self): - # This ID must also be a valid file name on all OSs. - # It should also avoid shell metacharacters for obvious - # reasons. - base = self.name + self.type_suffix() - if self.subproject == '': - return base - return self.subproject + '@@' + base - def check_unknown_kwargs(self, kwargs): # Override this method in derived classes that have more # keywords. @@ -1511,8 +1511,8 @@ class CustomTarget(Target): 'override_options': True, } - def __init__(self, name, subdir, kwargs, absolute_paths=False): - super().__init__(name, subdir, False) + def __init__(self, name, subdir, subproject, kwargs, absolute_paths=False): + super().__init__(name, subdir, subproject, False) self.dependencies = [] self.extra_depends = [] self.depend_files = [] # Files that this target depends on but are not on the command line. @@ -1689,8 +1689,8 @@ class CustomTarget(Target): raise NotImplementedError class RunTarget(Target): - def __init__(self, name, command, args, dependencies, subdir): - super().__init__(name, subdir, False) + def __init__(self, name, command, args, dependencies, subdir, subproject): + super().__init__(name, subdir, subproject, False) self.command = command self.args = args self.dependencies = dependencies @@ -1702,9 +1702,6 @@ class RunTarget(Target): repr_str = "<{0} {1}: {2}>" return repr_str.format(self.__class__.__name__, self.get_id(), self.command) - def get_id(self): - return self.name + self.type_suffix() - def get_dependencies(self): return self.dependencies |