[dpdk-dev,v2] tools: add tags and cscope index file generation support

Message ID 1484642507-15952-1-git-send-email-jerin.jacob@caviumnetworks.com (mailing list archive)
State Superseded, archived
Delegated to: Thomas Monjalon
Headers

Checks

Context Check Description
ci/checkpatch success coding style OK
ci/Intel compilation success Compilation OK

Commit Message

Jerin Jacob Jan. 17, 2017, 8:41 a.m. UTC
  This script generates cscope, gtags, and tags
index files based on EAL environment.
(architecture and OS(linux/bsd))

Selection of the architecture and OS environment
is based on dpdk configuration target(T=)

example usage:
make tags T=x86_64-native-linuxapp-gcc
make cscope T=x86_64-native-linuxapp-gcc
make gtags T=x86_64-native-linuxapp-gcc

Signed-off-by: Jerin Jacob <jerin.jacob@caviumnetworks.com>
Reviewed-by: Yuanhan Liu <yuanhan.liu@linux.intel.com>
Reviewed-by: Ferruh Yigit <ferruh.yigit@intel.com>
---
v2:

1) Moved tag.sh to devtools from scripts
2) Rebased to master

---
 .gitignore        |   8 ++
 devtools/tags.sh  | 251 ++++++++++++++++++++++++++++++++++++++++++++++++++++++
 mk/rte.sdkroot.mk |   4 +
 3 files changed, 263 insertions(+)
 create mode 100755 devtools/tags.sh
  

Comments

Thomas Monjalon Feb. 27, 2017, 2:18 p.m. UTC | #1
2017-01-17 14:11, Jerin Jacob:
> This script generates cscope, gtags, and tags
> index files based on EAL environment.
> (architecture and OS(linux/bsd))
> 
> Selection of the architecture and OS environment
> is based on dpdk configuration target(T=)

What is the purpose of selecting a configuration?
Is it to go quicker in the implementation you are interested in?
In that case, I think we need a catch-all option, because I like
being prompted by vim that several implementations exist and I can
choose one of them.

> example usage:
> make tags T=x86_64-native-linuxapp-gcc
> make cscope T=x86_64-native-linuxapp-gcc
> make gtags T=x86_64-native-linuxapp-gcc
> 
> Signed-off-by: Jerin Jacob <jerin.jacob@caviumnetworks.com>
> Reviewed-by: Yuanhan Liu <yuanhan.liu@linux.intel.com>
> Reviewed-by: Ferruh Yigit <ferruh.yigit@intel.com>
[...]
>  .gitignore        |   8 ++
>  devtools/tags.sh  | 251 ++++++++++++++++++++++++++++++++++++++++++++++++++++++
>  mk/rte.sdkroot.mk |   4 +
>  3 files changed, 263 insertions(+)

I think build-tags.sh would be a better name.

On the implementation, I have few comments:
	- is there a way to re-use the skip list when including the related files?
	- you can remove tile from this patch
And for the details:
	- why a bash shebang where /bin/sh would be wider?
	- verbose option should be -v (with getopts)
	- please use $() instead of backquotes
	- please avoid one-line functions used only once like doctags

I can help you with this script if needed.
  
Jerin Jacob Feb. 28, 2017, 2:12 p.m. UTC | #2
On Mon, Feb 27, 2017 at 03:18:52PM +0100, Thomas Monjalon wrote:
> 2017-01-17 14:11, Jerin Jacob:
> > This script generates cscope, gtags, and tags
> > index files based on EAL environment.
> > (architecture and OS(linux/bsd))
> > 
> > Selection of the architecture and OS environment
> > is based on dpdk configuration target(T=)
> 
> What is the purpose of selecting a configuration?
> Is it to go quicker in the implementation you are interested in?

Yes. That is the hard part to do.

> In that case, I think we need a catch-all option, because I like
> being prompted by vim that several implementations exist and I can
> choose one of them.

