-
Notifications
You must be signed in to change notification settings - Fork 42
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
Makefile: refactor 'woke', wrap longer lines #86
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Haven't tested, but LGTM. .PHONY after the target not before it isn't a style I've seen. Can't see any problem with it but I'm intrigued: what's the reason?
@lblythen adding a |
Makefile
Outdated
rm -rf $(VENVDIR) | ||
@{ echo "Removing \"woke\" snap... \n"; sudo snap remove woke; } |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
No, we can't do that - I have woke already installed on my system, clean shouldn't remove it.
There's probably no way to install woke locally somehow in case it's not installed globally, or is there? That would be cleaner, and then it could of course also be removed afterwards.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Makes sense. I believe this is the answer:
https://snapcraft.io/docs/parallel-installs
Do you like this approach?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
In general yes - but we can't reconfigure snapd and reboot the machine. :(
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Maybe @degville has some suggestion here?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@ru-fu Perhaps we can drop the remove part for now?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Sure - the other changes all look good to me. :)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Updated.
I'd like to see use improve the initial descriptions in some of these PRs. |
@pmatulis can you please elaborate? |
@akcano In the initial PR's description field we should describe the PR. |
@pmatulis I added some details; looks better now? |
Makefile
Outdated
@test ! -e "$(VENVDIR)" -o -d "$(VENVDIR)" \ | ||
-a "$(abspath $(VENVDIR))" != "$(VENVDIR)" | ||
rm -rf $(VENVDIR) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
If "$(VENVDIR)"
doesn't exist, ! -e "$(VENVDIR)"
will be TRUE. Short-circuit evaluation will yield TRUE for the whole @test statement, so make will continue instead of quitting: rm -rf $(VENVDIR)
will be performed on a non-existent $VENVDIR.
Otherwise make clean
's working because:
- VENVDIR's set to
.sphinx/venv
which generally exists whenmake clean
is run - Therefore
! -e "$(VENVDIR)"
is FALSE, but there's a -o expression which @test therefore must evaluate -d "$(VENVDIR"
is TRUE (.sphinx/venv
is a directory), but there's a -a expression which must also be evaluated"$(abspath $(VENVDIR))"
generally isn't identical to"$(VENVDIR)"
, so the -a expression is TRUE.- FALSE OR TRUE AND TRUE yields TRUE, so make continues:
rm -rf $(VENVDIR)
is performed.
It's good practice to wrap lines in a way that emphasises operator precedence rather than disguising it - it makes errors easier to spot. At present:
@test ! -e "$(VENVDIR)" -o -d "$(VENVDIR)" \
-a ...
keeps two expressions together with -o between them and splits the line between two expressions associated through -a, as if -o has higher precedence than -a. Ignoring problems with the logic, a representation less prone to being misinterpreted would be:
@test ! -e "$(VENVDIR)" -o \
-d "$(VENVDIR)" -a "$(abspath $(VENVDIR))" != "$(VENVDIR)"
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Personally, I think trying to delete a non-existent directory is not an issue at this moment. Technically, it's a no-op; we could stop to report instead of silently falling through, yes, but that goes beyond the scope of Makefile's current state. After all, this simply preserves current behaviour but adds safeguards.
Regarding the line wrapping: you're right, this reads better.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM!
This aims to extract the installation logic of the 'make woke' target into other targets while making the process more explicit for the user with echo commands.
Some of the longer recipe lines affected by this could benefit from wrapping, so a related change is added as a follow-up.