Preparing to use paths from makefile

This commit is contained in:
Justin Ethier 2015-07-17 21:37:22 -04:00
parent 03c0c81edc
commit 021d1bee0f
5 changed files with 21 additions and 45 deletions

2
TODO
View file

@ -24,8 +24,6 @@ in addition, the chicken code can just hardwire it to the current directory or a
1) makefile needs to pass PREFIX when building the runtime lib 1) makefile needs to pass PREFIX when building the runtime lib
* purge (cyc:get-*-dir) functions
should only need these maybe for the chicken install.
* figure out how a build will go now. is it possible to build locally * figure out how a build will go now. is it possible to build locally
and test (which would be ideal) or is an install required? a and test (which would be ideal) or is an install required? a
compromise might be to require libs/includes be installed, but compromise might be to require libs/includes be installed, but

View file

@ -18,35 +18,17 @@
(cond-expand (cond-expand
(chicken (chicken
(define (Cyc-installation-dir) "home/justin/Documents/cyclone") (define (Cyc-installation-dir) "/home/justin/Documents/cyclone")
;; TODO: nuke all the other defs below, this is the only one to base installed locations on
;; TODO: will need to read these from env somehow.
;; for now they are just hard-coded, but that won't work for an install
(define (cyc:get-lib-dir) "/home/justin/Documents/cyclone/")
(define (cyc:get-clib-dir) "/home/justin/Documents/cyclone/")
(define (cyc:get-include-dir) "/home/justin/Documents/cyclone/")
;; END TODO
(require-extension extras) ;; pretty-print (require-extension extras) ;; pretty-print
(require-extension chicken-syntax) ;; when (require-extension chicken-syntax) ;; when
(require-extension srfi-1) ;; every (require-extension srfi-1) ;; every
(load (string-append (cyc:get-lib-dir) "scheme/cyclone/common.so")) (load (string-append (Cyc-installation-dir) "/scheme/cyclone/common.so"))
(load (string-append (cyc:get-lib-dir) "parser.so")) (load (string-append (Cyc-installation-dir) "/parser.so"))
(load (string-append (cyc:get-lib-dir) "util.so")) (load (string-append (Cyc-installation-dir) "/util.so"))
(load (string-append (cyc:get-lib-dir) "libraries.so")) (load (string-append (Cyc-installation-dir) "/libraries.so"))
(load (string-append (cyc:get-lib-dir) "transforms.so")) (load (string-append (Cyc-installation-dir) "/transforms.so"))
(load (string-append (cyc:get-lib-dir) "cgen.so"))) (load (string-append (Cyc-installation-dir) "/cgen.so")))
(else #f)) (else #f))
;; (husk
;; (import (husk pretty-print))
;; ;; TODO: load files
;; )
; (else
; (load (string-append (cyc:get-lib-dir) "parser.scm"))
; (load (string-append (cyc:get-lib-dir) "util.scm"))
; (load (string-append (cyc:get-lib-dir) "libraries.scm"))
; (load (string-append (cyc:get-lib-dir) "transforms.scm"))
; (load (string-append (cyc:get-lib-dir) "cgen.scm"))))
;; Code emission. ;; Code emission.
@ -271,7 +253,12 @@
(result (create-c-file in-prog))) (result (create-c-file in-prog)))
;; Compile the generated C file ;; Compile the generated C file
(define (Cyc-installation-lib-dir) "") ; /lib/cyclone
(define (Cyc-installation-inc-dir) "") ; /inc/cyclone
;; TODO: -I is a hack, real answer is to use 'make install' to place .h file ;; TODO: -I is a hack, real answer is to use 'make install' to place .h file
;; TODO: real answer is to get rid of -I and -L below, and assume header and libs are
;; already installed on the system. this is OK since we are going to have a place
;; to bootstrap cyclone from, so it will always be installed.
(cond (cond
(program? (program?
(letrec ((objs-str (letrec ((objs-str
@ -282,9 +269,9 @@
(string-append " " (lib:import->filename i ".o") " ")) (string-append " " (lib:import->filename i ".o") " "))
lib-deps))) lib-deps)))
(comp-prog-cmd (comp-prog-cmd
(string-append "gcc " src-file " -I" (cyc:get-include-dir) " -g -c -o " exec-file ".o")) (string-append "gcc " src-file " -I" (Cyc-installation-dir) (Cyc-installation-inc-dir) " -g -c -o " exec-file ".o"))
(comp-objs-cmd (comp-objs-cmd
(string-append "gcc " exec-file ".o " objs-str " -L" (cyc:get-clib-dir) " -lcyclone -lm -I" (cyc:get-include-dir) " -g -o " exec-file))) (string-append "gcc " exec-file ".o " objs-str " -L" (Cyc-installation-dir) (Cyc-installation-lib-dir) " -lcyclone -lm -I" (Cyc-installation-dir) (Cyc-installation-inc-dir) " -g -o " exec-file)))
;(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)))) ;(write `(DEBUG ,(lib:get-all-import-deps (cdar in-prog))))
(cond (cond
@ -296,7 +283,7 @@
(write comp-objs-cmd))))) (write comp-objs-cmd)))))
(else (else
(let ((comp-lib-cmd (let ((comp-lib-cmd
(string-append "gcc " src-file " -I" (cyc:get-include-dir) " -g -c -o " exec-file ".o"))) (string-append "gcc " src-file " -I" (Cyc-installation-dir) (Cyc-installation-inc-dir) " -g -c -o " exec-file ".o")))
(cond (cond
(cc? (cc?
(system comp-lib-cmd)) (system comp-lib-cmd))

View file

@ -13,13 +13,6 @@
;; not a very clean or nice API at the moment. ;; not a very clean or nice API at the moment.
;; ;;
;; TODO: this definition is just temporary until we figure out how to get this info.
;; this is problematic as it has to work for the bootstrap and the actual cyclone comp.
;; although I suppose it would be OK if you have to bootstrap from a hardcoded dir
(define (cyc:get-lib-dir) "/home/justin/Documents/cyclone/")
(define (cyc:get-clib-dir) "/home/justin/Documents/cyclone/")
(define (cyc:get-include-dir) "/home/justin/Documents/cyclone/")
(define (library? ast) (define (library? ast)
(tagged-list? 'define-library ast)) (tagged-list? 'define-library ast))
@ -66,6 +59,9 @@
;; TODO: include-ci, cond-expand ;; TODO: include-ci, cond-expand
(define (Cyc-installation-sld-dir) "")
;(define (Cyc-installation-sld-dir) "/share/cyclone")
;; Resolve library filename given an import. ;; Resolve library filename given an import.
;; Assumes ".sld" file extension if one is not specified. ;; Assumes ".sld" file extension if one is not specified.
(define (lib:import->filename import . ext) (define (lib:import->filename import . ext)
@ -85,7 +81,7 @@
(filename (filename
(substring filename* 1 (string-length filename*)))) (substring filename* 1 (string-length filename*))))
(if (tagged-list? 'scheme import) (if (tagged-list? 'scheme import)
(string-append (cyc:get-lib-dir) filename) ;; Built-in library (string-append (Cyc-installation-dir) (Cyc-installation-sld-dir) "/" filename) ;; Built-in library
filename))) filename)))
;; Get path to directory that contains the library ;; Get path to directory that contains the library
@ -99,7 +95,7 @@
(string-append (symbol->string i) "/")) (string-append (symbol->string i) "/"))
import-path)))) import-path))))
(if (tagged-list? 'scheme import) (if (tagged-list? 'scheme import)
(string-append (cyc:get-lib-dir) path) ;; Built-in library (string-append (Cyc-installation-dir) (Cyc-installation-sld-dir) "/" path) ;; Built-in library
path))) path)))
;; Given a program's import set, resolve each import to its .o file, then ;; Given a program's import set, resolve each import to its .o file, then

View file

@ -4,9 +4,6 @@
(scheme cyclone util) (scheme cyclone util)
) )
(export (export
cyc:get-clib-dir
cyc:get-lib-dir
cyc:get-include-dir
library? library?
lib:name lib:name
lib:name->string lib:name->string

View file

@ -8,8 +8,6 @@
;; ;;
(cond-expand (cond-expand
; (chicken
; (load (string-append (cyc:get-lib-dir) "scheme/common.scm")))
(cyclone (cyclone
;; Temporary work-around for pp not being implemented yet ;; Temporary work-around for pp not being implemented yet
(define pretty-print write)) (define pretty-print write))