-
Notifications
You must be signed in to change notification settings - Fork 503
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
dynamic recipe dependencies #1009
Comments
Currently this isn't possible. Can you tell me more about your specific use-case? There might be a workaround. |
Actually, I have no case right now. It's just that I've been using this approach several times during my strugglings with make. So this question just poped up when I was reading thru docs. For example, if you have I think that this behaviour can be simulated in justfile like this: dep := "dont skip me"
recipe1: recipe2
@echo "recipe1"
recipe2 arg=dep:
#!/usr/bin/env bash
set -euo pipefail
[ -z "{{arg}}" ] && exit 0
echo "recipe2 arg: {{arg}}" And then you can pass empty string to dependent recipe to skip it:
|
Also new to
|
@liquidaty Sorry the workaround is so painful! T_T You should have the same environment variables, but keep in mind that anything that can be set on the command line might be different. What's your use-case that you need to call recipes dynamically? I'm curious if there's a better workaround, or perhaps something that could be better supported. The big difference between |
@casey understood re static typing-- no worries, this solution is perfectly acceptable to me. Current use case is experimental to see if For example, the Makefile might be called via:
which would run target1 and target3, but skip target2. The reason these are passed parameters, and not targets, is simply that the calling program does not have any concept of a target-- everything is a parameter, and even those aren't known to (or defined by) the caller-- they are simply passed through at run time. I suppose it could be reengineered to make the calling program differentiate between targets vs parameters, but better if that could be treated independently of this experiment to replace |
One thing you could do is make the target return early, which can be done with a shebang recipe: target1:
#!/usr/bin/env bash
if $TARGET1 != yes; then
exit
fi
# the rest of the recipe And then unconditionally call them. You can't do this with a linewise recipe (one without a shebang) because there's no way for a linewise recipe to indicate that We have sigils which change how recipe lines execute, and you could imagine a
Which would make this pattern possible with linewise recipes. This is backwards incompatible, so would have to be enabled with a setting. I think this is a potentially interesting feature, I'll create an issue for it and see if anyone wants it. Thanks for the issue! I'm always interested in how |
The Current (for simplicity, assuming each env var has been set to an equivalent lower-case local var):
With
With
2nd form, which is your suggestions, seems like a significant improvement over current. The last form to me is a slight further improvement, but more of a nice-to-have (and I guess it might require supporting a whole 'nother expression datatype so maybe not worth it) |
Hello! I'm switching to
just
frommake
. For now usingjust
is just great :-).A feature I cannot find any information about, is dynamic dependencies. In makefile, I can write something like this:
Is there a way to achieve similar funcationality in
just
?The text was updated successfully, but these errors were encountered: