Earlier quoted context omitted.
I disagree. Make is more than a build system, it's also an automation tool. It gives you a fairly flexible format for managing different tasks with shared variables and autocompletion and more. You can do it with a bunch of shell scripts too but I prefer having everything in a single file.
> Make is more than a build system, it's also an automation tool. I agree with that, but I don't believe that the GP said otherwise. Make is an automation tool, but what it aims to automate is exactly dependency tracking. Other features, like actually performing the tasks, are off-loaded to the shell and other tools. > It gives you a fairly flexible format for managing different tasks with shared variables and autoco…
Using Makefile(s) for Go
91–100 of 104 posts
Re: Using Makefile(s) for Go
#92I've seen a lot of developers, especially developers with C backgrounds, reach for Makefiles when approaching Go development, and I think it's a harmful practice. So, I'd like to offer a respectful but firm rebuttal to this article. :) I dislike using make(1) with Go for two reasons. The first is that make was developed for building C projects, and therefore is oriented around that task. Building C projects is a lot…
Why do people on this website use "make(1)" instead of "make" in writing? And I know it's in the man pages but what is this number even for?
Re: Using Makefile(s) for Go
#93Earlier quoted context omitted.
I agree with your point, but make solves the problem rather poorly. Besides the poor UX, it only knows the thing it built most recently, as opposed to maintaining a cache of things it has _ever_ built. And since it doesn't have a cache, it definitely doesn't have a distributed cache, although you could conceivably try to shoehorn NFS or something similar. Lastly, it's not reproducible. It's not going to fail a build…
I agree with the observation. But the alternatives are grossly over-engineered or a case study in NIH. I'm sticking with Makefiles until someone can present something better. >Something like Bazel theoretically solves this problem, but it's poorly documented and non-trivial to use or operate. Other Bazel/Blaze derivatives are worse with respect to usage/operation/correctness. I have night terrors from listening to tw…
I agree that they are complex beasts, but that complexity is incidental, not essential (some might argue "a lack of engineering" rather than "overengineered"). The documentation for these tools is also pretty atrocious on average. However, I don't think they're NIH insofar as their direct ancestor (Blaze) was never publicly available and Bazel didn't exist when those original Googler pilgrims brought their build-system ideas to Facebook, Twitter, Foursquare, etc. But nevertheless, there are half a dozen shitty tools instead of one decent tool. Worse, they're pretty much all designed for use in large organizations' monorepos--organizations who can employ people who are specialists in operating/maintaining these tools.
> I don't think Nix improves anything when you are stuck writing a weird javascript derivative. This comes from a packager writing bash for a living.
The improvements are certainly not uniformly distributed, nor are they sufficient to really justify its mainstream use, IMHO. :)
Re: Using Makefile(s) for Go
#94Earlier quoted context omitted.
I'm pretty sure MacOS and most of the headless Linux distributions require you to install it (from a package manager or similar). It's not hard, but usually the alternatives aren't hard to install either.
I've never had that issue. Make existed on all Mac systems I've worked on. Perhaps it got pulled in via other tools, but recently I ran into an issue with the Make on my Mac, and only because the version out of the box is a 3.x, from 2006.
Re: Using Makefile(s) for Go
#95It's really frustrating seeing so many Makefiles that don't _make_ anything. Make syntax is really odd. I see so many folks go out of their way to deal w/quirks of make when they really just need a shell script. You can see this anti-pattern very quickly when you see `.PHONY` targets for everything. I think make is useful for some aspects of go. GOPATH is becoming less relevant now, but still helpful when you want to…
Is there a way to easily have something like make targets in a shell script, without a ton of boilerplate? > Make syntax is really odd I don't find it particularly strange, except my biggest peeve - the insistence on tabs!
#!/bin/sh
set -e
case "$1" in
build)
;;
run)
;;
clean)
;;
*)
echo "unknown: $1"; exit 2
;;
esac
Someone else ITT hinted it could be done like the following. But the last line is dubious because it will happily run anything on PATH. #!/bin/sh
set -e
test $# -gt 0
build() {
:
}
run() {
:
}
clean() {
:
}
"$@"Re: Using Makefile(s) for Go
#96Earlier quoted context omitted.
Make is available everywhere that matters, and is a simple declarative way to encompass build actions. What are the alternatives? Bash? Not declarative, and requires lots more code. Some go rewrite of Make? Not universal, possibly not maintained in the future. Rake? Ugh, Ruby. I strongly believe that make is the least worst way to build go projects, but please change my mind by suggesting some alternatives, not by co…
This is patently untrue. Make is not available by default on Windows, which - whether you like it or not - matters as a platform for a large number of developers. _Fortunately_ some CI images (certainly GitHub Actions and Azure DevOps) install GNU Make on their windows images by default, but it absolutely cannot be assumed for average developers.
If you're forced to use Windows for a job- that sucks. You're probably used to doing lots of silly things just to get a reasonable development environment.
It's like saying Make is a bad system because it doesn't support left-to-right languages like Hebrew or Arabic.
Re: Using Makefile(s) for Go
#97Earlier quoted context omitted.
Is there a way to easily have something like make targets in a shell script, without a ton of boilerplate? > Make syntax is really odd I don't find it particularly strange, except my biggest peeve - the insistence on tabs!
Here's a named task runner shellscript (as compared to a Makefile full of .PHONY being used as a named task runner). #!/bin/sh set -e case "$1" in build) ;; run) ;; clean) ;; *) echo "unknown: $1"; exit 2 ;; esac Someone else ITT hinted it could be done like the following. But the last line is dubious because it will happily run anything on PATH. #!/bin/sh set -e test $# -gt 0 build() { : } run() { : } clean() { : }…
Personally, I've never used PHONY, or had a need to.
That said, your bash examples are pretty simple - I especially like the 2nd example, as it would trivially allow having targets that ran other targets, e.g. an "all" target from a makefile:
``` all: build push
build: @docker build --tag ${IMG} --tag ${UNSTABLE} .
rebuild: @docker build --no-cache --tag ${IMG} --tag ${UNSTABLE} .
push: @docker push ${NAME} ```
Re: Using Makefile(s) for Go
#98Earlier quoted context omitted.
This is patently untrue. Make is not available by default on Windows, which - whether you like it or not - matters as a platform for a large number of developers. _Fortunately_ some CI images (certainly GitHub Actions and Azure DevOps) install GNU Make on their windows images by default, but it absolutely cannot be assumed for average developers.
For the sake of this argument, windows support doesn't really matter. If you're forced to use Windows for a job- that sucks. You're probably used to doing lots of silly things just to get a reasonable development environment. It's like saying Make is a bad system because it doesn't support left-to-right languages like Hebrew or Arabic.
Re: Using Makefile(s) for Go
#99Any project will eventually have build and deployment scripts with non-trivial amounts of logic in them.
The question then becomes whether you want all that complex logic in shell scripts, makefiles, or Python.
For me, it's a no-brainer. I'll take the latter every time.
Re: Using Makefile(s) for Go
#100Shit... Docker is a makefile...