Additional build-time variable overrides in cros-go.eclass

Skip to first unread message

Clayton Whitelaw

May 11, 2023, 12:51:13 AM5/11/23
It looks like the cros-go eclass is hard-coded to substitute only `main.Version` when a special variable is present. I would like to set more than just this one value.

I can see a few possibilities, in order of less constraints:
  • An associative array named something like CROS_GO_VARIABLES or something like that that maps `pkg.var => value`  and passes each into ldflags as an argument to -X.
  • An array named CROS_GO_LDFLAGS that lets you pass in whatever ldflags you want.
    • "ldflags=${CROS_GO_LDFLAGS[@]}"
  • An array named CROS_GO_BUILD_OPTS that lets you pass anything into the cros_go build step
    • cros_go build -v ... "${CROS_GO_BUILD_OPTS[@]}" ...
Any preferences, or other eclasses that serve as an example to follow?

Clayton Whitelaw

May 12, 2023, 1:13:12 PM5/12/23
to, Jack Rosenthal
I asked +Jack Rosenthal in person and he pointed me to flag-o-matic. Seems like it's targeted at C/C++ toolchains, but it would support this use case.

It also sounds like in any case it's okay to add something more simple/general like in the second and third options I mentioned previously.

Clayton Whitelaw

May 13, 2023, 5:33:50 PM5/13/23
to, Jack Rosenthal
Looks like the ldflags are different between Go and C/C++ judging by the usage of "-X", so flag-o-matic is probably not a match and I'll probably go with adding CROS_GO_LDFLAGS.
Reply all
Reply to author
0 new messages