mirror of
https://github.com/justinethier/cyclone.git
synced 2025-07-07 05:06:36 +02:00
Refactoring
This commit is contained in:
parent
2497fa0554
commit
a4a6e7d602
2 changed files with 27 additions and 33 deletions
29
cyclone.scm
29
cyclone.scm
|
@ -216,14 +216,11 @@
|
||||||
(let* ((in-file (car args))
|
(let* ((in-file (car args))
|
||||||
(in-prog (read-file in-file))
|
(in-prog (read-file in-file))
|
||||||
(program? (not (library? (car in-prog))))
|
(program? (not (library? (car in-prog))))
|
||||||
; TODO: trying to get this here, then can pass it to
|
(lib-deps
|
||||||
; compiler code (for entry points) and below for
|
(if (and program?
|
||||||
; gcc calls (need to wrap in .o string for that though)
|
(tagged-list? 'import (car in-prog)))
|
||||||
;(lib-deps
|
(delete-duplicates (lib:get-all-import-deps (cdar in-prog)))
|
||||||
; (if (and program?
|
'()))
|
||||||
; (tagged-list? 'import (car in-prog)))
|
|
||||||
; (lib:get-all-import-deps (cadr in-prog))
|
|
||||||
; '()))
|
|
||||||
(exec-file (basename in-file))
|
(exec-file (basename in-file))
|
||||||
(src-file (string-append exec-file ".c"))
|
(src-file (string-append exec-file ".c"))
|
||||||
(create-c-file
|
(create-c-file
|
||||||
|
@ -256,16 +253,14 @@
|
||||||
(cond
|
(cond
|
||||||
(program?
|
(program?
|
||||||
(let ((objs-str
|
(let ((objs-str
|
||||||
(if (tagged-list? 'import (car in-prog))
|
(apply
|
||||||
(apply
|
string-append
|
||||||
string-append
|
(map
|
||||||
(delete-duplicates
|
(lambda (i)
|
||||||
(map
|
(string-append " " (lib:import->filename i ".o") " "))
|
||||||
(lambda (str)
|
lib-deps))))
|
||||||
(string-append " " str " "))
|
|
||||||
(lib:imports->objs (cdar in-prog)))))
|
|
||||||
"")))
|
|
||||||
;(write `(DEBUG all imports ,lib-deps objs ,objs-str))
|
;(write `(DEBUG all imports ,lib-deps objs ,objs-str))
|
||||||
|
;(write `(DEBUG ,(lib:get-all-import-deps (cdar in-prog))))
|
||||||
(if (equal? 0
|
(if (equal? 0
|
||||||
(system
|
(system
|
||||||
(string-append "gcc " src-file " -I" (cyc:get-include-dir) " -g -c -o " exec-file ".o")))
|
(string-append "gcc " src-file " -I" (cyc:get-include-dir) " -g -c -o " exec-file ".o")))
|
||||||
|
|
31
trans.scm
31
trans.scm
|
@ -1628,28 +1628,27 @@
|
||||||
;; libs requires. will probably need to prune duplicates from completed list.
|
;; libs requires. will probably need to prune duplicates from completed list.
|
||||||
;; Longer-term, do we want to look at file timestamps to see if files need to
|
;; Longer-term, do we want to look at file timestamps to see if files need to
|
||||||
;; be recompiled?
|
;; be recompiled?
|
||||||
(define (lib:imports->objs imports)
|
;(define (lib:imports->objs imports)
|
||||||
|
; (apply
|
||||||
|
; append
|
||||||
|
; (map
|
||||||
|
; (lambda (i)
|
||||||
|
; (cons
|
||||||
|
; (lib:import->filename i ".o")
|
||||||
|
; (lib:imports->objs (lib:read-imports i))
|
||||||
|
; ))
|
||||||
|
; imports)))
|
||||||
|
|
||||||
|
;; Given import names, get all dependant import names that are required
|
||||||
|
;; Note: does not filter out duplicates
|
||||||
|
(define (lib:get-all-import-deps imports)
|
||||||
(apply
|
(apply
|
||||||
append
|
append
|
||||||
(map
|
(map
|
||||||
(lambda (i)
|
(lambda (i)
|
||||||
(cons
|
(cons i (lib:get-all-import-deps (lib:read-imports i))))
|
||||||
(lib:import->filename i ".o")
|
|
||||||
(lib:imports->objs (lib:read-imports i))
|
|
||||||
))
|
|
||||||
imports)))
|
imports)))
|
||||||
|
|
||||||
;; Given import names, get all dependant import names that are required
|
|
||||||
(define (lib:get-all-import-deps imports)
|
|
||||||
(delete-duplicates
|
|
||||||
(apply
|
|
||||||
append
|
|
||||||
(map
|
|
||||||
(lambda (i)
|
|
||||||
(write `(DEBUG i ,i))
|
|
||||||
(cons i (lib:get-all-import-deps (lib:read-imports i))))
|
|
||||||
imports))))
|
|
||||||
|
|
||||||
;; Given a single import from an import-set, open the corresponding
|
;; Given a single import from an import-set, open the corresponding
|
||||||
;; library file and retrieve the library's import-set.
|
;; library file and retrieve the library's import-set.
|
||||||
(define (lib:read-imports import)
|
(define (lib:read-imports import)
|
||||||
|
|
Loading…
Add table
Reference in a new issue