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

make: 'go build' does not run when TAGS change #10196

Closed
silverwind opened this issue Feb 8, 2020 · 3 comments · Fixed by #10219
Closed

make: 'go build' does not run when TAGS change #10196

silverwind opened this issue Feb 8, 2020 · 3 comments · Fixed by #10219

Comments

@silverwind
Copy link
Member

silverwind commented Feb 8, 2020

TAGS=bindata make build
make build

The intentions is to first build with bindata, then without.

I still observe a bindata executable after the second build becausego build never ran (make thinks the executable is already up to date). We somehow need to trigger go build when the value of TAGS differs from the previous build.

I'm not exactly sure how to best achieve that except writing out the last TAGS to a evidence file after build and only write the file again when TAGS differs from the file's content. If there are other environment variables that can affect the build, they would need the same treatment.

cc: @guillep2k

@silverwind silverwind changed the title make: 'go build' does run when TAGS change make: 'go build' does not run when TAGS change Feb 8, 2020
@guillep2k
Copy link
Member

guillep2k commented Feb 9, 2020

Yes, it's a good point. I'd write the tags to an evidence file, but only if different. Something like:

mkdir -p "`dirname "$EVIDENCE"`" ; # Just make sure the directory exists
if [ "`cat "$EVIDENCE" 2>/dev/null`" != "$TAGS" ] ; then echo "$TAGS" > "$EVIDENCE" ; fi

@silverwind
Copy link
Member Author

I wonder if it is safe to skip the go generate step if the bindata tag is absent.

@zeripath
Copy link
Contributor

No. Do not skip generate. Even if it does nothing at present - we should start using generate more.

silverwind added a commit to silverwind/gitea that referenced this issue Feb 10, 2020
Write out TAGS to .make_evidence/tags and compare it to the previous
invocation. If they differ, insert the evidence file into the prereqs
of targets that use TAGS. I made it .PHONY so it always builds.

I did not include the prereq on release tasks, asssuming the will always
do a clean build.

Fixes: go-gitea#10196
sapk added a commit that referenced this issue Feb 11, 2020
Write out TAGS to .make_evidence/tags and compare it to the previous
invocation. If they differ, insert the evidence file into the prereqs
of targets that use TAGS. I made it .PHONY so it always builds.

I did not include the prereq on release tasks, asssuming the will always
do a clean build.

Fixes: #10196

Co-authored-by: techknowlogick <matti@mdranta.net>
Co-authored-by: Antoine GIRARD <sapk@users.noreply.github.com>
@go-gitea go-gitea locked and limited conversation to collaborators Nov 24, 2020
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants