gokrazy / tools

this repository contains the gok CLI tool of gokrazy
https://gokrazy.org
BSD 3-Clause "New" or "Revised" License
50 stars 27 forks source link

gokr-packer: Support go generate? #10

Closed bzub closed 5 years ago

bzub commented 5 years ago

In cases where a Go program needs to do some pre-build setup before gokr-packer installs it. The scope of this feature could be limited with --tags gokrazy so it only runs generate commands specifically intended for gokrazy.

My use case is to build/update binaries needed for wifi support (https://github.com/gokrazy/gokrazy/issues/13) and pack them into Go byte slices which become available to the Go program.

I will submit a PR for this if this sounds like an OK idea.

bzub commented 5 years ago

I can also see this feature being used to embed user configuration into Go programs. For example in my wifi use case the wifi Go program could look for a wifi config file on the host where gokr-packer is ran.

stapelberg commented 5 years ago

Hm, I’m not sure whether this should be added to the packer. Conceptually, the packer calls go get, not go generate.

You can easily combine both commands into a script — which you’ll need anyway to update from cron — like so:

PACKAGES := github.com/stapelberg/zkj-nas-tools/avr-x1100w \
        github.com/stapelberg/hmgo

go generate ${PACKAGES}
gokr-packer -serial_console=disabled -hostname=dr -update=yes ${PACKAGES}
bzub commented 5 years ago

That's true. Closing :)