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

Ensure Make behaves like make #3

Open
squeedee opened this issue Jul 10, 2019 · 0 comments
Open

Ensure Make behaves like make #3

squeedee opened this issue Jul 10, 2019 · 0 comments

Comments

@squeedee
Copy link

build/marman-linux: $(SRC) deps

Today I learnt (or realised something i knew but haven't been applying):

This is a file target

build/marman-linux: $(SRC) deps
	GOARCH=amd64 GOOS=linux go build -o build/marman-linux -ldflags ${LDFLAGS} ./cmd/marman/main.go

This is a pseudo-target

build-darwin: build/marman-darwin

If you want make to be efficient, try to make sure that file targets always depend on other file targets

In the build/marman-linux target, we're depending on a pseudo-target, deps which means the go build will always be run again, despite there being nothing to do.

the fix is to move deps to the pseudo target:

build/marman-linux: $(SRC)
	GOARCH=amd64 GOOS=linux go build -o build/marman-linux -ldflags ${LDFLAGS} ./cmd/marman/main.go

build-darwin: deps build/marman-darwin

OR we can establish a file target for deps using the temp/tags trick but that's not always feasable.

This isn't an immediate issue, in that building our go apps is pretty fast, but it can balloon out and cause friction when later you decide to add a slower pre-processing action to your builds.

squeedee pushed a commit to cf-platform-eng/mrreport that referenced this issue Jul 10, 2019
- not quite idiomatic because 'packr2 build' should preclude needing 'go build'
  - could not make that work
- added 'packr2 build' as file targets
- added documentation to help when working with packr
- made builds a little more efficient, see cf-platform-eng/marman#3

Co-authored-by: Pete Wall <[email protected]>
[#165363463]
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant