Changeset 5797 in project for nest-tool/trunk/nest-tool.scm


Ignore:
Timestamp:
08/29/07 00:01:13 (13 years ago)
Author:
Mario Domenech Goulart
Message:

Experimental dependencies graph generation.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • nest-tool/trunk/nest-tool.scm

    r4589 r5797  
    5050            (not (null? (grep pattern (map symbol->string (nest-tool:egg-dependencies egg))))))
    5151          (nest-tool:raw)))
     52
     53(define (nest-tool:dep-graph->dot eggname #!key (raw #f))
     54  (define labels "")
     55  (define links '())
     56 
     57  (define (scm->dot name)
     58    (cond ((eq? name 'digraph) "digraph_")
     59          ((equal? name "digraph") "digraph_")
     60          (else (string-translate (->string name) "-" "_"))))
     61
     62  (define (add-link! from to)
     63    (unless (member (cons from to) links)
     64      (set! links (cons (cons from to) links))))
     65
     66  (define (links->string)
     67    (string-intersperse
     68     (map (lambda (link)
     69            (string-append (scm->dot (car link)) " -> "
     70                           (scm->dot (cdr link)) ";\n"))
     71          links)))
     72   
     73  (define (link-dependencies egg)
     74    (let ((deps (filter (lambda (egg)
     75                          (not (memq egg ##sys#core-library-modules)))
     76                        (nest-tool:egg-dependencies (car (nest-tool:search-names (->string egg) raw))))))
     77      (with-output-to-string
     78        (lambda ()
     79          (let ((dot-egg (scm->dot egg)))
     80            (set! labels (string-append labels dot-egg " [label=\"" (->string egg) "\"]\n"))
     81            (for-each (lambda (egg-dep)
     82                        (add-link! egg egg-dep)
     83                        (link-dependencies egg-dep))
     84                      deps))))))
     85  (link-dependencies eggname)
     86  (string-append "digraph eggs {\n" labels "\n" (links->string) "\n}"))
     87
     88(define (nest-tool:dep-graphs->graphic eggname #!key (output-dir ".") (raw #f) (format 'png))
     89  (with-output-to-file  (make-pathname output-dir (->string eggname) "dot")
     90    (lambda ()
     91      (print (nest-tool:dep-graph->dot eggname raw: raw))))
     92  (system (conc "dot -T" format " "
     93                " -o " (make-pathname output-dir eggname (->string format)) " "
     94                (make-pathname output-dir eggname "dot")
     95                " &")))
     96
     97(define (nest-tool:all-dep-graphs->graphic #!key (eggnames #f) (output-dir ".") (format 'png))
     98  (let ((raw (nest-tool:raw)))
     99    (for-each (lambda (egg)
     100                (nest-tool:dep-graphs->graphic egg output-dir: output-dir raw: raw format: format))
     101              (map ->string (or eggnames (nest-tool:names))))))
Note: See TracChangeset for help on using the changeset viewer.