Root/fpd2pdf/fpdoc

1#!/usr/bin/perl
2#
3# fpdoc - Generate a PDF with the footprints used in a specific project
4#
5# Written 2011 by Werner Almesberger
6# Copyright 2011 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
15sub usage
16{
17    print STDERR "usage: $0 [-a module ...] pro-file pdf-file\n\n";
18    print STDERR " -a module add the specified module\n";
19    exit(1);
20}
21
22
23while ($ARGV[0] eq "-a") {
24    shift(@ARGV);
25    &usage unless @ARGV;
26    $need{shift @ARGV} = 1;
27}
28
29&usage if $ARGV[0] =~ /^-/;
30&usage unless @ARGV == 2;
31
32$pro = $ARGV[0];
33$out = $ARGV[1];
34
35($base = $pro) =~ s|\.pro$||;
36
37$pos = "${base}Front.pos";
38$cmp = "$base.cmp";
39
40my $on = 0;
41open(FILE, $pro) || die "$pro: $!";
42while (<FILE>) {
43    chop;
44    if (m|^\[pcbnew/libraries\]|) {
45        $on = 1;
46        next;
47    }
48    $on = 0 if /^\[/;
49    next unless $on;
50    next unless /LibName\d+=/;
51    my $mod = "$'.mod";
52    my $fpd = "$'.fpd";
53    open(MOD, $mod) || die "$mod: $!";
54    while (<MOD>) {
55        chop;
56        next unless /^\$MODULE\s+/;
57        $fpd{$'} = $fpd;
58    }
59    close MOD;
60}
61close FILE;
62
63push(@INC, split(":", $ENV{"PATH"}));
64do "pos2fab" || die "pos2fab: $!";
65
66#
67# We iterate over the items in the .pos file so that we skip NC and virtual
68# components.
69#
70
71for (@order) {
72    $need{$fp{$_}} = 1 if defined $fp{$_};
73}
74
75for (keys %need) {
76    die "don't have $_" unless defined $fpd{$_};
77}
78
79exec "fpd2pdf", "-o", $out, map { "$fpd{$_}:$_" } sort keys %need;
80

Archive Download this file

Branches:
master



interactive