Loading...
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 | #!/bin/sh -e
# Generate tags or gtags or cscope or etags files
#
# BSD LICENSE
#
# Copyright 2017 Cavium, Inc
#
# Redistribution and use in source and binary forms, with or without
# modification, are permitted provided that the following conditions
# are met:
#
# * Redistributions of source code must retain the above copyright
# notice, this list of conditions and the following disclaimer.
# * Redistributions in binary form must reproduce the above copyright
# notice, this list of conditions and the following disclaimer in
# the documentation and/or other materials provided with the
# distribution.
# * Neither the name of Cavium, Inc nor the names of its
# contributors may be used to endorse or promote products derived
# from this software without specific prior written permission.
#
# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
# "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
# LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
# A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
# OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
# SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
# LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
# DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
# THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
# (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
# OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
verbose=false
linux=true
bsd=true
x86_32=true
x86_64=true
ppc_64=true
arm_32=true
arm_64=true
print_usage()
{
echo "Usage: $(basename $0) [-h] [-v] tags|cscope|gtags|etags [config]"
echo "Valid configs are:"
make showconfigs | sed 's,^,\t,'
}
# Move to the root of the git tree
cd $(dirname $0)/..
while getopts hv ARG ; do
case $ARG in
v ) verbose=true ;;
h ) print_usage; exit 0 ;;
? ) print_usage; exit 1 ;;
esac
done
shift $(($OPTIND - 1))
#ignore version control files
ignore="( -name .svn -o -name CVS -o -name .hg -o -name .git ) -prune -o"
source_dirs="test 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"
}
linux_sources()
{
find_sources "lib/librte_eal/linuxapp" '*.[chS]'
}
bsd_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_32_sources()
{
arm_common
find_sources "lib/librte_eal/common/include/arch/arm" '*.[chS]' \
"$skip_64b_files"
}
arm_64_sources()
{
arm_common
find_sources "lib/librte_eal/common/include/arch/arm" '*.[chS]' \
"$skip_32b_files"
find_sources "$source_dirs" '*arm64.[chS]'
}
x86_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]'
}
x86_32_sources()
{
x86_common
find_sources "lib/librte_eal/common/include/arch/x86" '*.[chS]' \
"$skip_64b_files"
}
x86_64_sources()
{
x86_common
find_sources "lib/librte_eal/common/include/arch/x86" '*.[chS]' \
"$skip_32b_files"
}
ppc_64_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]'
}
check_valid_target()
{
cfgfound=false
allconfigs=$(make showconfigs)
for cfg in $allconfigs ; do
if [ "$cfg" = "$1" ] ; then
cfgfound=true
fi
done
if ! $cfgfound ; then
echo "Invalid config: $1"
print_usage
exit 0
fi
}
if [ -n "$2" ]; then
check_valid_target $2
echo $2 | grep -q "linuxapp-" || linux=false
echo $2 | grep -q "bsdapp-" || bsd=false
echo $2 | grep -q "x86_64-" || x86_64=false
echo $2 | grep -q "arm-" || arm_32=false
echo $2 | grep -q "arm64-" || arm_64=false
echo $2 | grep -q "ppc_64-" || ppc_64=false
echo $2 | grep -q -e "i686-" -e "x32-" || x86_32=false
fi
all_sources()
{
common_sources
if $linux ; then linux_sources ; fi
if $bsd ; then bsd_sources ; fi
if $x86_64 ; then x86_64_sources ; fi
if $x86_32 ; then x86_32_sources ; fi
if $ppc_64 ; then ppc_64_sources ; fi
if $arm_32 ; then arm_32_sources ; fi
if $arm_64 ; then arm_64_sources ; fi
}
show_flags()
{
if $verbose ; then
echo "mode: $1"
echo "config: $2"
echo "linux: $linux"
echo "bsd: $bsd"
echo "x86_32: $x86_32"
echo "x86_64: $x86_64"
echo "ppc_64: $ppc_64"
echo "arm_32: $arm_32"
echo "arm_64: $arm_64"
fi
}
case "$1" in
"cscope")
show_flags $1 $2
all_sources > cscope.files
cscope -q -b -f cscope.out
;;
"gtags")
show_flags $1 $2
all_sources | gtags -i -f -
;;
"tags")
show_flags $1 $2
rm -f tags
all_sources | xargs ctags -a
;;
"etags")
show_flags $1 $2
rm -f TAGS
all_sources | xargs etags -a
;;
*)
echo "Invalid mode: $1"
print_usage
;;
esac
|