move to use of shared scheme library
authorBdale Garbee <bdale@gag.com>
Tue, 15 Jan 2013 18:36:53 +0000 (11:36 -0700)
committerBdale Garbee <bdale@gag.com>
Tue, 15 Jan 2013 18:36:53 +0000 (11:36 -0700)
Makefile
scheme/gnet-partslist-bom.scm [deleted file]
scheme/gnet-partslist-csv.scm [deleted file]
scheme/gnet-partslistgag.scm [deleted file]

index 8f25ca48ecffbc7806372168ead021d83d7715d5..9e57c753aa8f2704ed637e5ac76739f546b07ddf 100644 (file)
--- a/Makefile
+++ b/Makefile
@@ -19,17 +19,17 @@ partslist:  teleterra.sch
        rm -f teleterra.unsorted
 
 partslist.csv: teleterra.sch Makefile
-       gnetlist -m scheme/gnet-partslistgag.scm -g partslistgag \
+       gnetlist -L ../altusmetrum/scheme -g partslistgag \
                -o teleterra.unsorted teleterra.sch
        head -n1 teleterra.unsorted > partslist.csv
        tail -n+2 teleterra.unsorted | sort -t \, -k 8 >> partslist.csv
        rm -f teleterra.unsorted
 
 partslist.dk:  $(PROJECT).sch Makefile scheme/gnet-partslist-bom.scm
-       gnetlist -m scheme/gnet-partslist-bom.scm -g partslist-bom -Ovendor=digikey -o $@ $(PROJECT).sch
+       gnetlist -L ../altusmetrum/scheme -g partslist-bom -Ovendor=digikey -o $@ $(PROJECT).sch
 
 partslist.mouser:      $(PROJECT).sch Makefile scheme/gnet-partslist-bom.scm
-       gnetlist -m scheme/gnet-partslist-bom.scm -g partslist-bom -Ovendor=mouser -o $@ $(PROJECT).sch
+       gnetlist -L ../altusmetrum/scheme -g partslist-bom -Ovendor=mouser -o $@ $(PROJECT).sch
 
 pcb:   teleterra.sch project
        gsch2pcb project
