-
Notifications
You must be signed in to change notification settings - Fork 5
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
Idea: Compile Single Script #83
Comments
Actually the very similar approach is utilized by Taskfile project, but without the preprocessing (awk) step. Believe it or not, but this is almost how it was implemented initially, we even used to have Multiple reasons for this:
|
Very good points. I have some thoughts about them, but please don't interpret this as me trying to argue or convince you of anything. I share them only to help flesh out the idea and be helpful. For point 1, you're right: My compiled script above does have the problem of goals not being independent. However using subshells would largely fix this, i.e. function goal:default() {
(
# Now we're running in a subshell, so goals can't modify global state
)
} For point 2... yeah you're probably right. To be honest, timing isn't terribly important to me personally. The Taskfile approach to timing seems like it's not terribly convoluted with the Point 3: It looks like to support Point 4: I totally agree that dependency order calculation, circular dependency detection, etc. should definitely NOT go in the script. Also the listing of goals via I do think the "single compiled script" approach leaves more room for users to abuse things in ways I haven't considered... but it strikes me as adhering more to the "worse is better" philosophy. I'm not terribly concerned about users who are trying to shoot themselves in the foot - I'm happy as long as we just avoid giving them footguns that are easy to make mistakes with. |
So let's return to the mentioned advantages
But it seems that the whole idea of prelude as a script running before all goals is questionable.
Well if need be we can handle this in current model by making the
So seems like this could be the one of "real" reasons to do it. Relying on imperative script as internal execution model makes the whole thing more imperative in nature. |
Due to considerations above I would prefer to close this for now. |
Our conversation in #81 got me thinking - what if we're thinking about this all wrong? Rather than writing a lot of logic in awk to get things executing in the correct order, why don't we instead just focus on "compiling" the Makesurefile file into an executable script?
For example, say you have this code in your Makesurefile:
It seems like we could pretty easily compile this into the following Bash script:
Here's what it might look like with a more typical Makesurefile:
This would compile to:
Once this script is compiled, it would be a simple matter of just executing it with the
shellExec()
function. It's a fairly simple Bash script you could save to a file and run if you wanted, and it contains most of the important features of Makesure.The advantages I can think of:
@lib
,@use_lib
, or@define
- the prelude can just always be in scope.makesure.awk
.What do you think?
I know I left out lots of details like detecting circular dependencies and whatnot... That kind of logic needs to probably remain as it is now. The actual script execution would just be the last stage, after we've already validated the Makesurefile.
The text was updated successfully, but these errors were encountered: