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

28 views
Skip to first unread message

Clayton Whitelaw

unread,
May 11, 2023, 12:51:13 AM5/11/23
to chromiu...@chromium.org
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

unread,
May 12, 2023, 1:13:12 PM5/12/23
to chromiu...@chromium.org, 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

unread,
May 13, 2023, 5:33:50 PM5/13/23
to chromiu...@chromium.org, 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
Forward
0 new messages