mirror of
git://projects.qi-hardware.com/kicad-libs.git
synced 2024-11-16 21:30:16 +02:00
108 lines
1.7 KiB
Bash
Executable File
108 lines
1.7 KiB
Bash
Executable File
#!/bin/sh -e
|
|
#
|
|
# missing-in-tree - List items present in libraries but not in the tree
|
|
#
|
|
# Copyright 2012, 2014 by Werner Almesberger
|
|
#
|
|
# This program is free software; you can redistribute it and/or modify
|
|
# it under the terms of the GNU General Public License as published by
|
|
# the Free Software Foundation; either version 2 of the License, or
|
|
# (at your option) any later version.
|
|
#
|
|
|
|
|
|
usage()
|
|
{
|
|
echo "usage: $0 [-F] [-x lib ...] [-L libdir ...] [-l lib ...] hierarchy" 1>&2
|
|
echo " $0 -Q [-x lib ...] [-L libdir ...] [-l lib ...] project.pro" 1>&2
|
|
exit 1
|
|
}
|
|
|
|
|
|
excluded()
|
|
{
|
|
[ "`eval echo \\\$exclude_\`sanitize \"$1\"\``" ]
|
|
}
|
|
|
|
|
|
scan_comp()
|
|
{
|
|
for n in "$@"; do
|
|
excluded "$n" && continue
|
|
sed '/^DEF ~\?/{s///;s/ .*//;p;};d' <$n >>_tmp2
|
|
done
|
|
}
|
|
|
|
|
|
scan_fped()
|
|
{
|
|
for n in "$@"; do
|
|
excluded "$n" && continue
|
|
fped -k $n - | sed '/^\$MODULE /s///p;d' >>_tmp2
|
|
done
|
|
}
|
|
|
|
|
|
scan_pro()
|
|
{
|
|
for n in `sed '/^LibName[0-9]*=\.\/\(.*\)/s//\1/p;d' $1`; do
|
|
sed '/^DEF ~\?/{s///;s/ .*//;p;};d' <$n.lib
|
|
done
|
|
}
|
|
|
|
|
|
sanitize()
|
|
{
|
|
basename "$1" .$ext | tr -d '\n' | tr -c 'A-Za-z0-9_[-]' _
|
|
}
|
|
|
|
|
|
trap "rm -f _tmp1 _tmp2" 0
|
|
|
|
if [ "$1" = -Q ]; then
|
|
pro=true
|
|
shift
|
|
else
|
|
genkicat -D "$@" >_tmp1 || exit
|
|
pro=false
|
|
fi
|
|
|
|
ext=lib
|
|
|
|
>_tmp2
|
|
while [ "$1" ]; do
|
|
case "$1" in
|
|
-F) ext=fpd;;
|
|
-L) shift
|
|
if [ "`echo \"$1\"/*.$ext`" != "$1/*.$ext" ]; then
|
|
if [ $ext = lib ]; then
|
|
scan_comp "$1"/*.$ext
|
|
else
|
|
scan_fped "$1"/*.$ext
|
|
fi
|
|
fi;;
|
|
-l) shift
|
|
if [ $ext = lib ]; then
|
|
scan_comp "$1"
|
|
else
|
|
scan_fped "$1"
|
|
fi;;
|
|
-x) shift
|
|
eval exclude_`sanitize "$1"`=y;;
|
|
-*) usage;;
|
|
*) break;;
|
|
esac
|
|
shift
|
|
done
|
|
|
|
[ "$1" ] || usage
|
|
[ -z "$2" ] || usage
|
|
|
|
if $pro; then
|
|
scan_pro "$1" >_tmp1
|
|
fi
|
|
|
|
cat _tmp1 _tmp1 _tmp2 | sort | uniq -u
|
|
|
|
exit 0
|