1 ;;; gEDA - GPL Electronic Design Automation
2 ;;; gnetlist - gEDA Netlist
3 ;;; Copyright (C) 1998-2010 Ales Hvezda
4 ;;; Copyright (C) 1998-2010 gEDA Contributors (see ChangeLog for details)
6 ;;; This program is free software; you can redistribute it and/or modify
7 ;;; it under the terms of the GNU General Public License as published by
8 ;;; the Free Software Foundation; either version 2 of the License, or
9 ;;; (at your option) any later version.
11 ;;; This program is distributed in the hope that it will be useful,
12 ;;; but WITHOUT ANY WARRANTY; without even the implied warranty of
13 ;;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 ;;; GNU General Public License for more details.
16 ;;; You should have received a copy of the GNU General Public License
17 ;;; along with this program; if not, write to the Free Software
18 ;;; Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
21 ;; --------------------------------------------------------------------------
23 ;; Bill of Material backend written by Matt Ettus starts here
26 ;;; Bill Of Materials Generator
27 ;;; You must have a file called attribs in the pwd
28 ;;; The file should be a text list of attributes you want listed,
29 ;;; One per line. No comments are allowed in the file.
30 ;;; Questions? Contact matt@ettus.com
31 ;;; This software is released under the terms of the GNU GPL
33 (use-modules (ice-9 rdelim)) ;; guile-1.8 fix
36 (lambda (output-filename)
37 (let ((port (if (string=? "-" output-filename)
39 (open-output-file output-filename)))
40 (attriblist (bom:parseconfig (open-input-file "attribs"))))
41 (bom:printlist (cons 'refdes attriblist) port)
42 (bom:components port packages attriblist)
43 (close-output-port port))))
50 (display (car ls) port)
51 (write-char #\tab port)
52 (bom:printlist (cdr ls) port)))))
54 ; Parses attrib file. Returns a list of read attributes.
55 (define bom:parseconfig
57 (let ((read-from-file (read-delimited " \n\t" port)))
58 (cond ((eof-object? read-from-file)
60 ((= 0 (string-length read-from-file))
61 (bom:parseconfig port))
63 (cons read-from-file (bom:parseconfig port)))))))
65 (define bom:components
66 (lambda (port ls attriblist)
68 (let ((package (car ls)))
69 (if (not (string=? "1" (gnetlist:get-package-attribute package "nobom")))
71 (display package port)
72 (write-char #\tab port)
73 (bom:printlist (bom:find-attribs package attriblist) port)))
74 (bom:components port (cdr ls) attriblist)))))
76 (define bom:find-attribs
77 (lambda (package attriblist)
78 (if (null? attriblist)
80 (cons (gnetlist:get-package-attribute package (car attriblist))
81 (bom:find-attribs package (cdr attriblist))))))
84 ;; Bill of Material backend written by Matt Ettus ends here
86 ;; --------------------------------------------------------------------------