Date:2010-08-28 01:42:40 (8 years 10 months ago)
Author:Werner Almesberger
Commit:2921bcea47bc9926587d60469c8bbd2e02d906a8
Message:New script sanitize-profile to remove glitches from a KiCad profile.

- scripts/sanitize-profile: remove upsetting items from a KiCad profile
- scripts/gitsch2ppm: option -S to enable sanitizing of profiles
- scripts/schhist2web: pass option -S to gitsch2ppm
- scripts/Makefile (xue-schhist): invoke schhist2web with option -S
Files: scripts/Makefile (1 diff)
scripts/gitsch2ppm (4 diffs)
scripts/sanitize-profile (1 diff)
scripts/schhist2web (3 diffs)

Change Details

scripts/Makefile
2424    SCHHIST_TITLE=Xue \
2525      SCHHIST_HOME_URL=http://projects.qi-hardware.com/index.php/p/xue/ \
2626      SCHHIST_COMMIT_TEMPLATE='http://projects.qi-hardware.com/index.php/p/xue/source/commit/{}/' \
27      ./schhist2web ../../xue kicad/xue-rnc/xue-rnc.sch _xue
27      ./schhist2web -S ../../xue kicad/xue-rnc/xue-rnc.sch _xue
2828
2929xue-schhist-upload:
3030     rsync -a --progress _xue/{index.html,unchanged.png,thum*,diff*} \
scripts/gitsch2ppm
4343  -c use cached Postscript files (from previous run, with -k)
4444  -k keep checked-out tree (for immediate reuse with -c)
4545  -r XxY image resolution (default: $RES)
46  -S sanitize the KiCad profile
4647  -w points Postscript line width (default: $LINEWIDTH)
4748EOF
4849    exit 1
...... 
5152
5253cache=false
5354keep=false
55sanitize=true
5456while true; do
5557    case "$1" in
5658    -c) cache=true
...... 
6062    -r) [ -z "$2" ] && usage
6163    RES="$2"
6264    shift 2;;
65    -S) sanitize=`PATH="$PATH":\`dirname "$0"\` which sanitize-profile`
66    [ "$sanitize" = "${sanitize#/}" ] && sanitize=`pwd`/"$sanitize"
67    shift;;
6368    -w) [ -z "$2" ] && usage
6469    LINEWIDTH="$2"
6570    shift 2;;
...... 
102107        exit 1
103108    fi
104109
105    ( cd "$sch" && rm -f *.ps *.ppm && eeschema --plot "$tmp/$schem"; ) || exit
110    (
111    cd "$sch" || exit
112    rm -f *.ps *.ppm
113    $sanitize "$tmp"/`dirname "$schem"`/`basename "$schem" .sch`.pro ||
114      exit
115    eeschema --plot "$tmp/$schem"
116    ) || exit
106117fi
107118
108119for n in "$sch"/*.ps; do
scripts/sanitize-profile
1#!/usr/bin/perl
2#
3# sanitize-profile - Remove items from a KiCad profile that may cause an upset
4#
5# Written 2010 by Werner Almesberger
6# Copyright 2010 Werner Almesberger
7#
8# This program is free software; you can redistribute it and/or modify
9# it under the terms of the GNU General Public License as published by
10# the Free Software Foundation; either version 2 of the License, or
11# (at your option) any later version.
12#
13
14
15@LIBS = ("/usr/share/kicad/library", "/usr/local/share/kicad/library");
16
17
18sub rewrite
19{
20    local ($s) = @_;
21
22    return $s if $section ne "eeschema/libraries";
23    return $s unless /^LibName(\d+)=(.*)\s*$/;
24    my $lib = $2;
25    if ($1 == $in_lib) {
26    $in_lib++;
27    } else {
28    print STDERR "LibName$1 when expecting $next_lib. Renumbering.";
29    $in_lib = $1+1;
30    }
31    $out_lib++;
32    my $var = "LibName$out_lib";
33    if ($lib =~ /\//) {
34    return "$var=$lib\n" if -r "$lib.lib";
35    }
36    for (".", $libdir, @LIBS) {
37    return "$var=$lib\n" if -r "$_/$lib.lib";
38    }
39    print STDERR "cannot find $lib\n";
40    $out_lib--;
41    return undef;
42}
43
44
45sub usage
46{
47    print STDERR "usage: $0 file.pro [outfile]\n";
48    exit(1);
49}
50
51
52($file, $out) = @ARGV;
53&usage if $#ARGV > 1;
54
55($dir = $file) =~ s|.*/||;
56$dir = "." if $dir eq "";
57
58open(FILE, $file) || die "$file: $!";
59while (<FILE>) {
60    if (/^\[(\S+)\]/) {
61    $section = $1;
62    if ($section eq "eeschema/libraries") {
63        $in_lib = 1;
64        $out_lib = 0;
65    }
66    }
67    if ($section eq "eeschema") {
68    $libdir = $2 if /^LibDir=(.*)\s*$/;
69    }
70    $s = &rewrite($_);
71    push(@f, $s) if defined $s;
72}
73close FILE;
74
75if (!defined $out) {
76    rename($file, "$file.bak");
77    $out= $file;
78}
79
80open(FILE, ">$out") || die "$out: $!";
81print FILE join("", @f) || die "$out: $!";
82close FILE || die "$out: $!";
scripts/schhist2web
4343usage()
4444{
4545    cat <<EOF 2>&1
46usage: $0 [-c cache-dir] [-n] [top-dir] [top-schem] [out-dir]
46usage: $0 [-c cache-dir] [-n] [-S] [top-dir] [top-schem] [out-dir]
4747
4848  top-dir top-level directory of the git archive (default: locate it)
4949  top-schem root sheet of the schematics (default: locate it in top-dir)
5050  out-dir output directory (default: $OUTDIR)
51  -n don't use previous cache content (rebuild the cache)
5251  -c cache-dir cache directory (default: same as out-dir)
52  -n don't use previous cache content (rebuild the cache)
53  -S sanitize KiCad profile
5354EOF
5455    exit 1
5556}
5657
5758
5859no_cache=false
60sanitize=
61
5962while true; do
6063    case "$1" in
6164    -n) no_cache=true
...... 
6366    -c) [ -z "$1" ] && usage
6467    cache="$1"
6568    shift 2;;
69    -S) sanitize=-S
70    shift;;
6671    -*) usage;;
6772    *) break;;
6873    esac
...... 
136141    if [ ! -d "$cache/ppm_$n" ]; then
137142    rm -rf "$cache/ppm_$n"
138143    mkdir "$cache/ppm_$n"
139    gitsch2ppm -k "$dir" "$schname" $n "$cache/ppm_$n" || exit
144    gitsch2ppm $sanitize -k "$dir" "$schname" $n "$cache/ppm_$n" || exit
140145    gitsch2ppm -c -w 500 "$dir" "$schname" $n "$cache/fat_$n" || exit
141146    fi
142147    for m in "$cache/ppm_$n/"*; do

Archive Download the corresponding diff file



interactive