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

gEDA-user: Use the gnetlist, Luke



Thinking about a set of scripts to better automate my path from light  
library symbols to heavy project symbols. One issue for user scripts  
like this is that they need to know where gEDA is installed. For me,  
that varies between machines, and sometimes I even have multiple  
installations on the same machine.

But, as usual, gnetlist comes to the rescue: *it* knows where the  
installation is. All I have to do is get it to report. It's pretty easy:

;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
; gnetlist back end to find the paths of a gEDA installation
; and generate a file that defines them in Bourne shell syntax

(define where-geda-sh (lambda (output-filename)
    (set-current-output-port (open-output-file output-filename))
    (for-each putexpr '(
       "geda-confd-path"
       "geda-data-path"
       "geda-font-path"
       "geda-rc-path"
       "geda-scheme-path"
       "geda-sym-path"
        ))
))

;; Output a variable name followed by "=" and its value
;; Dashes get changed to underscores

(define putexpr (lambda (var)
    (display (string-map -to_ var))
    (display "=\"")
    (display (eval-string var))
    (display "\"")
    (newline)
))

;; Change - to _

(define -to_ (lambda (c) (if (eq? c #\-) #\_ c)))
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;

Put this wherever your gEDA keeps Scheme scripts, and then:

gnetlist -g where-geda-sh /dev/null
. output.net

will define shell variables geda_confd_path etc. assuming you're  
using a shell with Bourne syntax.

It helps that gnetlist "does nothing gracefully" when given empty  
schematic as input. Good design.

Of course, installing gnet-where-geda-sh runs into the same issue:  
what is geda-scheme-path? It would be good to have the above script  
as part of the gEDA installation (since the installation script  
knows). Ales, would you like for me to put the GPL boilerplate on  
this and submit it to you, along with a CSH version?

It would also be nice to have a configurable place for user gnetlist  
scripts.

John Doty              Noqsi Aerospace, Ltd.
http://www.noqsi.com/
jpd@xxxxxxxxx




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