# diff /usr/share/gEDA/scheme/gnet-gsch2pcb.scm geda/share/gEDA/scheme/gnet-gsch2pcb.scm > gnet-gsch2pcb.scm.diffs 28a29 > (use-modules (ice-9 rdelim)) 33,49c34,50 < (lambda (port) < (display "# release: pcb 1.99x\n" port) < (display "# To read pcb files, the pcb version (or the" port) < (display " cvs source date) must be >= the file version\n" port) < (display "FileVersion[20070407]\n" port) < (display "PCB[\"\" 600000 500000]\n" port) < (display "Grid[10000.000000 0 0 0]\n" port) < (display "Cursor[0 0 0.000000]\n" port) < (display "PolyArea[200000000.000000]\n" port) < (display "Thermal[0.500000]\n" port) < (display "DRC[1000 1000 1000 1000 1500 1000]\n" port) < (display "Flags(\"nameonpcb,uniquename,clearnew,snappin\")\n" port) < (display "Groups(\"1,c:2:3:4:5:6,s:7:8\")\n" port) < (display "Styles[\"Signal,1000,3600,2000,1000:" port) < (display "Power,2500,6000,3500,1000:" port) < (display "Fat,4000,6000,3500,1000:" port) < (display "Skinny,600,2402,1181,600\"]\n" port) --- > (lambda () > (display "# release: pcb 1.99x\n") > (display "# To read pcb files, the pcb version (or the") > (display " cvs source date) must be >= the file version\n") > (display "FileVersion[20070407]\n") > (display "PCB[\"\" 600000 500000]\n") > (display "Grid[10000.000000 0 0 0]\n") > (display "Cursor[0 0 0.000000]\n") > (display "PolyArea[200000000.000000]\n") > (display "Thermal[0.500000]\n") > (display "DRC[1000 1000 1000 1000 1500 1000]\n") > (display "Flags(\"nameonpcb,uniquename,clearnew,snappin\")\n") > (display "Groups(\"1,c:2:3:4:5:6,s:7:8\")\n") > (display "Styles[\"Signal,1000,3600,2000,1000:") > (display "Power,2500,6000,3500,1000:") > (display "Fat,4000,6000,3500,1000:") > (display "Skinny,600,2402,1181,600\"]\n") 55,66c56,67 < (lambda (port) < (display "Layer(1 \"top\")\n(\n)\n" port) < (display "Layer(2 \"ground\")\n(\n)\n" port) < (display "Layer(3 \"signal2\")\n(\n)\n" port) < (display "Layer(4 \"signal3\")\n(\n)\n" port) < (display "Layer(5 \"power\")\n(\n)\n" port) < (display "Layer(6 \"bottom\")\n(\n)\n" port) < (display "Layer(7 \"outline\")\n(\n)\n" port) < (display "Layer(8 \"spare\")\n(\n)\n" port) < (display "Layer(9 \"silk\")\n(\n)\n" port) < (display "Layer(10 \"silk\")\n(\n)" port) < (newline port))) --- > (lambda () > (display "Layer(1 \"top\")\n(\n)\n") > (display "Layer(2 \"ground\")\n(\n)\n") > (display "Layer(3 \"signal2\")\n(\n)\n") > (display "Layer(4 \"signal3\")\n(\n)\n") > (display "Layer(5 \"power\")\n(\n)\n") > (display "Layer(6 \"bottom\")\n(\n)\n") > (display "Layer(7 \"outline\")\n(\n)\n") > (display "Layer(8 \"spare\")\n(\n)\n") > (display "Layer(9 \"silk\")\n(\n)\n") > (display "Layer(10 \"silk\")\n(\n)") > (newline))) 135c136 < (define-undefined gsch2pcb:pcb-m4-dir "/usr/share/pcb/m4") --- > (define-undefined gsch2pcb:pcb-m4-dir "/home/nelson/geda/share/pcb/m4") 140a142,158 > ;; List of the m4 command line entries > (define (gsch2pcb:build-m4-command-line-list) > (delv "" > (append > (list > gsch2pcb:pcb-m4-command > "-d") > (map-in-order > (lambda (x) (string-append "-I" x)) > (cons > gsch2pcb:pcb-m4-dir > gsch2pcb:pcb-m4-path)) > (list > (string-append gsch2pcb:pcb-m4-dir "/common.m4") > gsch2pcb:m4-files > "-")))) > 142,150c160,253 < (define (gsch2pcb:build-m4-command-line output-filename) < (string-append gsch2pcb:pcb-m4-command < " -d" < (string-join (cons gsch2pcb:pcb-m4-dir < gsch2pcb:pcb-m4-path) < " -I" 'prefix) < " " gsch2pcb:pcb-m4-dir "/common.m4" < " " gsch2pcb:m4-files < " - >> " output-filename)) --- > (define (gsch2pcb:build-m4-command-line) > (string-join > (gsch2pcb:build-m4-command-line-list) > " " > 'infix)) > > ;; run a child process and return a pair of input and output ports. > ;; Executes the program 'command' with optional arguments 'args' > ;; (all strings) in a subprocess. > ;; Two ports to the process (based on pipes) are created and > ;; returned. > ;; The procedure is a modified version of the popen open-pipe* > ;; procedure. Its functionality is close to that of > ;; open-input-output-pipe. Changes are made to make it return two > ;; ports instead of one in order to have a possibility to close > ;; each one separately. This allows closing of the input pipe by > ;; using (close-port port) when needed and emit EOF to the running > ;; child process. > (define (gsch2pcb:open-io-pipe command . args) > (let* ((c2p (pipe)) ; child to parent > (p2c (pipe))) ; parent to child > > (setvbuf (cdr c2p) _IONBF) > (setvbuf (cdr p2c) _IONBF) > (let ((pid (primitive-fork))) > (if (= pid 0) > (begin > ;; child process > (ensure-batch-mode!) > > ;; select the three file descriptors to be used as > ;; standard descriptors 0, 1, 2 for the new > ;; process. They are pipes to/from the parent or taken > ;; from the current Scheme input/output/error ports if > ;; possible. > > (let ((input-fdes (fileno (car p2c))) > (output-fdes (fileno (cdr c2p))) > (error-fdes > (or (false-if-exception (fileno (current-error-port))) > (open-fdes *null-device* O_WRONLY)))) > > ;; close all file descriptors in ports inherited from > ;; the parent except for the three selected above. > ;; this is to avoid causing problems for other pipes in > ;; the parent. > > ;; use low-level system calls, not close-port or the > ;; scsh routines, to avoid side-effects such as > ;; flushing port buffers or evicting ports. > > (port-for-each (lambda (pt-entry) > (false-if-exception > (let ((pt-fileno (fileno pt-entry))) > (if (not (or (= pt-fileno input-fdes) > (= pt-fileno output-fdes) > (= pt-fileno error-fdes))) > (close-fdes pt-fileno)))))) > > ;; Copy the three selected descriptors to the standard > ;; descriptors 0, 1, 2, if not already there > > (if (not (= input-fdes 0)) > (begin > (if (= output-fdes 0) (set! output-fdes (dup->fdes 0))) > (if (= error-fdes 0) (set! error-fdes (dup->fdes 0))) > (dup2 input-fdes 0) > ;; it's possible input-fdes is error-fdes > (if (not (= input-fdes error-fdes)) > (close-fdes input-fdes)))) > > (if (not (= output-fdes 1)) > (begin > (if (= error-fdes 1) (set! error-fdes (dup->fdes 1))) > (dup2 output-fdes 1) > ;; it's possible output-fdes is error-fdes > (if (not (= output-fdes error-fdes)) > (close-fdes output-fdes)))) > > (if (not (= error-fdes 2)) > (begin > (dup2 error-fdes 2) > (close-fdes error-fdes))) > > (apply execlp command command args))) > (begin > ;; parent process > ;; the forked child process should use these ports so > ;; the parent process doesn't need them any more > (close-port (cdr c2p)) > (close-port (car p2c)) > ;; return input and output ports > (cons (car c2p) (cdr p2c)) > ))))) 153,158c256,258 < (define command-line (gsch2pcb:build-m4-command-line output-filename)) < < (let ((port (open-output-file output-filename))) < (gsch2pcb:write-top-header port) < (close-port port) < ) --- > (begin > (set-current-output-port (gnetlist:output-port output-filename)) > (gsch2pcb:write-top-header) 160c260 < (format #t --- > (format (current-error-port) 189c289 < command-line) --- > (gsch2pcb:build-m4-command-line)) 195,214c295,313 < (let ((pipe (open-output-pipe command-line)) < ) < < (display "Using the m4 processor for pcb footprints\n") < ;; packages is a list with the different refdes value < (gsch2pcb:write-value-footprints pipe packages) < (close-pipe pipe) < ) < < (let ((port (open output-filename (logior O_WRONLY O_APPEND)))) < (display "Skipping the m4 processor for pcb footprints\n") < (gsch2pcb:write-value-footprints port packages) < (close-port port) < ) < ) < < (let ((port (open output-filename (logior O_WRONLY O_APPEND)))) < (gsch2pcb:write-bottom-footer port) < close-port port) < ) --- > (let* ((pipe-ports > (apply gsch2pcb:open-io-pipe > (gsch2pcb:build-m4-command-line-list))) > (ip (car pipe-ports)) > (op (cdr pipe-ports))) > > (message "Using the m4 processor for pcb footprints\n") > ;; packages is a list with the different refdes value > (gsch2pcb:write-value-footprints op packages) > (close-port op) > (do ((line (read-line ip) (read-line ip))) > ((eof-object? line)) > (display line) > (newline))) > > ;; don't use m4 > (begin > (message "Skipping the m4 processor for pcb footprints\n") > (gsch2pcb:write-value-footprints (current-output-port) packages))) 215a315 > (gsch2pcb:write-bottom-footer)))