Patchwork Clean all .go in clean-go

login
register
mail settings
Submitter Eric Bavier
Date Sept. 16, 2016, 5:15 a.m.
Message ID <20160916001540.617d9a54@openmailbox.org>
Download mbox | patch
Permalink /patch/15686/
State New
Headers show

Comments

Eric Bavier - Sept. 16, 2016, 5:15 a.m.
On Fri, 02 Sep 2016 14:42:27 +0200
ludo@gnu.org (Ludovic Courtès) wrote:

> Eric Bavier <ericbavier@openmailbox.org> skribis:
> 
> > On Thu, 01 Sep 2016 14:37:58 +0200
> > ludo@gnu.org (Ludovic Courtès) wrote:  
> 
> [...]
> 
> >> > In regards of the .go files remaining in the build directory, I agree
> >> > that this is not good, however I don't think it is worth trying to fix
> >> > this issue which equally applies to every file generated by Make.  Using
> >> > wildcards can be tempting in such cases but it can lead to accidental
> >> > file deletions which is worse IMO.  As a consequence I would prefer
> >> > keeping the current 'clean-go' rule.    
> >> 
> >> I sympathize with that.  
> >
> > How about simply printing  a warning if there are any .go files laying
> > around after a `make clean` or `make clean-go`?  
> 
> Sure, why not.

So, with the attached patch, I get the following output after `make
clean-go`:

warning: stray .go files: ./guix/scripts/import/cpan.go ./gnu/services/dmd.go
./gnu/system/linux.go ./gnu/packages/yasm.go ./gnu/packages/cursynth.go 
./gnu/packages/lightning.go ./gnu/packages/doxygen.go ./gnu/packages/tre.go 
./gnu/packages/asciidoc.go ./gnu/packages/texlive.go ./gnu/packages/i3.go 
./gnu/packages/fish.go ./gnu/packages/slim.go ./gnu/packages/tcsh.go 
./gnu/packages/zsh.go ./gnu/packages/lsh.go ./gnu/packages/rc.go 
./gnu/packages/openssl.go ./gnu/packages/aria2.go ./gnu/packages/gdbm.go 
./gnu/packages/gnutls.go ./gnu/packages/grue-hunter.go ./gnu/packages/aarddict.go

Maybe this means that I've not been doing due diligence in keeping my
builddir clean, or maybe its just the result of developing on guix for
so long.

Another issue that I thought of that's posed by these stray .go files,
which isn't only a problem when acting as a wizard: introducing a new
module import when adding a package, only to have that module
moved/renamed before pushing your change.  I suppose it is a corner
case, but it did happen to me recently, in 2e3f18511, which 宋文武
kindly fixed in 19b2ea1b6. The problem was that between the time I
originally packaged tomb and the time I pushed the commit,
gnu/packages/zsh.scm was consolidated into gnu/packages/shells.scm.  I
had done a `make clean-go && make` before pushing, as I always do, but
since clean-go didn't remove gnu/packages/zsh.go the subsequent `make`
didn't complain of a missing module.

`~Eric
Leo Famulari - Sept. 16, 2016, 6 a.m.
On Fri, Sep 16, 2016 at 12:15:40AM -0500, Eric Bavier wrote:
> Another issue that I thought of that's posed by these stray .go files,
> which isn't only a problem when acting as a wizard: introducing a new
> module import when adding a package, only to have that module
> moved/renamed before pushing your change.  I suppose it is a corner
> case, but it did happen to me recently, in 2e3f18511, which 宋文武
> kindly fixed in 19b2ea1b6. The problem was that between the time I
> originally packaged tomb and the time I pushed the commit,
> gnu/packages/zsh.scm was consolidated into gnu/packages/shells.scm.  I
> had done a `make clean-go && make` before pushing, as I always do, but
> since clean-go didn't remove gnu/packages/zsh.go the subsequent `make`
> didn't complain of a missing module.

I accidentally did this to myself in c41d97bed6 (gnu: mupdf: Update to
1.9a.).
Ludovic Courtès - Sept. 20, 2016, 5:20 a.m.
Hi,

Eric Bavier <ericbavier@openmailbox.org> skribis:

> So, with the attached patch, I get the following output after `make
> clean-go`:
>
> warning: stray .go files: ./guix/scripts/import/cpan.go ./gnu/services/dmd.go
> ./gnu/system/linux.go ./gnu/packages/yasm.go ./gnu/packages/cursynth.go 
> ./gnu/packages/lightning.go ./gnu/packages/doxygen.go ./gnu/packages/tre.go 
> ./gnu/packages/asciidoc.go ./gnu/packages/texlive.go ./gnu/packages/i3.go 
> ./gnu/packages/fish.go ./gnu/packages/slim.go ./gnu/packages/tcsh.go 
> ./gnu/packages/zsh.go ./gnu/packages/lsh.go ./gnu/packages/rc.go 
> ./gnu/packages/openssl.go ./gnu/packages/aria2.go ./gnu/packages/gdbm.go 
> ./gnu/packages/gnutls.go ./gnu/packages/grue-hunter.go ./gnu/packages/aarddict.go

Looks good, surely an improvement!

> Another issue that I thought of that's posed by these stray .go files,
> which isn't only a problem when acting as a wizard: introducing a new
> module import when adding a package, only to have that module
> moved/renamed before pushing your change.  I suppose it is a corner
> case, but it did happen to me recently, in 2e3f18511, which 宋文武
> kindly fixed in 19b2ea1b6. The problem was that between the time I
> originally packaged tomb and the time I pushed the commit,
> gnu/packages/zsh.scm was consolidated into gnu/packages/shells.scm.  I
> had done a `make clean-go && make` before pushing, as I always do, but
> since clean-go didn't remove gnu/packages/zsh.go the subsequent `make`
> didn't complain of a missing module.

Indeed, that’s happened to me before.

> From ffe1710d5a91cd9906f2419d21944b1375b1b842 Mon Sep 17 00:00:00 2001
> From: Eric Bavier <bavier@member.fsf.org>
> Date: Thu, 15 Sep 2016 23:31:41 -0500
> Subject: [PATCH] build: clean-go: warn about stray .go files.
>
> * Makefile.am (clean-go): Warn of .go files remaining in builddir.

LGTM, thank you!

Ludo’.

Patch

From ffe1710d5a91cd9906f2419d21944b1375b1b842 Mon Sep 17 00:00:00 2001
From: Eric Bavier <bavier@member.fsf.org>
Date: Thu, 15 Sep 2016 23:31:41 -0500
Subject: [PATCH] build: clean-go: warn about stray .go files.

* Makefile.am (clean-go): Warn of .go files remaining in builddir.
---
 Makefile.am | 6 ++++++
 1 file changed, 6 insertions(+)

diff --git a/Makefile.am b/Makefile.am
index f9fe141..43a33c8 100644
--- a/Makefile.am
+++ b/Makefile.am
@@ -208,6 +208,12 @@  endif INSTALL_SRFI_37
 # Handy way to remove the .go files without removing all the rest.
 clean-go:
 	-$(RM) -f $(GOBJECTS)
+	@find . -name '*.go' -print | \
+	  if test -t 1; then \
+	    xargs -r echo -e "\033[31mwarning:\033[0m stray .go files:"; \
+	  else \
+	    xargs -r echo "warning: stray .go files:"; \
+	  fi
 
 
 # Test extensions; has to be unconditional.
-- 
2.9.2