@@ -38,31 +38,35 @@ (define (print-err . data) (with-output-to-port (current-error-port) (lambda () (apply print data)))) -(define (process-file ignores fname) +(define (process-file ignores fname oup) (with-input-from-file fname (lambda () (let loop ((modname "DUMMYMOD")) (let* ((inl (read-line))) (if (eof-object? inl) #t (match (string-search unituses-rx inl) - ((_ dtype unitname) - (if (equal? dtype "unit") - (loop unitname) - (begin - (if (equal? dtype "uses") - (if (not (or (member modname '("DUMMYMOD")) - (member modname ignores) - (member unitname ignores))) - (print " \""unitname"\" -> \""modname"\";")) - (print-err "ERROR: bad declare line \""inl"\"")) - (loop modname)))) - (else - (loop modname))))))))) + ((_ dtype unitname) + (if (equal? dtype "unit") + (loop unitname) + (begin + (if (equal? dtype "uses") + (if (not (or (member modname '("DUMMYMOD")) + (member modname ignores) + (member unitname ignores))) + (begin + (print " \""unitname"\" -> \""modname"\";") + (with-output-to-port oup + (lambda () + (print "mofiles/"modname".o : mofiles/"unitname".o"))))) + (print-err "ERROR: bad declare line \""inl"\"")) + (loop modname)))) + (else + (loop modname))))))))) ;; ./utils/plot-uses todot portlogger,stml2,debugprint,mtargs ;; apimod.scm commonmod.scm configfmod.scm dbmod.scm megatestmod.scm ;; mtmod.scm processmod.scm rmtmod.scm servermod.scm ;; tcp-transportmod.scm > uses.dot @@ -71,19 +75,21 @@ (define (main) (match (command-line-arguments) (("todot" ignoreunits . files) - (let* ((ignores (string-split ignoreunits ","))) + (let* ((ignores (string-split ignoreunits ",")) + (oup (open-output-file "make.inc"))) (print-err "Making graph for files: " (string-intersperse files ", ")) (print "digraph uses_unit {") (for-each (lambda (fname) (print "// Filename: "fname) - (process-file ignores fname)) + (process-file ignores fname oup)) files) - (print "}"))) + (print "}") + (close-output-port oup))) (else (print-err "Usage: plot-uses todot u1,u2... file1.scm ...") (print-err " where u1,u2... are units to ignore and file1.scm... are the files to process.")))) (main)