5.15.1.3 component-library-command

A program or set of programs can be used as a component resource. The procedure used to add such a resource from a Lepton RC file is:

(component-library-command list-command get-command name)

The code adds a new library named name. The list-command argument specifies a name of the program that will be executed with no further arguments, and should output a list of available symbol names on stdout. The get-command argument specifies another program that should take a symbol name as its only argument, and output symbol data in gEDA/gaf File Format Document on stdout.

If the command cannot successfully complete, it should exit with non-zero exit status. Anything it has output on stdout will be ignored, and any stderr output displayed to the user.

This is the contents of an example script:

#!/usr/bin/env sh
if [ -z "$1" ] ; then
   echo "Usage: $0 symname.sym"
   echo "List symbols: $0 -l"
   echo "Get symbol: $0 symname.sym"
   exit 255
fi

if test "$1" = "-l"; then
   echo "symname1.sym"
   echo "symname2.sym"
else
   if test "$1" = "symname1.sym"; then
       # symname1.sym
       echo "v 20200604 2"
       echo "L 100 100 200 200 3 0 0 0 -1 -1"
   else
       # symname2.sym
       echo "v 20200604 2"
       echo "P 300 300 0 300 1 0 1"
   fi
fi

As can be seen from the code, the script can function as list command, if the option -l is given, or as get command, if file name is given. Otherwise, if no arguments given, it exits with an error code. If the script is named, say, cmd-component.sh, then the following code in gafrc file will define a new component library:

(define list-command "cmd-component.sh")
(define get-command (string-append list-command " -l"))
(component-library-command list-command get-command "simple-cmd-lib")

Likewise, you can use various symbol generators written in various languages.