zb icon indicating copy to clipboard operation
zb copied to clipboard

Support go build `-o` flag

Open robert-zaremba opened this issue 9 years ago • 3 comments

It's is beneficial to build only the requested package / main program (eg by explicitly pointing to the package we want to build using full name or .) and decide where to place the binary. This is especially useful in projects with lot of binaries.

robert-zaremba avatar Jan 08 '17 09:01 robert-zaremba

Wow, sorry for the slow response. Not getting notifications. I'll look into it.

Anyway, you can always use zb -p build . to build just the one package. Also, zb (without -p) will only rebuild the binaries that need to be rebuilt based on file modification times (like make). So if you change one binary source, it will be the only binary rebuilt. If, however, you change a library that multiple binaries depend on, each of those binaries will be rebuilt.

zb is not intended to be a full replacement for the go command. You can mix and match your use of zb and go as needed. The only downside I can think of is that zb will provide linker arguments of the git commit and buildTime that go will not. This is a completely optional use and should never impede building with either tool.

Is this a satisfactory answer, or do you still think there is a case for implicit support of the -o flag?

joshuarubin avatar Jan 19 '17 18:01 joshuarubin

Hello @joshuarubin , Thank you for response, and sorry for being late.

My need is to have an option to specify the zb build output directory. So I can say zb to put the binaries in another directory rather than the project root. I'm thinking about something like zb build -o bin

robert-zaremba avatar Aug 23 '17 15:08 robert-zaremba

That does sound like a useful option.

I'm going to be doing some refactoring of zb to better handle vendored dependencies with the somewhat different way that golang/dep stores things, so I'll see if I can add this at the same time.

joshuarubin avatar Aug 23 '17 15:08 joshuarubin