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

Support custom build args #21

Closed andig closed 3 years ago

andig commented 3 years ago

Fix https://github.com/gokrazy/gokrazy/issues/80

Doing something like

-build_args "-tags=release -ldflags '-X "github.com/andig/evcc/server.Version=foo" -X "github.com/andig/evcc/server.Commit=bar"'"

seems to work fine. I had expected needing to use something like https://github.com/kballard/go-shellquote or https://github.com/google/shlex but that doesn't seem required.

andig commented 3 years ago

As-is, this pull request enforces the same build options for all applications, which is not necessarily desirable.

Doh: Will update accordingly.

The proposed structure will lead to a lot of directories:

flags/github.com/gokrazy/timestamps/flags.txt

then becomes:

buildopt/github.com/gokrazy/timestamps/buildopt.txt

Would you be ok with flattening these and putting the various package-specific options into a single per-packege folder like

github.com/gokrazy/timestamps/flags.txt
github.com/gokrazy/timestamps/buildopt.txt
stapelberg commented 3 years ago

The proposed structure will lead to a lot of directories:

Yes, one per thing that you’re changing.

I like that you can do e.g. head -100 flags/**/* (provided your shell expands **/*) to see all flags for all packages.

I don’t think that’s a problem, though. I understand that some people might subjectively prefer one or the other.

What I’m shooting for here is maximum clarity, though. All flags go into the flags directory, all environment variables into the environ directory, etc.

andig commented 3 years ago

I like that you can do e.g. head -100 flags/*/ (provided your shell expands */) to see all flags for all packages.

You could do the same by ./**/flags.txt?

andig commented 3 years ago

LGTM:

❯ gor github.com/gokrazy/tools/cmd/gokr-packer -http_port 8080 -update yes -hostname evcc github.com/gokrazy/breakglass github.com/andig/evcc
2021/01/11 15:40:09 packer.go:458: building [github.com/gokrazy/breakglass github.com/andig/evcc]
2021/01/11 15:40:09 packer.go:200: package github.com/andig/evcc will be compiled with build args from buildargs/github.com/andig/evcc/buildargs.txt
[build -tags gokrazy -o /var/folders/73/89ycv7qn51j4kbm04jsz9b840000gn/T/gokrazy-bins-302778475/dhcp github.com/gokrazy/gokrazy/cmd/dhcp]
[build -tags gokrazy -o /var/folders/73/89ycv7qn51j4kbm04jsz9b840000gn/T/gokrazy-bins-302778475/evcc -tags=release -ldflags '-X "github.com/andig/evcc/server.Version=${VERSION}" -X "github.com/andig/evcc/server.Commit=${SHA}"' github.com/andig/evcc]
stapelberg commented 3 years ago

You could do the same by ./**/flags.txt?

Indeed, yes.

I still feel that having a top-level directory for per-package configuration files is a good idea.

andig commented 3 years ago

You could do the same by ./**/flags.txt?

Indeed, yes.

I still feel that having a top-level directory for per-package configuration files is a good idea.

Maybe packageconf or buildconfig as top level? Then we could at least gather multiple files in the same package folder. Or .gocrazy-build?