-
Notifications
You must be signed in to change notification settings - Fork 85
Makefile: Add a pattern rule for oci-* commands #28
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
Conversation
yes please, split them into individual targets and then have "tools" to build them all |
The previous commit only rebuilt them when the associated main.go was newer, which avoided some unnecessary rebuilds. Unfortunately, it also avoids rebuilding when another Go dependency changed, which could bite users that expected 'make tools' to give them fresh copies of the tools even if they only touched a dependency package. I'm fine either way, but Antonio prefers always rebuilding [1], so this commit adds it. I've switched the old pattern rule to a static pattern rule [2], because Make was treating the non-static pattern rules as implicit rules and .PHONY causes implicit rules to be skipped [3]. [1]: opencontainers#28 (comment) [2]: https://www.gnu.org/software/make/manual/html_node/Static-Usage.html [3]: https://www.gnu.org/software/make/manual/html_node/Phony-Targets.html Signed-off-by: W. Trevor King <[email protected]>
|
On Thu, Sep 22, 2016 at 09:40:40AM -0700, Antonio Murdaca wrote:
As is stood in 0179710, this PR already split them into individual |
|
|
||
| .PHONY: \ | ||
| tools \ | ||
| $(TOOLS) \ |
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.
that is somewhat redundant
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.
also, not true. When those binaries are built from the subdirectory, then the executable by those names is present.
| go build ./cmd/oci-image-validate | ||
| tools: $(TOOLS) | ||
|
|
||
| $(TOOLS): oci-%: |
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.
Here the oci-% is looking for dependencies of the target that have the oci-% pattern. Is that intended?
|
On Thu, Sep 22, 2016 at 10:50:54AM -0700, Vincent Batts wrote:
We need $(TOOLS) so we rebuild them every time. You could remove |
|
On Thu, Sep 22, 2016 at 10:56:01AM -0700, Vincent Batts wrote:
This is a static pattern rule (linked from the the 689ee3e commit |
|
would almost seem like to get the Makefile dependency usefulness, we could have something like GO_DEPS = $(shell go list -f '{{range .Deps}}{{printf "%s" .}}{{end}}' $(1))
GO_SOURCE_FILES = $(shell go list -f '{{range .GoFiles}}{{printf "%s" .}}{{end}}' $(1))
oci-%: $(call GO_SOURCE_FILES,$(call GO_DEPS,./cmd/oci-%))
go build ./cmd/$@or similar |
|
On Thu, Sep 22, 2016 at 11:27:41AM -0700, Vincent Batts wrote:
Having an accurate list of dependencies would be awesome, but the On the other hand, ‘go build’ (as we call it without -a) only rebuilds |
|
yes. |
|
On Thu, Sep 22, 2016 at 11:48:06AM -0700, Vincent Batts wrote:
So we're both happy with this PR as it stands with 689ee3e? Or is |
|
please rebase |
Make it easy to (re)build a single command without building all of them. Using main.go as the only prerequisite cuts some corners, but prerequisites for this are hard ;). With this commit, you can touch main.go to force a rebuild. If that ends up being too awkward, we can make these .PHONY targets. Signed-off-by: W. Trevor King <[email protected]>
The previous commit only rebuilt them when the associated main.go was newer, which avoided some unnecessary rebuilds. Unfortunately, it also avoids rebuilding when another Go dependency changed, which could bite users that expected 'make tools' to give them fresh copies of the tools even if they only touched a dependency package. I'm fine either way, but Antonio prefers always rebuilding [1], so this commit adds it. I've switched the old pattern rule to a static pattern rule [2], because Make was treating the non-static pattern rules as implicit rules and .PHONY causes implicit rules to be skipped [3]. [1]: opencontainers#28 (comment) [2]: https://www.gnu.org/software/make/manual/html_node/Static-Usage.html [3]: https://www.gnu.org/software/make/manual/html_node/Phony-Targets.html Signed-off-by: W. Trevor King <[email protected]>
689ee3e to
2d06368
Compare
|
LGTM |
|
On Thu, Oct 06, 2016 at 09:35:21AM -0700, Vincent Batts wrote:
Is that lint timeout reproducible? I'd just kick it again. |
|
funky. that did the trick. |
Make it easy to (re)build a single command without building all of them. Using main.go as the only prerequisite cuts some corners, but prerequisites for this are hard ;). With this commit, you can touch
main.goto force a rebuild. If that ends up being too awkward, we can make these.PHONYtargets.This is the current first commit in #5, to see if nibbling away at that PR one commit at a time makes review any easier.