[dpdk-dev] [PATCH v5] devtools: add tags and cscope index file generation support

Thomas Monjalon thomas at monjalon.net
Fri Apr 28 10:50:20 CEST 2017


Hi,
I have some comments about behaviour, naming and coding style.

22/03/2017 09:30, Jerin Jacob:
> +verbose=false
> +linuxapp=false
> +bsdapp=false

linuxapp/bsdapp could be renamed to simpler linux/bsd.

> +x86_64=false
> +arm=false

Why not arm32 for consistency?

> +arm64=false
> +ia_32=false

ia_32 should be x86_32

> +ppc_64=false

[...]
> +	make showconfigs | sed 's,^,\t,'

This is assuming the working dir is the dpdk root.
It is assumed elsewhere in the script.
I suggest adding "cd $(dirname $0)/.." at the beginning of the script.

[...]
> +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]'
> +}

Same comment about arm32 consistency.

> +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"
> +}

... and here x86/x86_32 instead of ia/i686


> +config_file()
> +{
> +	if [ -f $RTE_SDK/$RTE_TARGET/include/rte_config.h ]; then
> +		ls $RTE_SDK/$RTE_TARGET/include/rte_config.h
> +	fi
> +}

RTE_TARGET is used to define the build directory.
It will not be defined in this script and it does not really
make sense to enforce it.
I suggest to remove rte_config.h from this script.
Other argument: you can have several build directories
with different configs.

[...]
> +check_valid_config()

It is not a config but a target.
Yes the target is checked against existing config template names.

> +{
> +	cfgfound=false
> +	allconfigs=$(make showconfigs)
> +	for cfg in $allconfigs
> +	do

This "do" keyword could be on the previous line, like you did for if...then.

> +		if [ "$cfg" = "$1" ] ; then
> +			cfgfound=true
> +		fi
> +	done
> +	$cfgfound || echo "Invalid config: $1"
> +	$cfgfound || print_usage
> +	$cfgfound || exit 0

Better to use an "if" block here.

[...]
> +	if [ $(echo $2 | grep -c "linuxapp-") -gt 0 ]; then
> +		linuxapp=true
> +	fi

More compact grep:
	if echo $2 | grep -q "linuxapp-" ; then

[...]
> +else
> +	linuxapp=true
> +	bsdapp=true
> +	x86_64=true
> +	arm=true
> +	arm64=true
> +	ia_32=true
> +	ppc_64=true
> +fi

You could define them as true by default.
So the above grep would become:
	echo $2 | grep -q "linuxapp-" || linux=false

[...]
> +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

I am a bit surprised by these constructs.
When using sh -e, we should not have a false statement.
I think it should be:
	if $linuxapp ; then linuxapp_sources ; fi

[...]
> +show_flags()
> +{
> +	$verbose && echo "mode:     $1"
> +	$verbose && echo "config:   $2"
> +	$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"

Please use an "if" block here.

> +++ b/mk/rte.sdkroot.mk
> +.PHONY: cscope gtags tags etags
> +cscope gtags tags etags:
> +ifdef T
> +	$(Q)$(RTE_SDK)/devtools/build-tags.sh $@ ${T}
> +else
> +	$(Q)$(RTE_SDK)/devtools/build-tags.sh $@
> +endif

No need of ifdef.

Thanks Jerin


More information about the dev mailing list