diff options
author | Jon Turney <jon.turney@dronecode.org.uk> | 2018-05-19 13:36:04 +0100 |
---|---|---|
committer | Nirbheek Chauhan <nirbheek.chauhan@gmail.com> | 2018-06-03 21:06:23 +0000 |
commit | 7e08e958c0e3cdf7e6769027d8eeff5925b69d73 (patch) | |
tree | 38ca4d11be72f46402a0815fff12fa73174cb49e /mesonbuild | |
parent | 50aabc01293afc4778a7c881ffa0c3a531c39dbe (diff) | |
download | meson-7e08e958c0e3cdf7e6769027d8eeff5925b69d73.zip meson-7e08e958c0e3cdf7e6769027d8eeff5925b69d73.tar.gz meson-7e08e958c0e3cdf7e6769027d8eeff5925b69d73.tar.bz2 |
Allow substitutions in custom_target() depfile:
Allow substitutions in custom_target() depfile: as well as in command:
Diffstat (limited to 'mesonbuild')
-rw-r--r-- | mesonbuild/backend/ninjabackend.py | 3 | ||||
-rw-r--r-- | mesonbuild/build.py | 12 | ||||
-rw-r--r-- | mesonbuild/interpreter.py | 2 |
3 files changed, 16 insertions, 1 deletions
diff --git a/mesonbuild/backend/ninjabackend.py b/mesonbuild/backend/ninjabackend.py index e9892b4..b327338 100644 --- a/mesonbuild/backend/ninjabackend.py +++ b/mesonbuild/backend/ninjabackend.py @@ -546,7 +546,8 @@ int dummy; else: cmd_type = 'custom' if target.depfile is not None: - rel_dfile = os.path.join(self.get_target_dir(target), target.depfile) + depfile = target.get_dep_outname(elem.infilenames) + rel_dfile = os.path.join(self.get_target_dir(target), depfile) abs_pdir = os.path.join(self.environment.get_build_dir(), self.get_target_dir(target)) os.makedirs(abs_pdir, exist_ok=True) elem.add_item('DEPFILE', rel_dfile) diff --git a/mesonbuild/build.py b/mesonbuild/build.py index 1e7f5fe..c5e50da 100644 --- a/mesonbuild/build.py +++ b/mesonbuild/build.py @@ -1835,6 +1835,18 @@ class CustomTarget(Target): def get_generated_sources(self): return self.get_generated_lists() + def get_dep_outname(self, infilenames): + if self.depfile is None: + raise InvalidArguments('Tried to get depfile name for custom_target that does not have depfile defined.') + if len(infilenames): + plainname = os.path.basename(infilenames[0]) + basename = os.path.splitext(plainname)[0] + return self.depfile.replace('@BASENAME@', basename).replace('@PLAINNAME@', plainname) + else: + if '@BASENAME@' in self.depfile or '@PLAINNAME@' in self.depfile: + raise InvalidArguments('Substitution in depfile for custom_target that does not have an input file.') + return self.depfile + def type_suffix(self): return "@cus" diff --git a/mesonbuild/interpreter.py b/mesonbuild/interpreter.py index b596ddc..564558e 100644 --- a/mesonbuild/interpreter.py +++ b/mesonbuild/interpreter.py @@ -2939,6 +2939,8 @@ root and issuing %s. def func_custom_target(self, node, args, kwargs): if len(args) != 1: raise InterpreterException('custom_target: Only one positional argument is allowed, and it must be a string name') + if 'depfile' in kwargs and ('@BASENAME@' in kwargs['depfile'] or '@PLAINNAME@' in kwargs['depfile']): + FeatureNew('substitutions in custom_target depfile', '0.47.0').use() name = args[0] kwargs['install_mode'] = self._get_kwarg_install_mode(kwargs) tg = CustomTargetHolder(build.CustomTarget(name, self.subdir, self.subproject, kwargs), self) |