dpdk/buildtools/map-list-symbol.sh
<<
>>
Prefs
   1#!/bin/sh
   2# SPDX-License-Identifier: BSD-3-Clause
   3# Copyright(c) 2018 David Marchand <david.marchand@redhat.com>
   4
   5section=all
   6symbol=all
   7quiet=
   8
   9while getopts 'S:s:q' name; do
  10        case $name in
  11        S)
  12                [ $section = 'all' ] || {
  13                        echo 'Cannot list in multiple sections'
  14                        exit 1
  15                }
  16                section=$OPTARG
  17        ;;
  18        s)
  19                [ $symbol = 'all' ] || {
  20                        echo 'Cannot list multiple symbols'
  21                        exit 1
  22                }
  23                symbol=$OPTARG
  24        ;;
  25        q)
  26                quiet='y'
  27        ;;
  28        ?)
  29                echo 'usage: $0 [-S section] [-s symbol] [-q]'
  30                exit 1
  31        ;;
  32        esac
  33done
  34
  35shift $(($OPTIND - 1))
  36
  37for file in $@; do
  38        cat "$file" |awk '
  39        BEGIN {
  40                current_section = "";
  41                if ("'$section'" == "all" && "'$symbol'" == "all") {
  42                        ret = 0;
  43                } else {
  44                        ret = 1;
  45                }
  46        }
  47        /^.*\{/ {
  48                if ("'$section'" == "all" || $1 == "'$section'") {
  49                        current_section = $1;
  50                }
  51        }
  52        /.*}/ { current_section = ""; }
  53        /^[^}].*[^:*];/ {
  54                if (current_section != "") {
  55                        gsub(";","");
  56                        if ("'$symbol'" == "all" || $1 == "'$symbol'") {
  57                                ret = 0;
  58                                if ("'$quiet'" == "") {
  59                                        print "'$file' "current_section" "$1;
  60                                }
  61                                if ("'$symbol'" != "all") {
  62                                        exit 0;
  63                                }
  64                        }
  65                }
  66        }
  67        END {
  68                exit ret;
  69        }'
  70done
  71