def recursive_template_action(target, source, env): """Render a recursive template.""" outdir = os.path.dirname(str(target[0])) render_recursive_template(env['RECURSIVE_TEMPLATE'], {}, outdir, preserve=["main.c.tpl"])
def test_recursive_render(tmpdir): """Make sure we can actually do a recursive render.""" out_dir = str(tmpdir) files, dirs = render_recursive_template('qemu_semihost_unit', {}, out_dir) for file in files: assert os.path.isfile(os.path.join(out_dir, file)) for folder in dirs: assert os.path.isdir(os.path.join(out_dir, folder))
def recursive_template_emitter(target, source, env): """Emit all of the files generated by a recursive template.""" outdir = os.path.dirname(str(target[0])) files, _dirs = render_recursive_template(env['RECURSIVE_TEMPLATE'], {}, outdir, preserve=["main.c.tpl"], dry_run=True) target.extend([os.path.join(outdir, x) for x in files]) for outfile in files: source.append(files[outfile][1]) return target, source
def test_dryrun(): """Make sure we can get a good list of all output files.""" files, dirs = render_recursive_template('qemu_semihost_unit', {}, "output_folder", dry_run=True) print(files) assert len(files) == 9 assert len(dirs) == 0 # Make sure .tpl is stripped assert files['main.c'][0] == 'main.c.tpl'