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

Update Makefile to reflect the move to a go module. #437

Merged
merged 1 commit into from
Sep 28, 2022

Conversation

kellegous
Copy link
Member

@kellegous kellegous commented Sep 27, 2022

What kind of change does this PR introduce? (check at least one)

  • Bugfix
  • Feature
  • Code style update
  • Refactor
  • Build-related changes
  • Other, please describe:

The PR fulfills these requirements:

  • All tests are passing?
  • New/updated tests are included?
  • If any static assets have been updated, has ui/bindata.go been regenerated?
  • Are there doc blocks for functions that I updated/created?

If adding a new feature, the PR's description includes:

  • A convincing reason for adding this feature (to avoid wasting your time, it's best to open a suggestion issue first and wait for approval before working on it)

Other information:

Since Hound is now a proper Go module, we can avoid a lot of the complexity of setting up the GOPATH that we used to have to deal with. This updates the Makefile so that GOPATH hijinks is no longer required to build locally. The one caveat is that houndd and hound will be built into .build/bin instead of $GOPATH/bin.

A few other changes explained:

Why tools/tools.go?

A go module should explicitly reference its dependencies somewhere. go mod tidy is often used to cull dependencies that are no longer needed in a go module. This poses a problem for dependencies that are build related as they are only referenced in the build system. A convention that is often used, and which I'm using here, is to add an explicit code reference to those dependencies in a package that is not actually reachable from the main module ... but tells tools like go mod tidy that the dependency is used.

Why update the node_modules rule to node_modules/build?

Since I created this Makefile, I found that make targets that reference a directory are unreliable. Make often believes they have been invalidated when they haven't. It seems to be best practice to not have a directory as a target in gnu make because of differences in the way mtime is updated for directories. So I've started making all my node_modules make targets point to a file within the node_modules directory.

Copy link
Contributor

@salemhilal salemhilal left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thank you for these changes and for the clear, thorough explanations! I hope my own PRs are even half as clear as this one.

I left two minor comments, but the changes themselves look good to me.

README.md Outdated Show resolved Hide resolved
@@ -11,25 +11,25 @@ ALL: $(CMDS)

ui: ui/bindata.go

node_modules:
node_modules/build:
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm not well-versed in Make, but is it possible to drop a comment here explaining why node_modules/build is the target? That feels like one of those things that would get lost to time otherwise.

Copy link
Contributor

@dschott68 dschott68 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

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

Successfully merging this pull request may close these issues.

3 participants