Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Feature: Provide named targets with variables (aka functions) #454

Open
DarkTrick opened this issue Feb 17, 2022 · 2 comments
Open

Feature: Provide named targets with variables (aka functions) #454

DarkTrick opened this issue Feb 17, 2022 · 2 comments

Comments

@DarkTrick
Copy link

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

@gittup
Copy link
Owner

gittup commented Feb 19, 2022

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.

@DarkTrick
Copy link
Author

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants