Add @PLAINNAME@ and @BASENAME@ to arguments argument for Generator

Fixes #1282
pull/2340/head
Niklas Claesson 7 years ago
parent bbda3c7adb
commit 07dde545d9
  1. 2
      mesonbuild/backend/ninjabackend.py
  2. 2
      mesonbuild/backend/vs2010backend.py
  3. 6
      mesonbuild/build.py
  4. 19
      test cases/common/98 gen extra/meson.build
  5. 3
      test cases/common/98 gen extra/name.l

@ -1784,7 +1784,6 @@ rule FORTRAN_DEP_HACK
exe_arr = self.exe_object_to_cmd_array(exe)
infilelist = genlist.get_inputs()
outfilelist = genlist.get_outputs()
base_args = generator.get_arglist()
extra_dependencies = [os.path.join(self.build_to_src, i) for i in genlist.extra_depends]
source_target_dir = self.get_target_source_dir(target)
for i in range(len(infilelist)):
@ -1794,6 +1793,7 @@ rule FORTRAN_DEP_HACK
sole_output = ''
curfile = infilelist[i]
infilename = curfile.rel_to_builddir(self.build_to_src)
base_args = generator.get_arglist(infilename)
outfiles = genlist.get_outputs_for(curfile)
outfiles = [os.path.join(self.get_target_private_dir(target), of) for of in outfiles]
if generator.depfile is None:

@ -106,7 +106,6 @@ class Vs2010Backend(backends.Backend):
infilelist = genlist.get_inputs()
outfilelist = genlist.get_outputs()
exe_arr = self.exe_object_to_cmd_array(exe)
base_args = generator.get_arglist()
idgroup = ET.SubElement(parent_node, 'ItemGroup')
for i in range(len(infilelist)):
if len(infilelist) == len(outfilelist):
@ -115,6 +114,7 @@ class Vs2010Backend(backends.Backend):
sole_output = ''
curfile = infilelist[i]
infilename = os.path.join(down, curfile.rel_to_builddir(self.build_to_src))
base_args = generator.get_arglist(infilename)
outfiles_rel = genlist.get_outputs_for(curfile)
outfiles = [os.path.join(target_private_dir, of) for of in outfiles_rel]
generator_output_files += outfiles

@ -1075,8 +1075,10 @@ class Generator:
basename = os.path.splitext(plainname)[0]
return self.depfile.replace('@BASENAME@', basename).replace('@PLAINNAME@', plainname)
def get_arglist(self):
return self.arglist
def get_arglist(self, inname):
plainname = os.path.split(inname)[1]
basename = os.path.splitext(plainname)[0]
return [x.replace('@BASENAME@', basename).replace('@PLAINNAME@', plainname) for x in self.arglist]
def process_files(self, name, files, state, extra_args=[]):
output = GeneratedList(self, extra_args=extra_args)

@ -11,3 +11,22 @@ g2 = gen.process('name.dat', extra_args: '--upper')
test('basic', executable('basic', 'plain.c', g1))
test('upper', executable('upper', 'upper.c', g2))
cp = find_program('cp')
basename_gen = generator(cp,
output : '@BASENAME@.c',
arguments : ['@INPUT@', join_paths('@BUILD_DIR@', '@BASENAME@.c')])
# This test should produce a name.c
basename_src = basename_gen.process('name.l')
test('basename', executable('basename', basename_src))
plainname_gen = generator(cp,
output : '@PLAINNAME@.c',
arguments : ['@INPUT@', join_paths('@BUILD_DIR@', '@PLAINNAME@.c')])
# This test should produce a name.l.c
plainname_src = plainname_gen.process('name.l')
test('plainname', executable('plainname', plainname_src))

@ -0,0 +1,3 @@
int main() {
return 0;
}
Loading…
Cancel
Save