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,20 +1781,35 @@
(else ".so"))))
(so-flags (cond-expand (macosx '("-dynamiclib" "-Oz"))
(else '("-fPIC" "-shared" "-Os"))))
(cc-cmd (append cc cflags so-flags
(if local-test? '("-Iinclude" "-L.") '())
`("-o" ,so-file ,c-file "-lchibi-scheme"))))
(and (or (file-exists? c-file)
(lib-flags
(map (lambda (lib) (string-append "-l" lib))
(library-foreign-dependencies impl cfg library)))
(ffi-cmd
`(,@chibi-ffi
"-c" "-cc" ,(car cc)
"-f" ,(string-join cflags " ")
"-f" ,(string-join lib-flags " ")
,@(if local-test? '("-f" "-Iinclude -L.") '())
,@(if (pair? (cdr cc))
(list "-f" (string-join (cdr cc) " "))
'())
,stub-file))
(cc-cmd
`(,@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 (and (system? (append chibi-ffi (list stub-file)))
(file-exists? c-file))
(yes-or-no? cfg "couldn't generate c from stub: "
(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?"))
(or (system? cc-cmd)
(yes-or-no? cfg "couldn't compile chibi ffi c code: "
c-file " - install anyway?"))
(lp (cdr ls))))))))
(define (chicken-builder impl cfg library dir)

View file

@ -394,6 +394,11 @@
(lambda (x) (or (and (pair? x) (eq? 'depends (car x)) (cdr x)) '()))
(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)
(cond
((pair? str) str)

View file

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