Wednesday, June 30, 2021

Re: Convenience changes for Go

On Wed, 30 Jun 2021 14:24:24 -0600, Aaron Bieber <aaron@bolddaemon.com>
wrote:

Thanks for working on it! I see a few possible improvements:

> -# modgo-gen-modules will output MODGO_MODULES and MODGO_MODFILES
> +# modgo-gen-modules will output MODGO_MODULES and MODGO_MODFILES for
> +# the latest version of a given MODGO_MODNAME if MODGO_VERSION is set to
> +# "current". Otherwise it will fetch the MODULES/MODFILES for the presently
> +# set MODGO_VERSION.

Can we use "latest" instead of current? That's the terminology upstream
uses:
"The string latest, which selects the highest available release
version."

https://golang.org/ref/mod#version-queries

> modgo-gen-modules:
> .if empty(MODGO_MODNAME)
> @${ECHO_MSG} "No MODGO_MODNAME set"
> @exit 1
> .else
> +.if ${MODGO_VERSION} == "current"
> @${_PERLSCRIPT}/modgo-gen-modules-helper ${MODGO_MODNAME}
> +.else
> + @${_PERLSCRIPT}/modgo-gen-modules-helper ${MODGO_MODNAME}
> ${MODGO_VERSION} .endif
> +.endif

We're nesting ifs here. We can put the new one outside easily, but if
you don't want to do that, the second one should be indented like the
one L152.

My main disagreement is that if you don't have any MODGO_VERSION set,
it fails with
$ make modgo-gen-modules
*** Parse error in /usr/ports/security/age: Malformed conditional (${MODGO_VERSION} == "current") (/usr/ports/lang/go/go.port.mk:189)
*** Parse error: Need an operator in '"current"' (/usr/ports/lang/go/go.port.mk:189)

I tried setting something like
MODGO_VERSION ?= "current" but make(1) didn't like it.

Here's an updated diff for the two first points. It doesn't improve the
empty MODGO_VERSION tho :(

BTW, go-module(5) will need an update.

Index: go.port.mk
===================================================================
RCS file: /cvs/ports/lang/go/go.port.mk,v
retrieving revision 1.42
diff -u -p -r1.42 go.port.mk
--- go.port.mk 23 Mar 2021 13:19:08 -0000 1.42
+++ go.port.mk 30 Jun 2021 21:23:38 -0000
@@ -71,7 +71,7 @@ DISTNAME_ESC = ${DISTNAME${_s}}
EXTRACT_SUFX ?= .zip
PKGNAME ?= ${DISTNAME:S/-v/-/}
ALL_TARGET ?= ${MODGO_MODNAME}
-MODGO_FLAGS += -modcacherw
+MODGO_FLAGS += -modcacherw -trimpath
DISTFILES += ${DISTNAME_ESC}${EXTRACT_SUFX}{${MODGO_VERSION}${EXTRACT_SUFX}}
EXTRACT_ONLY = ${DISTNAME_ESC}${EXTRACT_SUFX}
MASTER_SITES ?= ${MASTER_SITE_ATHENS}${MODGO_MODNAME_ESC}/@v/
@@ -177,11 +177,17 @@ do-test:
. endif
.endif

-# modgo-gen-modules will output MODGO_MODULES and MODGO_MODFILES
+# modgo-gen-modules will output MODGO_MODULES and MODGO_MODFILES for
+# the latest version of a given MODGO_MODNAME if MODGO_VERSION is set to
+# "latest". Otherwise it will fetch the MODULES/MODFILES for the presently
+# set MODGO_VERSION.
modgo-gen-modules:
.if empty(MODGO_MODNAME)
@${ECHO_MSG} "No MODGO_MODNAME set"
@exit 1
-.else
+.endif
+.if ${MODGO_VERSION} == "latest"
@${_PERLSCRIPT}/modgo-gen-modules-helper ${MODGO_MODNAME}
+.else
+ @${_PERLSCRIPT}/modgo-gen-modules-helper ${MODGO_MODNAME} ${MODGO_VERSION}
.endif

No comments:

Post a Comment