[Author Prev][Author Next][Thread Prev][Thread Next][Author Index][Thread Index]

gEDA-cvs: gaf.git: branch: master updated (1.7.1-20110619-166-g76bc345)



The branch, master has been updated
       via  76bc345ee043764b919980c3de6d27f78546cf73 (commit)
      from  987021bbb5f65ce3d28bc05f1c715b49a8a8e015 (commit)

Those revisions listed above that are new to this repository have
not appeared on any other notification email; so we list those
revisions in full, below.


=========
 Summary
=========

 gnetlist/scheme/gnet-bom.scm  |   63 +++++++++++++++++++++++++++-------------
 gnetlist/scheme/gnet-bom2.scm |   56 +++++++++++++++++++++++++-----------
 2 files changed, 81 insertions(+), 38 deletions(-)


=================
 Commit Messages
=================

commit 76bc345ee043764b919980c3de6d27f78546cf73
Author: Jared Casper <jaredcasper@xxxxxxxxx>
Commit: Peter TB Brett <peter@xxxxxxxxxxxxx>

    gnetlist: bom/bom2 backend attribute list improvements
    
    - Checks for the existence of the attribute file, gives a helpful error
      message if none is found (no default)
    
    - Adds an attrib_file command line option to the backend for
      specifying an alternate attribute file
    
    - Adds an attribs command line option for specifying the attributes
      directly from the command line
    
    Closes-bug: lp-810202

:100644 100644 4ccd26f... 05cb40a... M	gnetlist/scheme/gnet-bom.scm
:100644 100644 128160d... a3c8549... M	gnetlist/scheme/gnet-bom2.scm

=========
 Changes
=========

commit 76bc345ee043764b919980c3de6d27f78546cf73
Author: Jared Casper <jaredcasper@xxxxxxxxx>
Commit: Peter TB Brett <peter@xxxxxxxxxxxxx>

    gnetlist: bom/bom2 backend attribute list improvements
    
    - Checks for the existence of the attribute file, gives a helpful error
      message if none is found (no default)
    
    - Adds an attrib_file command line option to the backend for
      specifying an alternate attribute file
    
    - Adds an attribs command line option for specifying the attributes
      directly from the command line
    
    Closes-bug: lp-810202

diff --git a/gnetlist/scheme/gnet-bom.scm b/gnetlist/scheme/gnet-bom.scm
index 4ccd26f..05cb40a 100644
--- a/gnetlist/scheme/gnet-bom.scm
+++ b/gnetlist/scheme/gnet-bom.scm
@@ -30,17 +30,35 @@
 ;;; Questions? Contact matt@xxxxxxxxx
 ;;; This software is released under the terms of the GNU GPL
 
