aboutsummaryrefslogtreecommitdiff
path: root/mesonbuild
diff options
context:
space:
mode:
authorNirbheek Chauhan <nirbheek@centricular.com>2016-11-08 18:55:15 +0530
committerJussi Pakkanen <jpakkane@gmail.com>2016-11-09 11:30:09 -0500
commit5fdac48250c0e4a7ad6e9b92041ab7b4d1bd02ec (patch)
tree5fe297ef6c3c52cbeeb28fac43786d2a4d5126db /mesonbuild
parent4d8e3be08f5d6a426f64fb6a1f71c9f52b249311 (diff)
downloadmeson-5fdac48250c0e4a7ad6e9b92041ab7b4d1bd02ec.zip
meson-5fdac48250c0e4a7ad6e9b92041ab7b4d1bd02ec.tar.gz
meson-5fdac48250c0e4a7ad6e9b92041ab7b4d1bd02ec.tar.bz2
custom_target: Substitute @OUTPUT@ and @INPUT properly
They weren't being substituted if they were a part of a command argument, ala --output=@OUTPUT@, etc. Closes https://github.com/mesonbuild/meson/issues/824
Diffstat (limited to 'mesonbuild')
-rw-r--r--mesonbuild/backend/backends.py69
1 files changed, 43 insertions, 26 deletions
diff --git a/mesonbuild/backend/backends.py b/mesonbuild/backend/backends.py
index bd75fdb..5cc2442 100644
--- a/mesonbuild/backend/backends.py
+++ b/mesonbuild/backend/backends.py
@@ -572,32 +572,49 @@ class Backend():
i = i.replace('@INPUT%d@' % j, src)
for (j, res) in enumerate(ofilenames):
i = i.replace('@OUTPUT%d@' % j, res)
- if i == '@INPUT@':
- cmd += srcs
- elif i == '@OUTPUT@':
- cmd += ofilenames
- else:
- if '@OUTDIR@' in i:
- i = i.replace('@OUTDIR@', outdir)
- elif '@DEPFILE@' in i:
- if target.depfile is None:
- raise MesonException('Custom target %s has @DEPFILE@ but no depfile keyword argument.' % target.name)
- if absolute_paths:
- dfilename = os.path.join(self.get_target_private_dir_abs(target), target.depfile)
- else:
- dfilename = os.path.join(self.get_target_private_dir(target), target.depfile)
- i = i.replace('@DEPFILE@', dfilename)
- elif '@PRIVATE_OUTDIR_' in i:
- match = re.search('@PRIVATE_OUTDIR_(ABS_)?([-a-zA-Z0-9.@:]*)@', i)
- source = match.group(0)
- if match.group(1) is None and not absolute_paths:
- lead_dir = ''
- else:
- lead_dir = self.environment.get_build_dir()
- i = i.replace(source,
- os.path.join(lead_dir,
- outdir))
- cmd.append(i)
+ if '@INPUT@' in i:
+ msg = 'Custom target {} has @INPUT@ in the command, but'.format(target.name)
+ if len(srcs) == 0:
+ raise MesonException(msg + ' no input files')
+ if i == '@INPUT@':
+ cmd += srcs
+ continue
+ else:
+ if len(srcs) > 1:
+ raise MesonException(msg + ' more than one input file')
+ i = i.replace('@INPUT@', srcs[0])
+ elif '@OUTPUT@' in i:
+ msg = 'Custom target {} has @OUTPUT@ in the command, but'.format(target.name)
+ if len(ofilenames) == 0:
+ raise MesonException(msg + ' no output files')
+ if i == '@OUTPUT@':
+ cmd += ofilenames
+ continue
+ else:
+ if len(ofilenames) > 1:
+ raise MesonException(msg + ' more than one output file')
+ i = i.replace('@OUTPUT@', ofilenames[0])
+ elif '@OUTDIR@' in i:
+ i = i.replace('@OUTDIR@', outdir)
+ elif '@DEPFILE@' in i:
+ if target.depfile is None:
+ raise MesonException('Custom target %s has @DEPFILE@ but no depfile keyword argument.' % target.name)
+ if absolute_paths:
+ dfilename = os.path.join(self.get_target_private_dir_abs(target), target.depfile)
+ else:
+ dfilename = os.path.join(self.get_target_private_dir(target), target.depfile)
+ i = i.replace('@DEPFILE@', dfilename)
+ elif '@PRIVATE_OUTDIR_' in i:
+ match = re.search('@PRIVATE_OUTDIR_(ABS_)?([-a-zA-Z0-9.@:]*)@', i)
+ source = match.group(0)
+ if match.group(1) is None and not absolute_paths:
+ lead_dir = ''
+ else:
+ lead_dir = self.environment.get_build_dir()
+ i = i.replace(source,
+ os.path.join(lead_dir,
+ outdir))
+ cmd.append(i)
# This should not be necessary but removing it breaks
# building GStreamer on Windows. The underlying issue
# is problems with quoting backslashes on Windows