diff --git a/cyclone.scm b/cyclone.scm index 6ab58f1e..53079e80 100644 --- a/cyclone.scm +++ b/cyclone.scm @@ -754,17 +754,6 @@ " " lib-options) lib-options))) - ;; Only read C compiler options from module being compiled - (cc-opts* - (cond - (program? - (string-join ;; Check current program for options - (program-c-compiler-opts! in-prog) - " ")) - (else - (string-join - (lib:c-compiler-options (car in-prog)) - " ")))) (exec-file (basename in-file)) (src-file (string-append exec-file ".c")) (meta-file (string-append exec-file ".meta")) @@ -803,9 +792,57 @@ lib-deps) in-file append-dirs - prepend-dirs))))) - (result (create-c-file in-prog))) + prepend-dirs)))))) + (create-c-file in-prog) + (when (not program?) + ;; 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))))))) +(define (run-external-compiler args cc? cc-prog cc-exec cc-lib cc-so + cc-opts cc-prog-linker-opts cc-prog-linker-objs + append-dirs prepend-dirs) + (let* ((in-file (car args)) + (expander (base-expander)) + (in-prog-raw (read-file in-file)) + (program? (not (library? (car in-prog-raw)))) + (in-prog + (cond + (program? + (Cyc-add-feature! 'program) ;; Load special feature + ;; TODO: what about top-level cond-expands in the program? + in-prog-raw) + (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 + (program? + (string-join ;; Check current program for options + (program-c-compiler-opts! in-prog) + " ")) + (else + (string-join + (lib:c-compiler-options (car in-prog)) + " ")))) + (exec-file (basename in-file)) + (src-file (string-append exec-file ".c")) + (get-comp-env + (lambda (sym str) + (if (> (string-length str) 0) + str + (Cyc-compilation-environment sym)))) + ) ;; Compile the generated C file (cond (program? @@ -857,13 +894,6 @@ (display comp-objs-cmd) (newline))))) (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)))) ;; Compile library (let ((comp-lib-cmd (string-append @@ -1075,5 +1105,10 @@ Debug options: (exit 1))) (run-compiler non-opts compile? cc-prog cc-exec cc-lib cc-so cc-opts cc-linker-opts cc-linker-extra-objects - append-dirs prepend-dirs))))) + append-dirs prepend-dirs) + (run-external-compiler non-opts compile? cc-prog cc-exec cc-lib cc-so + cc-opts cc-linker-opts cc-linker-extra-objects + append-dirs prepend-dirs) + + ))))