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

Can not pass @glob ITEMs to other @glob goals #172

Open
koljakube opened this issue Sep 25, 2024 · 2 comments
Open

Can not pass @glob ITEMs to other @glob goals #172

koljakube opened this issue Sep 25, 2024 · 2 comments

Comments

@koljakube
Copy link

I have, not for the first time, encountered the following situation:

A directory contains a set of similar files, lets call them definitions.

./
- definitions/
  - def1
  - def2
- Makesurefile
- makesure

A Makesurefile contains glob goals for these definitions.

@goal make-foo @glob 'definitions/*'
  process "$ITEM" "$(target_name_for "$ITEM")"

@goal upload-foo @glob 'definitions/*'
  upload "$(target_name_for "$ITEM")"

Now upload-foo cannot depend on make-foo by forwarding its ITEM. I tried:

  • @depends_on 'make-foo@$ITEM'
  • @depends_on "make-foo@$ITEM"
  • @depends_on 'make-foo' @args ITEM
  • @depends_on 'make-foo' @glob
  • @depends_on 'make-foo' @glob ITEM
  • @depends_on 'make-foo' @args "$ITEM"
  • @depends_on 'make-foo' @args '$ITEM'

(I know not all are legal)

I also can not build a hybrid @param-@glob solution, since @globs are not callable (outside of calling makesure recursively), and @globs also can not forward their item.

I have two suggested solutions, in order of preference:

  1. Allow using ITEM like any other parameter, without any restrictions; and also allow calling @glob goals (with unmatched globbed items simply resulting in "goal not found" errors).
  2. Allow forwarding between @glob goals with identical glob strings by appending @glob to the @depends_on (here, a more descriptive error message might be appropriate).

I can't think of really evil ways of abusing the first proposal, but the second one would of course be a lot more restricted and declarative. What do you think? I might even try contributing a patch if I find the time.

@koljakube
Copy link
Author

On further reflection, I underestimated the problem, since parameterized goals do not get instantiated without a dependency on them and the specific argument list. That makes even recursive makesure calls a non-viable workaround. I could still call @glob goals recursively, but then I need to implement the globbing in shell scripts as well.

I still think a lot would be gained by glob-forwarding and allowing ITEM after @args.

@xonixx
Copy link
Owner

xonixx commented Sep 26, 2024

Thank you for this case. Indeed this looks like a useful feature to have. I’ll try to assess a viable implementation strategy.

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