xref: /aosp_15_r20/external/webrtc/rtc_tools/class_usage.sh (revision d9f758449e529ab9291ac668be2861e7a55c2422)
1*d9f75844SAndroid Build Coastguard Worker#!/bin/bash
2*d9f75844SAndroid Build Coastguard Worker
3*d9f75844SAndroid Build Coastguard Worker# Copyright (c) 2017 The WebRTC project authors. All Rights Reserved.
4*d9f75844SAndroid Build Coastguard Worker#
5*d9f75844SAndroid Build Coastguard Worker# Use of this source code is governed by a BSD-style license
6*d9f75844SAndroid Build Coastguard Worker# that can be found in the LICENSE file in the root of the source
7*d9f75844SAndroid Build Coastguard Worker# tree. An additional intellectual property rights grant can be found
8*d9f75844SAndroid Build Coastguard Worker# in the file PATENTS.  All contributing project authors may
9*d9f75844SAndroid Build Coastguard Worker# be found in the AUTHORS file in the root of the source tree.
10*d9f75844SAndroid Build Coastguard Worker
11*d9f75844SAndroid Build Coastguard Worker# This script is run in a git repository. It lists all classes defined
12*d9f75844SAndroid Build Coastguard Worker# in header files, sorted by the number of other files where the name
13*d9f75844SAndroid Build Coastguard Worker# of the class occurs. It is intentionally not limited to only source
14*d9f75844SAndroid Build Coastguard Worker# files. Classes close to the top of the list are candidates for
15*d9f75844SAndroid Build Coastguard Worker# removal.
16*d9f75844SAndroid Build Coastguard Worker
17*d9f75844SAndroid Build Coastguard Workergit grep -h '^class .*[:{]' -- '*.h' '*.hpp' \
18*d9f75844SAndroid Build Coastguard Worker  | sed -e 's/WEBRTC_DLL_EXPORT// ' -e 's/^class *\([^ :{(<]*\).*/\1/' \
19*d9f75844SAndroid Build Coastguard Worker  | sort | uniq | while read class ; do
20*d9f75844SAndroid Build Coastguard Worker  count="$(git grep -l -w -F "${class}" | wc -l)"
21*d9f75844SAndroid Build Coastguard Worker  echo "${count}" "${class}"
22*d9f75844SAndroid Build Coastguard Workerdone | sort -n
23