Supporting foreign library dependencies for chibi.

This commit is contained in:
Alex Shinn 2015-05-09 21:52:07 +09:00
parent 2f27dbb5bc
commit d96f1c9fc5
3 changed files with 36 additions and 16 deletions

View file

@ -1781,21 +1781,36 @@
(else ".so")))) (else ".so"))))
(so-flags (cond-expand (macosx '("-dynamiclib" "-Oz")) (so-flags (cond-expand (macosx '("-dynamiclib" "-Oz"))
(else '("-fPIC" "-shared" "-Os")))) (else '("-fPIC" "-shared" "-Os"))))
(cc-cmd (append cc cflags so-flags (lib-flags
(if local-test? '("-Iinclude" "-L.") '()) (map (lambda (lib) (string-append "-l" lib))
`("-o" ,so-file ,c-file "-lchibi-scheme")))) (library-foreign-dependencies impl cfg library)))
(and (or (file-exists? c-file) (ffi-cmd
(and (file-exists? stub-file) `(,@chibi-ffi
(or (and (system? (append chibi-ffi (list stub-file))) "-c" "-cc" ,(car cc)
(file-exists? c-file)) "-f" ,(string-join cflags " ")
(yes-or-no? cfg "couldn't generate c from stub: " "-f" ,(string-join lib-flags " ")
stub-file " - install anyway?"))) ,@(if local-test? '("-f" "-Iinclude -L.") '())
(yes-or-no? cfg "can't find ffi stub or c source for: " ,@(if (pair? (cdr cc))
base " - install anyway?")) (list "-f" (string-join (cdr cc) " "))
(or (system? cc-cmd) '())
(yes-or-no? cfg "couldn't compile chibi ffi c code: " ,stub-file))
c-file " - install anyway?")) (cc-cmd
(lp (cdr ls)))))))) `(,@cc ,@cflags ,@so-flags
,@(if local-test? '("-Iinclude" "-L.") '())
"-o" ,so-file ,c-file "-lchibi-scheme"
,@lib-flags)))
(when (or (and (file-exists? c-file)
(or (system? cc-cmd)
(yes-or-no?
cfg "couldn't compile chibi ffi c code: "
c-file " - install anyway?")))
(and (file-exists? stub-file)
(or (system? ffi-cmd)
(yes-or-no? cfg "couldn't compile stub: "
stub-file " - install anyway?")))
(yes-or-no? cfg "can't find ffi stub or c source for: "
base " - install anyway?"))
(lp (cdr ls))))))))
(define (chicken-builder impl cfg library dir) (define (chicken-builder impl cfg library dir)
(let* ((library-file (make-path dir (get-library-file cfg library))) (let* ((library-file (make-path dir (get-library-file cfg library)))

View file

@ -394,6 +394,11 @@
(lambda (x) (or (and (pair? x) (eq? 'depends (car x)) (cdr x)) '())) (lambda (x) (or (and (pair? x) (eq? 'depends (car x)) (cdr x)) '()))
(cdr (library-for-impl impl cfg lib)))) (cdr (library-for-impl impl cfg lib))))
(define (library-foreign-dependencies impl cfg lib)
(append-map
(lambda (x) (or (and (pair? x) (eq? 'foreign-depends (car x)) (cdr x)) '()))
(cdr (library-for-impl impl cfg lib))))
(define (parse-library-name str) (define (parse-library-name str)
(cond (cond
((pair? str) str) ((pair? str) str)

View file

@ -14,7 +14,7 @@
library-name->path library->path get-library-file find-library-file library-name->path library->path get-library-file find-library-file
library-url library-name parse-library-name library-name->path library-url library-name parse-library-name library-name->path
library-analyze library-include-files library-dependencies library-analyze library-include-files library-dependencies
library-shared-include-files library-shared-include-files library-foreign-dependencies
library-rewrite-includes library-file-name library-rewrite-includes library-file-name
get-program-file program-name program-install-name get-program-file program-name program-install-name
invalid-package-reason valid-package? invalid-package-reason valid-package?