21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
|
srfi-69
)
(define (portprint p . args)
(with-output-to-port p
(lambda ()
(apply print args))))
(define (compunit targfname files)
(let* ((unitdata (make-hash-table))
(moduledata (make-hash-table))
(filesdata (make-hash-table))
(unitdec (regexp "^\\(declare\\s+\\(unit\\s+([^\\s]+)\\)\\)"))
(unituse (regexp "^\\(declare\\s+\\(uses\\s+([^\\s]+)\\)\\)"))
(moduledec (regexp "^\\(module\\s+([\\s]+)"))
(importuse (regexp "^\\(import\\s+(.*)\\)")) ;; captures string of imports (one line)
(dotport (open-output-file (conc targfname ".dot")))
(incport (open-output-file (conc targfname ".inc")))
)
(portprint dotport "digraph usedeps {")
(for-each
(lambda (fname)
(let* ((sname (string-substitute "\\.scm$" "" fname)))
(print "Processing "fname" with core name of "sname)
(hash-table-set! filesdata sname fname) ;; record the existance of the src file
(with-input-from-file fname
(lambda ()
(let loop ((inl (read-line)))
(if (not (eof-object? inl))
(begin
(regex-case
inl
(unitdec (_ unitname)
(if (equal? sname unitname) ;; good if same
(if (not (hash-table-exists? unitdata unitname))
(hash-table-set! unitdata unitname (make-hash-table)))))
(unituse (_ usingname)
(portprint dotport "\""sname"\" -> \""usingname"\"")
(portprint incport sname".scm : "usingname".scm"))
;; (moduledec (_ modname) (print "Module: " modname))
;; (importuse (_ importname) (print "Imports: " importname))
(else #f))
(loop (read-line)))))))))
files)
(portprint dotport "}")
(close-output-port dotport)
|
>
>
>
>
>
>
>
>
>
>
>
>
|
|
>
>
>
>
>
>
|
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
|
srfi-69
)
(define (portprint p . args)
(with-output-to-port p
(lambda ()
(apply print args))))
(define (mofiles-adjust->dot-o inf)
(regex-case
inf
("^.*mod$" _ (conc "mofiles/"inf".o"))
("pgdb" _ (conc "cgisetup/models/"inf".o"))
(else (conc inf".o"))))
(define (compunit targfname files)
(let* ((unitdata (make-hash-table))
(moduledata (make-hash-table))
(filesdata (make-hash-table))
(unitdec (regexp "^\\(declare\\s+\\(unit\\s+([^\\s]+)\\)\\)"))
(unituse (regexp "^\\(declare\\s+\\(uses\\s+([^\\s]+)\\)\\)"))
(moduledec (regexp "^\\(module\\s+([\\s]+)"))
(importuse (regexp "^\\(import\\s+(.*)\\)")) ;; captures string of imports (one line)
(dotport (open-output-file (conc targfname ".dot")))
(incport (open-output-file (conc targfname ".inc")))
)
(portprint dotport "digraph usedeps {")
(portprint incport "# To regenerate this file do:
# (cd utils/;ck52 csc gendeps.scm) && ./utils/gendeps allunits *scm
# cp allunits.inc build.inc
#
")
(for-each
(lambda (fname)
(let* ((sname (string-substitute "\\.scm$" "" fname)))
(print "Processing "fname" with core name of "sname)
(hash-table-set! filesdata sname fname) ;; record the existance of the src file
(with-input-from-file fname
(lambda ()
(let loop ((inl (read-line)))
(if (not (eof-object? inl))
(begin
(regex-case
inl
(unitdec (_ unitname)
(if (equal? sname unitname) ;; good if same
(if (not (hash-table-exists? unitdata unitname))
(hash-table-set! unitdata unitname (make-hash-table)))))
(unituse (_ usingname)
(portprint dotport "\""usingname"\" -> \""sname"\"")
(portprint incport
(if (or (string-search ".import$" sname)
(string-search ".import$" usingname))
"# "
"")
(mofiles-adjust->dot-o sname)" : "
(mofiles-adjust->dot-o usingname)))
;; (moduledec (_ modname) (print "Module: " modname))
;; (importuse (_ importname) (print "Imports: " importname))
(else #f))
(loop (read-line)))))))))
files)
(portprint dotport "}")
(close-output-port dotport)
|