Skip to contentSkip to conversation

build: use xargs in conjunction with etags

RFC In review Horms 2 participants 6 messages Jun 23, 2006 – Jun 27, 2006

lore
Share & tools
lore

Horms

author
#0 lore raw

RFC 1/1 build: use xargs in conjunction with etags

The existing etags invocation does not seem to work for me, but using xargs in the same way that it is used for crats does. I'm pretty sure that is because on Debian etags == ctags, does anyone have etags lying around to test if this works?

Also, I'm pretty sure this xargs approach will break for both ctags and etags if there are too many files to for one command line, as ctags/etags will be invoked multiple times, and the resulting tags file will only contain the tags for the last invocation.

xen/Makefile +1 -1
@@ -132,7 +136,7 @@ endef
 
 .PHONY: _TAGS
 _TAGS: 
-	$(all_sources) | etags -
+	$(all_sources) | xargs etags
 
 .PHONY: _tags
 _tags: 
 xen/Makefile |    2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
xen/Makefile +1 -1
@@ -132,7 +136,7 @@ endef
 
 .PHONY: _TAGS
 _TAGS: 
-	$(all_sources) | etags -
+	$(all_sources) | xargs etags
 
 .PHONY: _tags
 _tags: 
#1 lore raw
Quoted 14 lines · Horms

The existing etags invocation does not seem to work for me, but using xargs in the same way that it is used for crats does. I'm pretty sure that is because on Debian etags == ctags, does anyone have etags lying around to test if this works?

Also, I'm pretty sure this xargs approach will break for both ctags and etags if there are too many files to for one command line, as ctags/etags will be invoked multiple times, and the resulting tags file will only contain the tags for the last invocation.

xen/Makefile endef · line 139

Quoted 5 lines
xen/Makefile +1 -1
@@ -132,7 +136,7 @@ endef
 
 .PHONY: _TAGS
 _TAGS: 
-	$(all_sources) | etags -
+	$(all_sources) | xargs etags

