Root/scripts/missing-in-tree

Source at commit e5970e73cbc50930422cd26d5f817540f67bda20 created 6 years 11 days ago.
By Werner Almesberger, modules/msl0104.fpd: Rohm MSL0104 RGB LED
1#!/bin/sh -e
2#
3# missing-in-tree - List items present in libraries but not in the tree
4#
5# Copyright 2012, 2014 by Werner Almesberger
6#
7# This program is free software; you can redistribute it and/or modify
8# it under the terms of the GNU General Public License as published by
9# the Free Software Foundation; either version 2 of the License, or
10# (at your option) any later version.
11#
12
13
14usage()
15{
16    echo "usage: $0 [-F] [-x lib ...] [-L libdir ...] [-l lib ...] hierarchy" 1>&2
17    echo " $0 -Q [-x lib ...] [-L libdir ...] [-l lib ...] project.pro" 1>&2
18    exit 1
19}
20
21
22excluded()
23{
24    [ "`eval echo \\\$exclude_\`sanitize \"$1\"\``" ]
25}
26
27
28scan_comp()
29{
30    for n in "$@"; do
31        excluded "$n" && continue
32        sed '/^DEF ~\?/{s///;s/ .*//;p;};d' <$n >>_tmp2
33    done
34}
35
36
37scan_fped()
38{
39    for n in "$@"; do
40        excluded "$n" && continue
41        fped -k $n - | sed '/^\$MODULE /s///p;d' >>_tmp2
42    done
43}
44
45
46scan_pro()
47{
48    for n in `sed '/^LibName[0-9]*=\.\/\(.*\)/s//\1/p;d' $1`; do
49        sed '/^DEF ~\?/{s///;s/ .*//;p;};d' <$n.lib
50    done
51}
52
53
54sanitize()
55{
56    basename "$1" .$ext | tr -d '\n' | tr -c 'A-Za-z0-9_[-]' _
57}
58
59
60trap "rm -f _tmp1 _tmp2" 0
61
62if [ "$1" = -Q ]; then
63    pro=true
64    shift
65else
66    genkicat -D "$@" >_tmp1 || exit
67    pro=false
68fi
69
70ext=lib
71
72>_tmp2
73while [ "$1" ]; do
74    case "$1" in
75    -F) ext=fpd;;
76    -L) shift
77        if [ "`echo \"$1\"/*.$ext`" != "$1/*.$ext" ]; then
78            if [ $ext = lib ]; then
79                scan_comp "$1"/*.$ext
80            else
81                scan_fped "$1"/*.$ext
82            fi
83        fi;;
84    -l) shift
85        if [ $ext = lib ]; then
86            scan_comp "$1"
87        else
88            scan_fped "$1"
89        fi;;
90    -x) shift
91        eval exclude_`sanitize "$1"`=y;;
92    -*) usage;;
93    *) break;;
94    esac
95    shift
96done
97
98[ "$1" ] || usage
99[ -z "$2" ] || usage
100
101if $pro; then
102    scan_pro "$1" >_tmp1
103fi
104
105cat _tmp1 _tmp1 _tmp2 | sort | uniq -u
106
107exit 0
108

Archive Download this file

Branches:
master



interactive