blob: fd056357d635cedb56a3cf4d70778090c32df816 [file] [log] [blame] [edit]
#!/bin/bash
# Copyright 2020 The Skywater PDK Authors
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# https://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
set -e
set -u
filter_out=".git"
# filter out slashes - they indicate lack of extension
# awk with a dot delimiter, uniq prints count as well, last awk to trim whitespace
find $1 -type f | grep -Ev $filter_out | awk -F . '{print $NF}' | sort | grep -v "/" | uniq -c | awk '{print $1,$2}' | sort -nr > files-with-extensions
echo "Files with extensions: `awk '{s+=$1} END {print s}' files-with-extensions`"
# all files, also without extensions, so the first awk cuts away the directory name
find $1 -type f | grep -Ev $filter_out | awk -F '/' '{print $NF}' | awk -F . '{print $NF}' | sort | uniq -c | awk '{print $1,$2}' | sort -nr > all-files
echo "All files: `awk '{s+=$1} END {print s}' all-files`"
# find all files without extensions
for i in `find $1 -type f ! -name "*.*" | grep -Ev $filter_out`; do echo $(basename $i); done | sort | uniq -ic | awk '{print $1,$2}' | sort -nr > no-extensions
# find missing extensions
./missing.py files-with-extensions exts-from-spreadsheet > missing_exts
echo "Files with extensions not mentioned in the spreadsheet: `awk '{s+=$1} END {print s}' missing_exts`"
echo "Missing extensions: `cat missing_exts | wc -l`"
rm -f missing_exts_with_names
while read p <&3
do
n=0
files=""
ext=`echo $p | cut -f2 -d\ `
echo $p
while read f <&4
do
n=$((n+1))
files="$files $f"
done 4< <(find $1 -type f -name *.$ext)
if (( n < 7 ))
then
echo "$p: $files" >> missing_exts_with_names
else
echo "$p" >> missing_exts_with_names
fi
done 3< missing_exts
echo "After looking for names: `awk '{s+=$1} END {print s}' missing_exts_with_names`"