When xargs invokes etags more than once (i.e. it's actually needed), each invocation will clobber the output of the previous one. To run etags on an arbitrarily long file list, try something like

    rm -f TAGS && $(all_sources) | xargs etags -a
author
#2 lore raw
Quoted 17 lines · Markus Armbruster
Quoted 15 lines · Horms

The existing etags invocation does not seem to work for me, but using xargs in the same way that it is used for crats does. I'm pretty sure that is because on Debian etags == ctags, does anyone have etags lying around to test if this works?

Also, I'm pretty sure this xargs approach will break for both ctags and etags if there are too many files to for one command line, as ctags/etags will be invoked multiple times, and the resulting tags file will only contain the tags for the last invocation.

xen/Makefile +0 -0
@@ -132,7 +136,7 @@ endef
 
Quoted 7 lines

xen/Makefile endef · line 139

Quoted 4 lines
xen/Makefile +1 -1
 .PHONY: _TAGS
 _TAGS: 
-	$(all_sources) | etags -
+	$(all_sources) | xargs etags

When xargs invokes etags more than once (i.e. it's actually needed), each invocation will clobber the output of the previous one.

Indeed, I was concerned about that.

Quoted 4 lines

To run
etags on an arbitrarily long file list, try something like

    rm -f TAGS && $(all_sources) | xargs etags -a

Is the rm -f TAGS neccessary?

I believe that for ctags the following will work. At least it seems to work just fine here with exuberant-ctags 5.5.4

	$(all_sources) | xargs ctags -L -

Can you (or anyone who has etags) see if this approach works for etags as well. The reason that I ask is that it would be nice to have a command line that works for etags and ctags, as on Debian at least etags is ctags (though I am not sure how wise that is).

Signature · 2 lines
Horms                                           
H: http://www.vergenet.net/~horms/          W: http://www.valinux.co.jp/en/
author
#3 lore raw
Quoted 26 lines · Horms
Quoted 17 lines · Markus Armbruster
Quoted 15 lines · Horms

The existing etags invocation does not seem to work for me, but using xargs in the same way that it is used for crats does. I'm pretty sure that is because on Debian etags == ctags, does anyone have etags lying around to test if this works?

Also, I'm pretty sure this xargs approach will break for both ctags and etags if there are too many files to for one command line, as ctags/etags will be invoked multiple times, and the resulting tags file will only contain the tags for the last invocation.

xen/Makefile +0 -0
@@ -132,7 +136,7 @@ endef
 
Quoted 7 lines

xen/Makefile endef · line 139

Quoted 4 lines
xen/Makefile +1 -1
 .PHONY: _TAGS
 _TAGS: 
-	$(all_sources) | etags -
+	$(all_sources) | xargs etags

When xargs invokes etags more than once (i.e. it's actually needed), each invocation will clobber the output of the previous one.

Quoted 8 lines

Indeed, I was concerned about that.

Quoted 4 lines

To run
etags on an arbitrarily long file list, try something like

    rm -f TAGS && $(all_sources) | xargs etags -a

Is the rm -f TAGS neccessary?

On further investigation I see that the answer is yes as -a is append.

Quoted 4 lines

I believe that for ctags the following will work. At least it seems to work just fine here with exuberant-ctags 5.5.4

	$(all_sources) | xargs ctags -L -

The above line should not include xargs

        $(all_sources) | ctags -L -

But it turns out that ctags can use the same syntax as ctags

        rm -f tags && $(all_sources) | xargs ctags -a

I will send a patch that has ctags and etags use -a, I believe this will also work on Debian where ctags is the etags binary (I tested it and it seems fine, as when invoked as etags the code produces a TAGS file, and when invoked as ctags it produces a tags file).

Signature · 2 lines
Horms                                           
H: http://www.vergenet.net/~horms/          W: http://www.valinux.co.jp/en/
author
#4 lore raw
In reply to Horms

[ Sorry if this is a duplicate, I had a problem with my mail client
and I'm not sure where the previous incarntation went ]

Quoted 26 lines · In article <[email protected]> you wrote:
Quoted 17 lines · Markus Armbruster
Quoted 15 lines · Horms

The existing etags invocation does not seem to work for me, but using xargs in the same way that it is used for crats does. I'm pretty sure that is because on Debian etags == ctags, does anyone have etags lying around to test if this works?

Also, I'm pretty sure this xargs approach will break for both ctags and etags if there are too many files to for one command line, as ctags/etags will be invoked multiple times, and the resulting tags file will only contain the tags for the last invocation.

xen/Makefile +0 -0
@@ -132,7 +136,7 @@ endef
 
Quoted 7 lines

xen/Makefile endef · line 139

Quoted 4 lines
xen/Makefile +1 -1
 .PHONY: _TAGS
 _TAGS: 
-	$(all_sources) | etags -
+	$(all_sources) | xargs etags

When xargs invokes etags more than once (i.e. it's actually needed), each invocation will clobber the output of the previous one.

Quoted 8 lines

Indeed, I was concerned about that.

Quoted 4 lines

To run
etags on an arbitrarily long file list, try something like

    rm -f TAGS && $(all_sources) | xargs etags -a

Is the rm -f TAGS neccessary?

On further research I see that -a means append, so yes the rm is neccessary.

Quoted 4 lines

I believe that for ctags the following will work. At least it seems to work just fine here with exuberant-ctags 5.5.4

	$(all_sources) | xargs ctags -L -

For the record, xargs should not be present in the above command line

	$(all_sources) | ctags -L -

However, the same syntax as etags can also be used, which is nice for uniformity

	rm -f tags && $(all_sources) | xargs ctags -a

I will post a patch that uses the -a approach for both etags and ctags. This should work for pretty much all systems. In particular I tested debian, where ctags and etags are the same binary, and this approach works because a TAGS file is produced when the binary is invoked as etags, and a tags file is produced when the binary is invoked as etags.

Signature · 2 lines
Horms                                           
H: http://www.vergenet.net/~horms/          W: http://www.valinux.co.jp/en/
author
#5 lore raw

PATCH 1/1 Unifiy the usage of etags and ctags.

In reply to Horms

Both ctags and etags support the -a (append) option, and by removing the tags or TAGS file, and then running using the -a option in conjunction with xargs a full list of tags will be obtained, regardless of how many files there are.

I believe that the existing invocations of both etags and ctags are wrong:

* I don't think - is a vailid argument to etags

* xargs ctags does not handle the case where ctags is invoked multiple times by xargs when there are too many files to fit on one command line.

 xen/Makefile |    4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)
xen/Makefile +2 -2
@@ -136,11 +136,11 @@ endef
 
 .PHONY: _TAGS
 _TAGS: 
-	$(all_sources) | etags -
+	rm -f TAGS && $(all_sources) | xargs etags -a
 
 .PHONY: _tags
 _tags: 
-	$(all_sources) | xargs ctags
+	rm -f TAGS && $(all_sources) | xargs ctags -a
 
 .PHONY: _cscope
 _cscope: