mirror of
https://github.com/justinethier/cyclone.git
synced 2025-05-20 14:19:17 +02:00
Allow C compiler/linker options from a library to be expanded via cond-expand
This commit is contained in:
parent
c82e69a997
commit
209050b2d4
3 changed files with 18 additions and 10 deletions
|
@ -6,6 +6,7 @@ Features
|
||||||
|
|
||||||
- Arthur Maciel added `opaque?` and `opaque-null?` predicates to `(cyclone foreign)`.
|
- Arthur Maciel added `opaque?` and `opaque-null?` predicates to `(cyclone foreign)`.
|
||||||
- Added `import-shared-object` to `(scheme eval)` to allow loading a third party C shared library.
|
- Added `import-shared-object` to `(scheme eval)` to allow loading a third party C shared library.
|
||||||
|
- Allow C compiler/linker options from a library to be expanded via `cond-expand`.
|
||||||
|
|
||||||
Bug Fixes
|
Bug Fixes
|
||||||
|
|
||||||
|
|
|
@ -741,7 +741,7 @@
|
||||||
'()))
|
'()))
|
||||||
;; Read all linker options from dependent libs
|
;; Read all linker options from dependent libs
|
||||||
(c-linker-options
|
(c-linker-options
|
||||||
(let ((lib-options (lib:get-all-c-linker-options lib-deps append-dirs prepend-dirs)))
|
(let ((lib-options (lib:get-all-c-linker-options lib-deps append-dirs prepend-dirs expander)))
|
||||||
(if program?
|
(if program?
|
||||||
(string-append ;; Also read from current program
|
(string-append ;; Also read from current program
|
||||||
(string-join (program-c-linker-opts! in-prog) " ")
|
(string-join (program-c-linker-opts! in-prog) " ")
|
||||||
|
@ -791,7 +791,8 @@
|
||||||
(lib:get-all-c-linker-options
|
(lib:get-all-c-linker-options
|
||||||
lib-deps
|
lib-deps
|
||||||
append-dirs
|
append-dirs
|
||||||
prepend-dirs))
|
prepend-dirs
|
||||||
|
expander))
|
||||||
;; Return new deps
|
;; Return new deps
|
||||||
lib-deps)
|
lib-deps)
|
||||||
in-file
|
in-file
|
||||||
|
|
|
@ -434,37 +434,43 @@
|
||||||
(close-input-port fp)
|
(close-input-port fp)
|
||||||
includes))
|
includes))
|
||||||
|
|
||||||
(define (lib:read-c-linker-options import append-dirs prepend-dirs)
|
(define (lib:read-c-linker-options import append-dirs prepend-dirs expander)
|
||||||
(let* ((lib-name (lib:import->library-name import))
|
(let* ((lib-name (lib:import->library-name import))
|
||||||
(dir (lib:import->filename lib-name ".sld" append-dirs prepend-dirs))
|
(dir (lib:import->filename lib-name ".sld" append-dirs prepend-dirs))
|
||||||
(fp (open-input-file dir))
|
(fp (open-input-file dir))
|
||||||
(lib (read-all fp))
|
(lib (read-all fp))
|
||||||
(options (lib:c-linker-options (car lib))))
|
(lib* (if expander
|
||||||
|
(list (lib:cond-expand (car lib) expander))
|
||||||
|
lib))
|
||||||
|
(options (lib:c-linker-options (car lib*))))
|
||||||
(close-input-port fp)
|
(close-input-port fp)
|
||||||
(string-join options " ")))
|
(string-join options " ")))
|
||||||
|
|
||||||
(define (lib:get-all-c-linker-options imports append-dirs prepend-dirs)
|
(define (lib:get-all-c-linker-options imports append-dirs prepend-dirs expander)
|
||||||
(string-join
|
(string-join
|
||||||
(map
|
(map
|
||||||
(lambda (import)
|
(lambda (import)
|
||||||
(lib:read-c-linker-options import append-dirs prepend-dirs))
|
(lib:read-c-linker-options import append-dirs prepend-dirs expander))
|
||||||
imports)
|
imports)
|
||||||
" "))
|
" "))
|
||||||
|
|
||||||
(define (lib:read-c-compiler-options import append-dirs prepend-dirs)
|
(define (lib:read-c-compiler-options import append-dirs prepend-dirs expander)
|
||||||
(let* ((lib-name (lib:import->library-name import))
|
(let* ((lib-name (lib:import->library-name import))
|
||||||
(dir (lib:import->filename lib-name ".sld" append-dirs prepend-dirs))
|
(dir (lib:import->filename lib-name ".sld" append-dirs prepend-dirs))
|
||||||
(fp (open-input-file dir))
|
(fp (open-input-file dir))
|
||||||
(lib (read-all fp))
|
(lib (read-all fp))
|
||||||
(options (lib:c-compiler-options (car lib))))
|
(lib* (if expander
|
||||||
|
(list (lib:cond-expand (car lib) expander))
|
||||||
|
lib))
|
||||||
|
(options (lib:c-compiler-options (car lib*))))
|
||||||
(close-input-port fp)
|
(close-input-port fp)
|
||||||
(string-join options " ")))
|
(string-join options " ")))
|
||||||
|
|
||||||
(define (lib:get-all-c-compiler-options imports append-dirs prepend-dirs)
|
(define (lib:get-all-c-compiler-options imports append-dirs prepend-dirs expander)
|
||||||
(string-join
|
(string-join
|
||||||
(map
|
(map
|
||||||
(lambda (import)
|
(lambda (import)
|
||||||
(lib:read-c-compiler-options import append-dirs prepend-dirs))
|
(lib:read-c-compiler-options import append-dirs prepend-dirs expander))
|
||||||
imports)
|
imports)
|
||||||
" "))
|
" "))
|
||||||
|
|
||||||
|
|
Loading…
Add table
Reference in a new issue