Hi ports@, I had the idea of having a make target to help with MODGO_MODULES and MODGO_MODFILES generation just like devel/cargo does with its modcargo-gen-crates.
It may be a bit crude but it works and it could be quite useful when updating ports that use this. I discussed it a bit with abieber@ (as it's based on his portgen go work). He liked the general idea, and we agreed to continue on the list. Not sure if I should use ${REPORT_PROBLEM} instead of that `exit 1`. Of course this should be Comments appreciated. Attached 2 diffs, one against ports for the helper and make target and one against src for the man page changes. Cheers, -- Paco Esteban. 0x5818130B8A6DBC03
Index: infrastructure/bin/modgo-gen-modules-helper =================================================================== RCS file: infrastructure/bin/modgo-gen-modules-helper diff -N infrastructure/bin/modgo-gen-modules-helper --- /dev/null 1 Jan 1970 00:00:00 -0000 +++ infrastructure/bin/modgo-gen-modules-helper 25 Jun 2020 16:31:16 -0000 @@ -0,0 +1,43 @@ +#!/usr/bin/perl + +# $OpenBSD$ +# +# Copyright (c) 2020 Paco Esteban <p...@openbsd.org> +# +# Permission to use, copy, modify, and distribute this software for any +# purpose with or without fee is hereby granted, provided that the above +# copyright notice and this permission notice appear in all copies. +# +# THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES +# WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF +# MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR +# ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES +# WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN +# ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF +# OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. + +use 5.012; +use warnings; + +my ($portdir); + +use FindBin; + +BEGIN { + $portdir = $ENV{PORTSDIR} || '/usr/ports'; +} + +use lib ( "$portdir/infrastructure/lib", "$FindBin::Bin/../lib" ); + +use OpenBSD::PortGen::Port::Go; + +my ( $module ) = @ARGV; + +my $port = OpenBSD::PortGen::Port::Go->new; +my $portinfo = $port->get_dist_info($module); + +$port->set_other( MODGO_MODULES => "\\\n" . join(" \\\n", @{$portinfo->{Dist}})) if $portinfo->{Dist}; +$port->set_other( MODGO_MODFILES => "\\\n" . join(" \\\n", @{$portinfo->{Mods}})) if $portinfo->{Mods}; + +say "MODGO_MODULES =\t$port->{'MODGO_MODULES'}\n"; +say "MODGO_MODFILES =\t$port->{'MODGO_MODFILES'}\n"; Index: lang/go/go.port.mk =================================================================== RCS file: /home/cvs/ports/lang/go/go.port.mk,v retrieving revision 1.33 diff -u -p -r1.33 go.port.mk --- lang/go/go.port.mk 25 Jun 2020 13:57:45 -0000 1.33 +++ lang/go/go.port.mk 25 Jun 2020 18:26:49 -0000 @@ -162,3 +162,12 @@ do-test: ${MODGO_TEST_TARGET} . endif .endif + +# modgo-gen-modules will output MODGO_MODULES and MODGO_MODFILES +modgo-gen-modules: +. if empty(ALL_TARGET) + @${ECHO_MSG} "No ALL_TARGET set" + @exit 1 +. else + @${_PERLSCRIPT}/modgo-gen-modules-helper ${ALL_TARGET} +. endif
Index: share/man/man5/port-modules.5 =================================================================== RCS file: /home/cvs/src/share/man/man5/port-modules.5,v retrieving revision 1.243 diff -u -p -r1.243 port-modules.5 --- share/man/man5/port-modules.5 26 Jan 2020 11:11:39 -0000 1.243 +++ share/man/man5/port-modules.5 25 Jun 2020 18:38:57 -0000 @@ -1128,6 +1128,17 @@ Go package names as arguments), .Ev MODGO_{BUILD,INSTALL,TEST}_TARGET and .Ev MODGO_{BUILD,RUN}_DEPENDS . +.Pp +This module adds one +.Xr make 1 +target: +.Bl -tag -width modgo-gen-modules +.It Cm modgo-gen-modules +Generate the +.Ev MODGO_MODULES +and the +.Ev MODGO_MODFILES +.El .It lang/lua Sets .Ev MODLUA_BIN ,