diff --git a/scheme/gnet-partslist-bom.scm b/scheme/gnet-partslist-bom.scm
deleted file mode 100644 (file)
index dd90ea0..0000000
+++ /dev/null
@@ -1,118 +0,0 @@
-; Copyright © 2012 Keith Packard <keithp@keithp.com>
-; gnet-partslist-bom.scm
-; 
-; 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.
-; 
-; This program is distributed in the hope that it will be useful,
-; but WITHOUT ANY WARRANTY; without even the implied warranty of
-; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
-; GNU General Public License for more details.
-; 
-; You should have received a copy of the GNU General Public License
-; along with this program; if not, write to the Free Software
-; Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
-
-; The /'s may not work on win32
-(load (string-append gedadata "/scheme/gnet-partslist-common.scm"))
-
-(define (caddddddr s)
-  (car (cdr (cdr (cdr (cdr (cdr (cdr s))))))))
-
-(define (cadddddr s)
-  (car (cdr (cdr (cdr (cdr (cdr s)))))))
-
-(define (caddddr s)
-  (car (cdr (cdr (cdr (cdr s))))))
-
-(define multiplier 1)
-
-(define (partslist-bom:write-part s port)
-  (let ((quantity (caddddddr s))
-       (part (cadddddr s))
-       (device (cadr s))
-       (value (caddr s)))
-    (display (* multiplier quantity) port)
-    (display "," port)
-    (display part port)
-    (display "," port)
-    (display device port)
-    (display " " port)
-    (display value port)
-    (display "\n" port)))
-
-(define (partslist-bom:write-partslist ls port)
-  (if (null? ls)
-      '()
-      (begin (partslist-bom:write-part (car ls) port)
-            (partslist-bom:write-partslist (cdr ls) port))))
-
-(define (count-same-parts ls)
-  (if (null? ls)
-      (append ls)
-      (let* ((parts-table-no-uref (let ((result '()))
-                                   (for-each (lambda (l) (set! result (cons (cdr l) result))) (reverse ls))
-                                   (append result)))
-            (first-ls (car parts-table-no-uref))
-            (match-length (length (member first-ls (reverse parts-table-no-uref))))
-            (rest-ls (list-tail ls match-length))
-            (match-ls (list-tail (reverse ls) (- (length ls) match-length)))
-            (uref-ls (let ((result '()))
-                       (for-each (lambda (l) (set! result (cons (car l) result))) match-ls)
-                       (append result))))
-       (cons (cons uref-ls (append first-ls  (list match-length))) (count-same-parts rest-ls)))))
-
-(define get-vendor
-   (lambda (package)
-      (gnetlist:get-package-attribute package "vendor")))
-
-(define get-vendor-part-number
-   (lambda (package)
-      (gnetlist:get-package-attribute package "vendor_part_number")))
-
-(define get-footprint
-   (lambda (package)
-      (gnetlist:get-package-attribute package "footprint")))
-
-(define (get-parts-table-bom packages vendor)
-  (if (null? packages)
-      '()
-      (let ((package (car packages)))
-       (if (string=? (get-vendor package) vendor)
-           (if (string=? (get-device package) "include")
-               (get-parts-table-bom (cdr packages) vendor)
-               (cons (list package
-                           (get-device package)
-                           (get-value package)
-                           (get-footprint package)
-                           (get-vendor package)
-                           (get-vendor-part-number package)) ;; sdb change
-                     (get-parts-table-bom (cdr packages) vendor)))
-           (get-parts-table-bom (cdr packages) vendor)))))
-
-(define (get-opt-helper option list)
-  (if list
-      (let ((param (car list)))
-       (if (string-prefix? option (car param))
-           (string-drop (car param) (string-length option))
-           (get-opt-helper option (cdr list))))
-      nil)
-  )
-
-(define (get-opt option default)
-  (let ((opt (get-opt-helper (string-append option "=") (gnetlist:get-calling-flags))))
-    (if opt
-       opt
-       default)))
-
-(define (get-vendor-match)
-  (get-opt "vendor" "digikey"))
-
-(define (partslist-bom output-filename)
-  (let ((port (open-output-file output-filename))
-       (parts-table (marge-sort-with-multikey (get-parts-table-bom packages (get-vendor-match)) '(1 2 3 0))))
-    (set! parts-table (count-same-parts parts-table))
-    (partslist-bom:write-partslist parts-table port)
-    (close-output-port port)))
diff --git a/scheme/gnet-partslist-csv.scm b/scheme/gnet-partslist-csv.scm
deleted file mode 100644 (file)
index 291bb0a..0000000
+++ /dev/null
@@ -1,86 +0,0 @@
-; Copyright (C) 2001-2010 MIYAMOTO Takanori
-; gnet-partslist-csv.scm
-; 
-; 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.
-; 
-; This program is distributed in the hope that it will be useful,
-; but WITHOUT ANY WARRANTY; without even the implied warranty of
-; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
-; GNU General Public License for more details.
-; 
-; You should have received a copy of the GNU General Public License
-; along with this program; if not, write to the Free Software
-; Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
-
-; The /'s may not work on win32
-(load (string-append gedadata "/scheme/gnet-partslist-common.scm"))
-
-(define partslist-csv:write-top-header
-  (lambda (port)
-    (display "device,value,footprint,vendor,vendor_part_number,quantity,refdes\n" port)))
-
-(define (partslist-csv:write-partslist ls port)
-  (if (null? ls)
-      '()
-      (begin (write-one-row (cdar ls) "," "," port)
-            (write-one-row (caar ls) " " "\n" port)
-            (partslist-csv:write-partslist (cdr ls) port))))
-
-(define (count-same-parts ls)
-  (if (null? ls)
-      (append ls)
-      (let* ((parts-table-no-uref (let ((result '()))
-                                   (for-each (lambda (l) (set! result (cons (cdr l) result))) (reverse ls))
-                                   (append result)))
-            (first-ls (car parts-table-no-uref))
-            (match-length (length (member first-ls (reverse parts-table-no-uref))))
-            (rest-ls (list-tail ls match-length))
-            (match-ls (list-tail (reverse ls) (- (length ls) match-length)))
-            (uref-ls (let ((result '()))
-                       (for-each (lambda (l) (set! result (cons (car l) result))) match-ls)
-                       (append result))))
-       (cons (cons uref-ls (append first-ls  (list match-length))) (count-same-parts rest-ls)))))
-
-(define get-vendor
-   (lambda (package)
-      (gnetlist:get-package-attribute package "vendor")))
-
-(define get-vendor-part-number
-   (lambda (package)
-      (gnetlist:get-package-attribute package "vendor_part_number")))
-
-(define get-footprint
-   (lambda (package)
-      (gnetlist:get-package-attribute package "footprint")))
-
-(define get-loadstatus
-  (lambda (package)
-    (gnetlist:get-package-attribute package "loadstatus")))
-
-(define (get-parts-table-csv packages)
-  (if (null? packages)
-      '()
-      (let ((package (car packages)))
-       (if (string=? (get-device package) "include")
-           (get-parts-table-csv (cdr packages))
-           (if (string=? (get-loadstatus package) "smt")
-               (cons (list package
-                           (get-device package)
-                           (get-value package)
-                           (get-footprint package)
-                           (get-vendor package)
-                           (get-vendor-part-number package)) ;; sdb change
-                     (get-parts-table-csv (cdr packages)))
-               (get-parts-table-csv (cdr packages)))))))
-
-(define partslist-csv
-  (lambda (output-filename)
-    (let ((port (open-output-file output-filename))
-         (parts-table (marge-sort-with-multikey (get-parts-table-csv packages) '(1 2 3 0))))
-      (set! parts-table (count-same-parts parts-table))
-      (partslist-csv:write-top-header port)
-      (partslist-csv:write-partslist parts-table port)
-      (close-output-port port))))
diff --git a/scheme/gnet-partslistgag.scm b/scheme/gnet-partslistgag.scm
deleted file mode 100644 (file)
index 01b71e3..0000000
+++ /dev/null
@@ -1,140 +0,0 @@
-; Copyright 2009 by Bdale Garbee <bdale@gag.com>
-; gnet-partslistgag.scm
-;
-; derived from gnet-partslist3.scm 
-; Copyright (C) 2001 MIYAMOTO Takanori
-; 
-; 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.
-; 
-; This program is distributed in the hope that it will be useful,
-; but WITHOUT ANY WARRANTY; without even the implied warranty of
-; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
-; GNU General Public License for more details.
-; 
-; You should have received a copy of the GNU General Public License
-; along with this program; if not, write to the Free Software
-; Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111 USA
-
-; The /'s may not work on win32
-
-; Copyright (C) 2001 MIYAMOTO Takanori
-; gnet-partslist-common.scm
-; 
-; 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.
-; 
-; This program is distributed in the hope that it will be useful,
-; but WITHOUT ANY WARRANTY; without even the implied warranty of
-; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
-; GNU General Public License for more details.
-; 
-; You should have received a copy of the GNU General Public License
-; along with this program; if not, write to the Free Software
-; Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111 USA
-
-(define (get-parts-table packages)
-  (if (null? packages)
-      '()
-      (let ((package (car packages)))
-       (if (string=? "1" (gnetlist:get-package-attribute package "nobom"))
-           (get-parts-table (cdr packages))
-           (cons (list (gnetlist:get-package-attribute package "refdes")
-                       (get-device package)
-                       (get-value package)  
-                       (gnetlist:get-package-attribute package "footprint")
-                       (gnetlist:get-package-attribute package "loadstatus")
-                       (gnetlist:get-package-attribute package "vendor")
-                       (gnetlist:get-package-attribute package "vendor_part_number")) ;; sdb change
-                 (get-parts-table (cdr packages)))))))
-
-(define (write-one-row ls separator end-char port)
-  (if (null? ls)
-      '()
-      (begin (display "\"" port)
-            (display (car ls) port)
-            (for-each (lambda (st) (display separator port)(display st port)) (cdr ls))
-            (display end-char port))))
-
-(define (get-sortkey-value ls key-column)
-  (list-ref (car ls) key-column))
-
-(define (marge-sort-sub ls1 ls2 key-column)
-  (if (or (null? ls1) (null? ls2))
-      (append ls1 ls2)
-      (if (string-ci<=? (get-sortkey-value ls1  key-column) (get-sortkey-value ls2 key-column))
-         (cons (car ls1) (marge-sort-sub (cdr ls1) ls2 key-column))
-         (cons (car ls2) (marge-sort-sub ls1 (cdr ls2) key-column)))))
-
-(define (marge-sort ls key-column)
-  (let ((midpoint (inexact->exact (floor (/ (length ls) 2)))))
-    (if (<= (length ls) 1)
-       (append ls)
-       (let ((top-half (reverse (list-tail (reverse ls) midpoint)))
-             (bottom-half (list-tail ls (- (length ls) midpoint))))
-         (set! top-half (marge-sort top-half key-column))
-         (set! bottom-half (marge-sort bottom-half key-column))
-         (marge-sort-sub top-half bottom-half key-column)))))
-
-(define (marge-sort-with-multikey ls key-columns)
-  (if (or (<= (length ls) 1) (null? key-columns))
-      (append ls)
-      (let* ((key-column (car key-columns))
-            (sorted-ls (marge-sort ls key-column))
-            (key-column-only-ls 
-             ((lambda (ls) (let loop ((l ls))
-                             (if (null? l)
-                                 '()
-                                 (cons (get-sortkey-value l key-column) (loop (cdr l))))))
-              sorted-ls))
-            (first-value (get-sortkey-value sorted-ls key-column))
-            (match-length (length (member first-value (reverse key-column-only-ls))))
-            (first-ls (list-tail (reverse sorted-ls) (- (length sorted-ls) match-length)))
-            (rest-ls (list-tail sorted-ls match-length)))
-       (append (marge-sort-with-multikey first-ls (cdr key-columns))
-               (marge-sort-with-multikey rest-ls key-columns)))))
-
-(define partslistgag:write-top-header
-  (lambda (port)
-    (display "\"device\",\"value\",\"footprint\",\"loadstatus\",\"vendor\",\"vendor_part_number\",\"quantity\",\"refdes\"\n" port)))
-
-(define (partslistgag:write-partslist ls port)
-  (if (null? ls)
-      '()
-      (begin (write-one-row (cdar ls) "\",\"" "\"," port)
-            (write-one-row (caar ls) " " "\"\n" port)
-            (partslistgag:write-partslist (cdr ls) port))))
-
-(define partslistgag:write-bottom-footer
-  (lambda (port)
-      '()
-    ))
-
-(define (count-same-parts ls)
-  (if (null? ls)
-      (append ls)
-      (let* ((parts-table-no-uref (let ((result '()))
-                                   (for-each (lambda (l) (set! result (cons (cdr l) result))) (reverse ls))
-                                   (append result)))
-            (first-ls (car parts-table-no-uref))
-            (match-length (length (member first-ls (reverse parts-table-no-uref))))
-            (rest-ls (list-tail ls match-length))
-            (match-ls (list-tail (reverse ls) (- (length ls) match-length)))
-            (uref-ls (let ((result '()))
-                       (for-each (lambda (l) (set! result (cons (car l) result))) match-ls)
-                       (append result))))
-       (cons (cons uref-ls (append first-ls  (list match-length))) (count-same-parts rest-ls)))))
-
-(define partslistgag
-  (lambda (output-filename)
-    (let ((port (open-output-file output-filename))
-         (parts-table (marge-sort-with-multikey (get-parts-table packages) '(1 2 3 0))))
-      (set! parts-table (count-same-parts parts-table))
-      (partslistgag:write-top-header port)
-      (partslistgag:write-partslist parts-table port)
-      (partslistgag:write-bottom-footer port)
-      (close-output-port port))))