On Fri, 25 Sep 2020, Paco Esteban wrote: > On Thu, 25 Jun 2020, Paco Esteban wrote: > > > 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`. > > > > Comments appreciated. > > > > Some time ago I sent this. > abieber@ was ok with it but we had some doubts on where to put the perl > helper script. A second opinion on this would be nice. > > I've been using it to update MODGO_MODULES and MODGO_MODFILES for > www/hugo for some time now and it works ok for me. > > Attached both diffs again for convenience. > > Ok to commit ?
Updated diff. This time it also outputs MODGO_VERSION as suggested by abieber@ Comments ? ok to commit ? diff f248be11a10da0701307e728a200c35ff1b87784 refs/heads/modgo blob - /dev/null blob + 8e53dd0537be696920c08c2d6eab3b14cc4a9332 (mode 644) --- /dev/null +++ infrastructure/bin/modgo-gen-modules-helper @@ -0,0 +1,44 @@ +#!/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_VERSION =\t$portinfo->{Version}\n"; +say "MODGO_MODULES =\t$port->{'MODGO_MODULES'}\n"; +say "MODGO_MODFILES =\t$port->{'MODGO_MODFILES'}\n"; blob - 0d254934f32160dfe98719b0ec62b6f8b9c03769 blob + 29e60ea1e53ab34dc737b723320242cd1dfd9bea --- lang/go/go.port.mk +++ lang/go/go.port.mk @@ -161,3 +161,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