mirror of
https://github.com/justinethier/cyclone.git
synced 2025-05-19 05:39:17 +02:00
Use meta file to pass data when compiling programs
This commit is contained in:
parent
1a5310b881
commit
1d0cbf96ed
1 changed files with 31 additions and 8 deletions
39
cyclone.scm
39
cyclone.scm
|
@ -794,14 +794,38 @@
|
|||
append-dirs
|
||||
prepend-dirs))))))
|
||||
(create-c-file in-prog)
|
||||
(when (not program?)
|
||||
(cond
|
||||
(program?
|
||||
;; Use .meta file to store information for C compiler phase
|
||||
(save-program-metadata meta-file lib-deps c-linker-options))
|
||||
(else
|
||||
;; Emit .meta file
|
||||
(with-output-to-file
|
||||
meta-file
|
||||
(lambda ()
|
||||
(display ";; This file was automatically generated by the Cyclone Scheme compiler")
|
||||
(newline)
|
||||
(write (macro:get-defined-macros)))))))
|
||||
(write (macro:get-defined-macros))))))))
|
||||
|
||||
(define (save-program-metadata filename lib-deps c-linker-options)
|
||||
(with-output-to-file
|
||||
filename
|
||||
(lambda ()
|
||||
(display ";; This file was automatically generated by the Cyclone Scheme compiler")
|
||||
(newline)
|
||||
(write `(lib-deps . ,lib-deps))
|
||||
(newline)
|
||||
(write `(c-linker-options . ,c-linker-options)))))
|
||||
|
||||
(define (load-program-metadata filename)
|
||||
(let ((data (call-with-input-file filename read-all)))
|
||||
(delete-file filename)
|
||||
data))
|
||||
|
||||
(define (get-meta meta symbol default)
|
||||
(if (assoc symbol meta)
|
||||
(cdr (assoc symbol meta))
|
||||
default))
|
||||
|
||||
(define (run-external-compiler args cc? cc-prog cc-exec cc-lib cc-so
|
||||
cc-opts cc-prog-linker-opts cc-prog-linker-objs
|
||||
|
@ -819,11 +843,6 @@
|
|||
(else
|
||||
;; Account for any cond-expand declarations in the library
|
||||
(list (lib:cond-expand (car in-prog-raw) expander)))))
|
||||
;; how to collect these? would it be best if we write them to file
|
||||
;; and then we pick that file back up now?
|
||||
(c-linker-options 'todo)
|
||||
;; similar to above, may need to emit these and pick them back up now from file
|
||||
(lib-deps 'todo)
|
||||
;; Only read C compiler options from module being compiled
|
||||
(cc-opts*
|
||||
(cond
|
||||
|
@ -837,6 +856,7 @@
|
|||
" "))))
|
||||
(exec-file (basename in-file))
|
||||
(src-file (string-append exec-file ".c"))
|
||||
(meta-file (string-append exec-file ".meta"))
|
||||
(get-comp-env
|
||||
(lambda (sym str)
|
||||
(if (> (string-length str) 0)
|
||||
|
@ -846,7 +866,10 @@
|
|||
;; Compile the generated C file
|
||||
(cond
|
||||
(program?
|
||||
(letrec ((objs-str
|
||||
(letrec ((metadata (load-program-metadata meta-file))
|
||||
(c-linker-options (get-meta metadata 'c-linker-options '()))
|
||||
(lib-deps (get-meta metadata 'lib-deps '()))
|
||||
(objs-str
|
||||
(string-append
|
||||
cc-prog-linker-objs
|
||||
(apply
|
||||
|
|
Loading…
Add table
Reference in a new issue