-(use-modules (ice-9 rdelim))  ;; guile-1.8 fix
+(use-modules (ice-9 rdelim) ;; guile-1.8 fix
+             (gnetlist backend-getopt))
+
+(define bom:open-input-file
+  (lambda (options)
+    (let ((filename (backend-option-ref options 'attrib_file "attribs")))
+      (if (file-exists? filename)
+	  (open-input-file filename)
+	  (if (backend-option-ref options 'attribs) #f
+              (begin
+                (display (string-append "ERROR: Attribute file '" filename "' not found. You must do one of the following:\n"))
+                (display "         - Create an 'attribs' file\n")
+                (display "         - Specify an attribute file using -Oattrib_file=<filename>\n")
+                (display "         - Specify which attributes to include using -Oattribs=attrib1,attrib2,... (no spaces)\n")
+                #f))))))
 
 (define bom
   (lambda (output-filename)
-    (let ((port (if (string=? "-" output-filename)
-		      (current-output-port)
-		      (open-output-file output-filename)))
-	  (attriblist (bom:parseconfig (open-input-file "attribs"))))
-      (bom:printlist (cons 'refdes attriblist) port)
-      (bom:components port packages attriblist)
-      (close-output-port port))))
+    (let* ((options (backend-getopt
+                     (gnetlist:get-backend-arguments)
+                     '((attrib_file (value #t)) (attribs (value #t)))))
+           (port (if (string=? "-" output-filename)
+                     (current-output-port)
+                     (open-output-file output-filename)))
+           (attriblist (bom:parseconfig (bom:open-input-file options) options)))
+      (and attriblist
+           (begin (bom:printlist (cons 'refdes attriblist) port)
+                  (bom:components port packages attriblist)
+                  (close-output-port port))))))
 
 (define bom:printlist
   (lambda (ls port)
@@ -51,26 +69,29 @@
 	  (write-char #\tab port)
 	  (bom:printlist (cdr ls) port)))))
 
-; Parses attrib file. Returns a list of read attributes.
+; Parses attrib file or argument. Returns a list of read attributes.
 (define bom:parseconfig
-  (lambda (port)
-    (let ((read-from-file (read-delimited " \n\t" port)))
-      (cond ((eof-object? read-from-file)
-	     '())
-	    ((= 0 (string-length read-from-file))
-	     (bom:parseconfig port))
-	    (else
-	     (cons read-from-file (bom:parseconfig port)))))))
+  (lambda (port options)
+    (let ((attribs (backend-option-ref options 'attribs)))
+      (if attribs (string-split attribs #\,)
+          (and port
+               (let ((read-from-file (read-delimited " \n\t" port)))
+                 (cond ((eof-object? read-from-file)
+                        '())
+                       ((= 0 (string-length read-from-file))
+                        (bom:parseconfig port options))
+                       (else
+                        (cons read-from-file (bom:parseconfig port options))))))))))
 
 (define bom:components
   (lambda (port ls attriblist)
     (if (not (null? ls))
 	(let ((package (car ls)))
           (if (not (string=? "1" (gnetlist:get-package-attribute package "nobom")))
-	    (begin
-              (display package port)
-	      (write-char #\tab port)
-              (bom:printlist (bom:find-attribs package attriblist) port)))
+              (begin
+                (display package port)
+                (write-char #\tab port)
+                (bom:printlist (bom:find-attribs package attriblist) port)))
 	  (bom:components port (cdr ls) attriblist)))))
 
 (define bom:find-attribs
diff --git a/gnetlist/scheme/gnet-bom2.scm b/gnetlist/scheme/gnet-bom2.scm
index 128160d..a3c8549 100644
--- a/gnetlist/scheme/gnet-bom2.scm
+++ b/gnetlist/scheme/gnet-bom2.scm
@@ -30,18 +30,37 @@
 ;;; Questions? Contact matt@xxxxxxxxx
 ;;; This software is released under the terms of the GNU GPL
 
-(use-modules (ice-9 rdelim)) ;; guile-1.8 fix
+(use-modules (ice-9 rdelim) ;; guile-1.8 fix
+             (gnetlist backend-getopt))
+
+(define bom2:open-input-file
+  (lambda (options)
+    (let ((filename (backend-option-ref options 'attrib_file "attribs")))
+      (if (file-exists? filename)
+	  (open-input-file filename)
+	  (if (backend-option-ref options 'attribs) #f
+              (begin
+                (display (string-append "ERROR: Attribute file '" filename "' not found. You must do one of the following:\n"))
+                (display "         - Create an 'attribs' file\n")
+                (display "         - Specify an attribute file using -Oattrib_file=<filename>\n")
+                (display "         - Specify which attributes to include using -Oattribs=attrib1,attrib2,... (no spaces)\n")
+                #f))))))
 
 (define bom2
   (lambda (output-filename)
-    (let ((port (if (string=? "-" output-filename)
-		      (current-output-port)
-		      (open-output-file output-filename)))
-	  (attriblist (bom2:parseconfig (open-input-file "attribs"))))
-      (bom2:printlist (append (cons 'refdes attriblist) (list "qty")) port #\:)
-      (newline port)
-      (bom2:printbom port (bom2:components packages attriblist) 0)
-      (close-output-port port))))
+    (let* ((options (backend-getopt
+                     (gnetlist:get-backend-arguments)
+                     '((attrib_file (value #t)) (attribs (value #t)))))
+           (port (if (string=? "-" output-filename)
+                     (current-output-port)
+                     (open-output-file output-filename)))
+           (attriblist (bom2:parseconfig (bom2:open-input-file options) options)))
+      (and attriblist
+	   (begin
+	     (bom2:printlist (append (cons 'refdes attriblist) (list "qty")) port #\:)
+	     (newline port)
+	     (bom2:printbom port (bom2:components packages attriblist) 0)
+	     (close-output-port port))))))
 
 (define bom2:printbom
   (lambda (port bomlist count)
@@ -74,14 +93,17 @@
 
 ; Parses attrib file. Returns a list of read attributes.
 (define bom2:parseconfig
-  (lambda (port)
-    (let ((read-from-file (read-delimited " \n\t" port)))
-      (cond ((eof-object? read-from-file)
-	     '())
-	    ((= 0 (string-length read-from-file))
-	     (bom2:parseconfig port))
-	    (else
-	     (cons read-from-file (bom2:parseconfig port)))))))
+  (lambda (port options)
+    (let ((attribs (backend-option-ref options 'attribs)))
+      (if attribs (string-split attribs #\,)
+          (and port
+               (let ((read-from-file (read-delimited " \n\t" port)))
+                 (cond ((eof-object? read-from-file)
+                        '())
+                       ((= 0 (string-length read-from-file))
+                        (bom2:parseconfig port options))
+                       (else
+                        (cons read-from-file (bom2:parseconfig port options))))))))))
 
 (define bom2:match-list?
   (lambda (l1 l2)




_______________________________________________
geda-cvs mailing list
geda-cvs@xxxxxxxxxxxxxx
http://www.seul.org/cgi-bin/mailman/listinfo/geda-cvs