mirror of
git://projects.qi-hardware.com/eda-tools.git
synced 2024-11-29 10:57:12 +02:00
New script sanitize-schem to remove subsheets for which no file can be found.
- schhist/sanitize-schem: remove inaccssible schematics sub-sheets - schhist/gitsch2ps (usage, "main"): -S runs sanitize-schem in addition to sanitize-profile - schhist/schhist2web (usage): -S now also sanitizes the top-level sheet
This commit is contained in:
parent
b94f1b27a4
commit
75a4ea8869
@ -18,20 +18,25 @@ usage()
|
|||||||
usage: $0 [options] top-dir top-schem [commit] outdir
|
usage: $0 [options] top-dir top-schem [commit] outdir
|
||||||
|
|
||||||
-k keep the temporary directory and print its name
|
-k keep the temporary directory and print its name
|
||||||
-S sanitize the KiCad profile
|
-S sanitize the KiCad profile and the top-level sheet
|
||||||
EOF
|
EOF
|
||||||
exit 1
|
exit 1
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
sanitize=true
|
sanitize_profile=true
|
||||||
|
sanitize_schem=true
|
||||||
keep=false
|
keep=false
|
||||||
while true; do
|
while true; do
|
||||||
case "$1" in
|
case "$1" in
|
||||||
-k) keep=true
|
-k) keep=true
|
||||||
shift;;
|
shift;;
|
||||||
-S) sanitize=`PATH="$PATH":\`dirname "$0"\` which sanitize-profile`
|
-S) sanitize_profile=`PATH="$PATH":\`dirname "$0"\` which sanitize-profile`
|
||||||
[ "$sanitize" = "${sanitize#/}" ] && sanitize=`pwd`/"$sanitize"
|
[ "$sanitize_profile" = "${sanitize_profile#/}" ] &&
|
||||||
|
sanitize_profile=`pwd`/"$sanitize_profile"
|
||||||
|
sanitize_schem=`PATH="$PATH":\`dirname "$0"\` which sanitize-schem`
|
||||||
|
[ "$sanitize_schem" = "${sanitize_schem#/}" ] &&
|
||||||
|
sanitize_schem=`pwd`/"$sanitize_schem"
|
||||||
shift;;
|
shift;;
|
||||||
-*)
|
-*)
|
||||||
usage;;
|
usage;;
|
||||||
@ -74,8 +79,8 @@ fi
|
|||||||
(
|
(
|
||||||
cd "$sch" || exit
|
cd "$sch" || exit
|
||||||
rm -f *.ps
|
rm -f *.ps
|
||||||
$sanitize "$tmp/${schem%.sch}.pro" ||
|
$sanitize_profile "$tmp/${schem%.sch}.pro" || exit
|
||||||
exit
|
$sanitize_schem "$tmp/$schem" || exit
|
||||||
eeschema --plot "$tmp/$schem"
|
eeschema --plot "$tmp/$schem"
|
||||||
) || exit
|
) || exit
|
||||||
|
|
||||||
|
61
schhist/sanitize-schem
Executable file
61
schhist/sanitize-schem
Executable file
@ -0,0 +1,61 @@
|
|||||||
|
#!/usr/bin/perl
|
||||||
|
#
|
||||||
|
# sanitize-schem - Remove items from KiCad schematics that may cause an upset
|
||||||
|
#
|
||||||
|
# Written 2010 by Werner Almesberger
|
||||||
|
# Copyright 2010 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.
|
||||||
|
#
|
||||||
|
|
||||||
|
|
||||||
|
sub usage
|
||||||
|
{
|
||||||
|
print STDERR "usage: $0 file.sch [outfile]\n";
|
||||||
|
exit(1);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
($file, $out) = @ARGV;
|
||||||
|
&usage if $#ARGV > 1;
|
||||||
|
|
||||||
|
($dir = $file) =~ s|.*/||;
|
||||||
|
$dir = "." if $dir eq "";
|
||||||
|
|
||||||
|
open(FILE, $file) || die "$file: $!";
|
||||||
|
while (<FILE>) {
|
||||||
|
if (/^\$Sheet/) {
|
||||||
|
$s = $_;
|
||||||
|
$discard = 1;
|
||||||
|
next;
|
||||||
|
}
|
||||||
|
if (/^\$EndSheet/) {
|
||||||
|
push(@f, $s.$_) unless $discard;
|
||||||
|
undef $s;
|
||||||
|
next;
|
||||||
|
}
|
||||||
|
if (!defined $s) {
|
||||||
|
push(@f, $_);
|
||||||
|
next;
|
||||||
|
}
|
||||||
|
$s .= $_;
|
||||||
|
next unless /^F1 "([^"]*)"/;
|
||||||
|
if (-r "$1" || -r "$dir/$1") {
|
||||||
|
$discard = 0;
|
||||||
|
next;
|
||||||
|
}
|
||||||
|
print STDERR "removing $1\n";
|
||||||
|
}
|
||||||
|
close FILE;
|
||||||
|
|
||||||
|
if (!defined $out) {
|
||||||
|
rename($file, "$file.bak");
|
||||||
|
$out= $file;
|
||||||
|
}
|
||||||
|
|
||||||
|
open(FILE, ">$out") || die "$out: $!";
|
||||||
|
print FILE join("", @f) || die "$out: $!";
|
||||||
|
close FILE || die "$out: $!";
|
@ -118,7 +118,7 @@ usage: $0 [-c cache-dir] [-f] [-n] [-S] [top-dir] [top-schem] [out-dir]
|
|||||||
-c cache-dir cache directory (default: same as out-dir)
|
-c cache-dir cache directory (default: same as out-dir)
|
||||||
-f identify sheets by their file name, not the sheet name
|
-f identify sheets by their file name, not the sheet name
|
||||||
-n don't use previous cache content (rebuild the cache)
|
-n don't use previous cache content (rebuild the cache)
|
||||||
-S sanitize KiCad profile
|
-S sanitize KiCad profile and top-level sheet
|
||||||
EOF
|
EOF
|
||||||
exit 1
|
exit 1
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user