tup
tup copied to clipboard
Feature: Provide named targets with variables (aka functions)
Allow for targets like in make, but also allow usage of variables
I imagine something like this:
copy_files (build_level):
foreach src/* |> cp %f %o |> $(build_level)/%b
release:
copy_files(release)
debug:
copy_files(debug)
Benefits
Allows more flexible build scripts and better support for DRY within the build scripts
Although it's not a function, you might be able to do what you want here with !macros (see the man page under TUPFILES, !macro). In a Tuprules.tup file you could define the macro like so:
build_level = ...
!copy_files = |> cp %f %o |> $(build_level)/%b
And in a Tupfile:
include_rules
: foreach *.txt |> !copy_files |>
You might also be interested in using the Tupfile.lua parser, since with lua you can use actual functions.
Thank you for the reply!
- Nice idea! But this doesn't work for more complex examples and variables that are changing for each call.
- I will take a look at at Tupfile.lua. Maybe it solves the problem.