OK. Then we can make T= as optional and if T= is not specified then script can
take all the source files. Thoughts?

> 
> > example usage:
> > make tags T=x86_64-native-linuxapp-gcc
> > make cscope T=x86_64-native-linuxapp-gcc
> > make gtags T=x86_64-native-linuxapp-gcc
> > 
> > Signed-off-by: Jerin Jacob <jerin.jacob@caviumnetworks.com>
> > Reviewed-by: Yuanhan Liu <yuanhan.liu@linux.intel.com>
> > Reviewed-by: Ferruh Yigit <ferruh.yigit@intel.com>
> [...]
> >  .gitignore        |   8 ++
> >  devtools/tags.sh  | 251 ++++++++++++++++++++++++++++++++++++++++++++++++++++++
> >  mk/rte.sdkroot.mk |   4 +
> >  3 files changed, 263 insertions(+)
> 
> I think build-tags.sh would be a better name.

OK

> 
> On the implementation, I have few comments:
> 	- is there a way to re-use the skip list when including the related files?
> 	- you can remove tile from this patch

OK

> And for the details:
> 	- why a bash shebang where /bin/sh would be wider?

I will change to /bin/sh

> 	- verbose option should be -v (with getopts)

OK

> 	- please use $() instead of backquotes

OK

> 	- please avoid one-line functions used only once like doctags

OK

> 
> I can help you with this script if needed.

OK. I can work on this next week, if you have time then feel free to
take up this.

>
  
Thomas Monjalon March 1, 2017, 10:51 a.m. UTC | #3
2017-02-28 19:42, Jerin Jacob:
> On Mon, Feb 27, 2017 at 03:18:52PM +0100, Thomas Monjalon wrote:
> > 2017-01-17 14:11, Jerin Jacob:
> > > This script generates cscope, gtags, and tags
> > > index files based on EAL environment.
> > > (architecture and OS(linux/bsd))
> > > 
> > > Selection of the architecture and OS environment
> > > is based on dpdk configuration target(T=)
> > 
> > What is the purpose of selecting a configuration?
> > Is it to go quicker in the implementation you are interested in?
> 
> Yes. That is the hard part to do.
> 
> > In that case, I think we need a catch-all option, because I like
> > being prompted by vim that several implementations exist and I can
> > choose one of them.
> 
> OK. Then we can make T= as optional and if T= is not specified then script can
> take all the source files. Thoughts?

OK

> > I can help you with this script if needed.
> 
> OK. I can work on this next week, if you have time then feel free to
> take up this.

I have no time this week.
But do not hesitate to ping me when doing the v2 if you feel I can help.
  

Patch

diff --git a/.gitignore b/.gitignore
index a722abe..76bcae2 100644
--- a/.gitignore
+++ b/.gitignore
@@ -1 +1,9 @@ 
 doc/guides/nics/overview_table.txt
