-
Notifications
You must be signed in to change notification settings - Fork 7
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
add "cc.rkt" to compile "callbacks.c"
Use some indirection to avoid a package dependency on `dynext-lib`, since the intent is for "cc.rkt" to be used manually.
- Loading branch information
1 parent
77a03c8
commit 9b09c3f
Showing
1 changed file
with
64 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,64 @@ | ||
#lang racket | ||
|
||
;; Compile "callbacks.c" using Racket's suggested compiler and flags. | ||
|
||
;; Heavily based on Sam Tobin-Hochstadt's bcrypt/private/install.rkt | ||
;; https://github.com/samth/bcrypt.rkt | ||
|
||
(require racket/file | ||
racket/runtime-path | ||
(for-syntax syntax/transformer)) | ||
|
||
(define-syntax-rule (require-without-pkg-dep lib name) | ||
(begin (define tmp | ||
(let* ([v #f] | ||
[name (λ () | ||
(unless v | ||
(set! v (dynamic-require 'lib 'name))) | ||
v)]) | ||
name)) | ||
(define-syntax name | ||
(make-variable-like-transformer #'(tmp))))) | ||
|
||
(require-without-pkg-dep dynext/file append-extension-suffix) | ||
(require-without-pkg-dep dynext/link current-use-mzdyn) | ||
(require-without-pkg-dep dynext/link current-extension-linker-flags) | ||
(require-without-pkg-dep dynext/link link-extension) | ||
|
||
(define-runtime-path callbacks.c | ||
"callbacks.c") | ||
|
||
(define lib/ | ||
(path-only callbacks.c)) | ||
|
||
(define (so-path-elem) | ||
(append-extension-suffix "callbacks")) | ||
|
||
(define (cc [so-path (build-path lib/ | ||
(system-library-subpath #f) | ||
(so-path-elem))] | ||
#:overwrite? [overwrite? #t]) | ||
(parameterize ([current-use-mzdyn #f] | ||
[current-extension-linker-flags | ||
(if (eq? 'macosx (system-type 'os)) | ||
(list* "-mmacosx-version-min=10.5" | ||
(current-extension-linker-flags)) | ||
(current-extension-linker-flags))]) | ||
(when (and overwrite? (file-exists? so-path)) | ||
(delete-file so-path)) | ||
(make-parent-directory* so-path) | ||
(link-extension #f ;; not quiet | ||
(list callbacks.c) | ||
so-path))) | ||
|
||
(define (cc/i386-macosx) | ||
(unless (eq? 'macosx (system-type 'os)) | ||
(raise-arguments-error 'cc/i386-macosx | ||
"unsupported system type" | ||
"expected" 'macosx | ||
"given" (system-type 'os))) | ||
(parameterize ([current-extension-linker-flags | ||
(list* "-arch" | ||
"i386" | ||
(current-extension-linker-flags))]) | ||
(cc (build-path lib/ "i386-macosx" (so-path-elem))))) |