Page MenuHomeFreeBSD

Mk/Uses/go.mk: Allow naming output executable in GO_TARGET, make GH_ACCOUNT/GH_PROJECT usage less surprising
ClosedPublic

Authored by dmgk on Sun, Sep 8, 12:46 PM.

Details

Summary
  • Allow GO_TARGET to be specified as a tuple in the form package:output, which will instruct Go to write resulting executable to ${GO_WRKDIR_BIN}/${output} instead of the default behaviour of naming executable using the last component of the package name. This often removes the need for custom do/post-install that rename executables.

Examples:

  • audio/pms-devel

GO_TARGET= :pms-devel
instead of

do-install:
       ${INSTALL_PROGRAM} ${WRKSRC}/pms-${GH_TAGNAME} ${STAGEDIR}${PREFIX}/bin/${GO_PKGNAME}
  • databases/mongodb40-tools

Targets can be just listed in VARS:

BSONDUMP_VARS=         go_target+=./bsondump/main:bsondump
MONGOSTAT_VARS=                go_target+=./mongostat/main:mongostat
MONGOFILES_VARS=       go_target+=./mongofiles/main:mongofiles

instead of renaming directories in post-patch.

  • Swtich to shell looping in do-build/install. Unfortunately .for over GO_TARGET doesn't really work there because bsd.sites.mk is included too late for GH_ACCOUNT/GH_PROJECT to work correctly in GO_PKGNAME/GO_TARGET (example: textproc/minify)
  • Clarify that GO_PKGNAME is not needed in modules mode.
  • Fix spelling.

Depends on: https://bugs.freebsd.org/bugzilla/show_bug.cgi?id=240414

Test Plan

poudriere bulk of all Go ports.

Diff Detail

Repository
rP FreeBSD ports repository
Lint
Automatic diff as part of commit; lint not applicable.
Unit
Automatic diff as part of commit; unit tests not applicable.

Event Timeline

dmgk created this revision.Sun, Sep 8, 12:46 PM
dmgk edited the summary of this revision. (Show Details)Sun, Sep 8, 12:52 PM
dmgk retitled this revision from Allow naming output executable in GO_TARGET, make GH_ACCOUNT/GH_PROJECT usage less surprising to Mk/Uses/go.mk: Allow naming output executable in GO_TARGET, make GH_ACCOUNT/GH_PROJECT usage less surprising.Sun, Sep 8, 1:01 PM
dmgk updated this revision to Diff 61835.Mon, Sep 9, 12:04 PM

Update GO_PKGNAME description, use ECHO_CMD.

tobik added inline comments.Mon, Sep 9, 1:26 PM
Mk/Uses/go.mk
128 ↗(On Diff #61802)

Since this is a message from the framework use ${ECHO_MSG} here.

140 ↗(On Diff #61802)

I feel like this should somehow also support installing the binaries into a different path altogether like ${PREFIX}/sbin or ${PREFIX}/libexec. Example ports that would benefit are net/gobgp, www/gitea, www/webhook, ...

GO_TARGET=	./bsondump/main:${PREFIX}/sbin/bsondump

where the short form of

GO_TARGET=	./bsondump/main:bsondump

would still just install it as ${PREFIX}/bin/bsondump

dmgk updated this revision to Diff 61850.Mon, Sep 9, 4:41 PM

Use ECHO_MSG, add support for specifying full installation path in GO_TARGET.

dmgk marked 2 inline comments as done.Mon, Sep 9, 4:41 PM
dmgk updated this revision to Diff 61851.Mon, Sep 9, 6:00 PM

mkdir the destination dir if installing using a full path.

tobik accepted this revision.Thu, Sep 12, 11:54 AM

I have only tested a couple of ports, but this looks fine to me.

Can you ask for an exp-run to make sure this does not break anything?

dmgk added a comment.Thu, Sep 12, 12:34 PM

I have only tested a couple of ports, but this looks fine to me.
Can you ask for an exp-run to make sure this does not break anything?

devel/gb is expected to break. Should I declare exp-run PR dependent on https://bugs.freebsd.org/bugzilla/show_bug.cgi?id=240414 ?

In D21562#470983, @dg_syrec.org wrote:

I have only tested a couple of ports, but this looks fine to me.
Can you ask for an exp-run to make sure this does not break anything?

devel/gb is expected to break. Should I declare exp-run PR dependent on https://bugs.freebsd.org/bugzilla/show_bug.cgi?id=240414 ?

Since you already have a fix for that just include it in the exp-run patch too.

This revision was not accepted when it landed; it landed in state Needs Review.Sat, Sep 14, 8:20 AM
This revision was automatically updated to reflect the committed changes.