+cscope.out.po
+cscope.out.in
+cscope.out
+cscope.files
+GTAGS
+GPATH
+GRTAGS
+tags
diff --git a/devtools/tags.sh b/devtools/tags.sh
new file mode 100755
index 0000000..82c1a2a
--- /dev/null
+++ b/devtools/tags.sh
@@ -0,0 +1,251 @@ 
+#!/bin/bash
+# Generate tags or gtags or cscope files
+# Usage tags.sh <mode> T=<target> [VERBOSE=1]
+# set -x
+
+verbose=false
+linuxapp=false
+bsdapp=false
+x86_64=false
+arm=false
+arm64=false
+ia_32=false
+ppc_64=false
+tile=false
+
+if [ "$VERBOSE" = "1" ]; then
+	verbose=true
+fi
+
+#ignore version control files
+ignore="( -name .svn -o -name CVS -o -name .hg -o -name .git ) -prune -o"
+
+source_dirs="app buildtools drivers examples lib"
+
+skip_bsd="( -name bsdapp ) -prune -o"
+skip_linux="( -name linuxapp ) -prune -o"
+skip_arch="( -name arch ) -prune -o"
+skip_sse="( -name *_sse*.[chS] ) -prune -o"
+skip_avx="( -name *_avx*.[chS] ) -prune -o"
+skip_neon="( -name *_neon*.[chS] ) -prune -o"
+skip_altivec="( -name *_altivec*.[chS] ) -prune -o"
+skip_arm64="( -name *arm64*.[chS] ) -prune -o"
+skip_x86="( -name *x86*.[chS] ) -prune -o"
+skip_32b_files="( -name *_32.h ) -prune -o"
+skip_64b_files="( -name *_64.h ) -prune -o"
+
+skiplist="${skip_bsd} ${skip_linux} ${skip_arch} ${skip_sse} ${skip_avx} \
+		 ${skip_neon} ${skip_altivec} ${skip_x86} ${skip_arm64}"
+
+find_sources()
+{
+	find $1 $ignore $3 -name $2 -not -type l -print
+}
+
+common_sources()
+{
+	find_sources "${source_dirs}" '*.[chS]' "$skiplist"
+}
+
+linuxapp_sources()
+{
+	find_sources "lib/librte_eal/linuxapp" '*.[chS]'
+}
+
+bsdapp_sources()
+{
+	find_sources "lib/librte_eal/bsdapp" '*.[chS]'
+}
+
+arm_common()
+{
+	find_sources "lib/librte_eal/common/arch/arm" '*.[chS]'
+	find_sources "${source_dirs}" '*neon*.[chS]'
+}
+
+arm_sources()
+{
+	arm_common
+	find_sources "lib/librte_eal/common/include/arch/arm" '*.[chS]' \
+					"$skip_64b_files"
+}
+
+arm64_sources()
+{
+	arm_common
+	find_sources "lib/librte_eal/common/include/arch/arm" '*.[chS]' \
+					 "$skip_32b_files"
+	find_sources "${source_dirs}" '*arm64.[chS]'
+}
+
+ia_common()
+{
+	find_sources "lib/librte_eal/common/arch/x86" '*.[chS]'
+
+	find_sources "examples/performance-thread/common/arch/x86" '*.[chS]'
+	find_sources "${source_dirs}" '*_sse*.[chS]'
+	find_sources "${source_dirs}" '*_avx*.[chS]'
+	find_sources "${source_dirs}" '*x86.[chS]'
+}
+
+i686_sources()
+{
+	ia_common
+	find_sources "lib/librte_eal/common/include/arch/x86" '*.[chS]' \
+					"$skip_64b_files"
+}
+
+x86_64_sources()
+{
+	ia_common
+	find_sources "lib/librte_eal/common/include/arch/x86" '*.[chS]' \
+					"$skip_32b_files"
+}
+
+ppc64_sources()
+{
+	find_sources "lib/librte_eal/common/arch/ppc_64" '*.[chS]'
+	find_sources "lib/librte_eal/common/include/arch/ppc_64" '*.[chS]'
+	find_sources "${source_dirs}" '*altivec*.[chS]'
+}
+
+tile_sources()
+{
+	find_sources "lib/librte_eal/common/arch/tile" '*.[chS]'
+	find_sources "lib/librte_eal/common/include/arch/tile" '*.[chS]'
+}
+
+config_file()
+{
+	if [ -f $RTE_OUTPUT/include/rte_config.h ]; then
+		ls $RTE_OUTPUT/include/rte_config.h
+	fi
+}
+
+usage()
+{
+	if [ "$1" = 'tags' ] ; then
+		echo "Generate tags file for editors"
+	fi
+	if [ "$1" = 'cscope' ] ; then
+		echo "Generate cscope index"
+	fi
+	if [ "$1" = 'gtags' ] ; then
+		echo "Generate GNU GLOBAL index"
+	fi
+	echo "Usage: make tags|cscope|gtags T=<target> [VERBOSE=1]"
+	echo "Valid targets are:"
+	make showconfigs | sed 's,^,\t,'
+}
+
+check_valid_config()
+{
+	cfgfound=false
+	allconfigs=`make showconfigs`
+	for cfg in $allconfigs
+	do
+		if [ "$cfg" = "$1" ] ; then
+			cfgfound=true
+		fi
+	done
+	$cfgfound || echo "Invalid config: $1"
+	$cfgfound || usage $2
+	$cfgfound || exit 0
+}
+
+if [ -n "$T" ]; then
+	check_valid_config $T $1
+
+	if [ `echo $T | grep -c "linuxapp-" ` -gt 0 ]; then
+		linuxapp=true
+	fi
+
+	if [ `echo $T | grep -c "bsdapp-" ` -gt 0 ]; then
+		bsdapp=true
+	fi
+
+	if [ `echo $T | grep -c "x86_64-" ` -gt 0  ]; then
+		x86_64=true
+	fi
+
+	if [ `echo $T | grep -c "i686-" ` -gt 0 ]; then
+		ia_32=true
+	fi
+
+	if [ `echo $T | grep -c "x32-" ` -gt 0 ]; then
+		ia_32=true
+	fi
+
+	if [ `echo $T | grep -c "arm-" ` -gt 0 ]; then
+		arm=true
+	fi
+
+	if [ `echo $T | grep -c "arm64-" ` -gt 0 ]; then
+		arm64=true
+	fi
+
+	if [ `echo $T | grep -c "ppc_64-" ` -gt 0 ]; then
+		ppc_64=true
+	fi
+
+	if [ `echo $T | grep -c "tile-" ` -gt 0 ]; then
+		tile=true
+	fi
+
+	$verbose && echo "linuxapp: $linuxapp"
+	$verbose && echo "bsdapp:   $bsdapp"
+	$verbose && echo "ia_32:    $ia_32"
+	$verbose && echo "x86_64:   $x86_64"
+	$verbose && echo "arm:      $arm"
+	$verbose && echo "arm64:    $arm64"
+	$verbose && echo "ppc_64:   $ppc_64"
+	$verbose && echo "tile:     $tile"
+	$verbose && echo "build:    $RTE_OUTPUT"
+else
+	usage $1
+	exit
+fi
+
+all_sources()
+{
+	common_sources
+	$linuxapp && linuxapp_sources
+	$bsdapp && bsdapp_sources
+	$x86_64 && x86_64_sources
+	$ia_32 && i686_sources
+	$arm && arm_sources
+	$arm64 && arm64_sources
+	$ppc_64 && ppc64_sources
+	$tile && tile_sources
+	config_file
+}
+
+docscope()
+{
+	all_sources > cscope.files
+	cscope -q -b -f cscope.out
+}
+
+dogtags()
+{
+	all_sources | gtags -i -f -
+}
+
+doctags()
+{
+	all_sources | xargs ctags -a
+}
+
+case "$1" in
+	"cscope")
+		docscope
+		;;
+
+	"gtags")
+		dogtags
+		;;
+	"tags")
+		rm -f tags
+		doctags
+		;;
+esac
diff --git a/mk/rte.sdkroot.mk b/mk/rte.sdkroot.mk
index 04ad523..5802644 100644
--- a/mk/rte.sdkroot.mk
+++ b/mk/rte.sdkroot.mk
@@ -92,6 +92,10 @@  default: all
 config showconfigs showversion showversionum:
 	$(Q)$(MAKE) -f $(RTE_SDK)/mk/rte.sdkconfig.mk $@
 
+.PHONY: cscope gtags tags
+cscope gtags tags:
+	$(Q)$(RTE_SDK)/devtools/tags.sh $@
+
 .PHONY: test fast_test ring_test mempool_test perf_test coverage
 test fast_test ring_test mempool_test perf_test coverage:
 	$(Q)$(MAKE) -f $(RTE_SDK)/mk/rte.sdktest.mk $@