misc improvements, quiet the C compilation/linking
svn: r11240
This commit is contained in:
parent
5ae44c581e
commit
512c6c49cc
|
@ -1,4 +1,4 @@
|
|||
#lang scheme
|
||||
#lang scheme/base
|
||||
|
||||
(require "plot-extend.ss"
|
||||
"renderer-helpers.ss"
|
||||
|
@ -8,7 +8,6 @@
|
|||
define-plot-type)
|
||||
plot-view%
|
||||
|
||||
|
||||
sample-size
|
||||
scale-vectors
|
||||
x-values
|
||||
|
|
|
@ -1,72 +1,62 @@
|
|||
(module pre-installer mzscheme
|
||||
(require mzlib/etc mzlib/file mzlib/list
|
||||
#lang scheme/base
|
||||
(require scheme/runtime-path scheme/path scheme/file
|
||||
dynext/file dynext/link dynext/compile)
|
||||
|
||||
(define top-dir (this-expression-source-directory))
|
||||
(define src-dir (build-path top-dir "src"))
|
||||
(define tmp-dir (build-path src-dir "tmp"))
|
||||
(define dir->libname '(["all" "libplplot"] ["fit" "libfit"]))
|
||||
(define native-dir
|
||||
(build-path top-dir "compiled" "native" (system-library-subpath #f)))
|
||||
(define-runtime-path top-dir ".")
|
||||
(define (from-top . ps) (simplify-path (apply build-path top-dir ps) #f))
|
||||
|
||||
(define (build-library lib)
|
||||
(when (and (directory-exists? lib)
|
||||
(not (member (path->string lib) '("CVS" ".svn"))))
|
||||
(let* ([libname (cond
|
||||
[(assoc (path->string lib) dir->libname) => cadr]
|
||||
(define dir->libname '(["all" "libplplot"] ["fit" "libfit"]))
|
||||
(define src-dir (from-top "src"))
|
||||
(define tmp-dir (from-top "src/tmp"))
|
||||
(define sys-subpath (system-library-subpath #f))
|
||||
(define native-dir (from-top "compiled" "native" sys-subpath))
|
||||
|
||||
(define (build-library lib)
|
||||
(define libname (cond [(assoc (path->string lib) dir->libname) => cadr]
|
||||
[else (error 'plot-preinstaller
|
||||
"Found an unknown source directory: ~s\n"
|
||||
lib)])]
|
||||
[so-name (build-path top-dir "compiled" "native"
|
||||
(system-library-subpath #f)
|
||||
(append-extension-suffix libname))])
|
||||
(parameterize ([current-directory lib]
|
||||
[current-extension-compiler-flags
|
||||
lib)]))
|
||||
(define so-name (build-path native-dir (append-extension-suffix libname)))
|
||||
(define c-files (filter (lambda (f)
|
||||
(regexp-match? "\\.[cC]$" (path->string f)))
|
||||
(directory-list)))
|
||||
(parameterize ([current-extension-compiler-flags
|
||||
(append (current-extension-compiler-flags)
|
||||
(case (system-type)
|
||||
[(windows) '("/DHAVE_LIBPNG" "/DPLD_png")]
|
||||
[else '("-DHAVE_LIBPNG" "-DPLD_png")]))]
|
||||
;; we compile a simple .so, not an extension
|
||||
[current-standard-link-libraries '()]
|
||||
)
|
||||
(define c-files (filter (lambda (f)
|
||||
(regexp-match "\\.[cC]$" (path->string f)))
|
||||
(directory-list)))
|
||||
[current-standard-link-libraries '()])
|
||||
(when (or (not (file-exists? so-name))
|
||||
(let ([so-time (file-or-directory-modify-seconds so-name)])
|
||||
(ormap (lambda (f)
|
||||
(> (file-or-directory-modify-seconds f)
|
||||
so-time))
|
||||
c-files)))
|
||||
(printf "plot: compiling \"~a\" -> \"~a\"...\n" lib so-name)
|
||||
(for/or ([f c-files])
|
||||
((file-or-directory-modify-seconds f) . > . so-time))))
|
||||
(printf "plot: compiling \"~a\" -> \"~a\"...\n"
|
||||
(find-relative-path (from-top) (current-directory))
|
||||
(find-relative-path (from-top) so-name))
|
||||
(make-directory* tmp-dir)
|
||||
(for-each (lambda (c-file)
|
||||
(compile-extension #f
|
||||
c-file
|
||||
(build-path tmp-dir
|
||||
(append-object-suffix
|
||||
(path-replace-suffix
|
||||
c-file
|
||||
#"")))
|
||||
null))
|
||||
c-files)
|
||||
(for ([c-file c-files])
|
||||
(let ([o-file (append-object-suffix (path-replace-suffix c-file #""))])
|
||||
;; first #t means quiet (here and in link-extension)
|
||||
(compile-extension #t c-file (build-path tmp-dir o-file) null)))
|
||||
(parameterize ([current-directory tmp-dir])
|
||||
(link-extension #f (append
|
||||
(directory-list tmp-dir)
|
||||
(if (string=? "i386-cygwin"
|
||||
(path->string (system-library-subpath #f)))
|
||||
(let* ([o-files (directory-list)]
|
||||
[flags (if (string=? "i386-cygwin" (path->string sys-subpath))
|
||||
;; DLL needs every dependence explicit:
|
||||
'("-lc" "-lm" "-lcygwin" "-lkernel32")
|
||||
null))
|
||||
so-name))
|
||||
(delete-directory/files tmp-dir))))))
|
||||
null)])
|
||||
(link-extension #t (append o-files flags) so-name)))
|
||||
(delete-directory/files tmp-dir))))
|
||||
|
||||
(provide pre-installer)
|
||||
(define (pre-installer main-collects-parent-dir)
|
||||
(provide pre-installer)
|
||||
(define (pre-installer main-collects-parent-dir)
|
||||
(unless (directory-exists? src-dir)
|
||||
(error 'plot-preinstall "Could not find the source directory at ~a"
|
||||
(error 'plot-preinstall "Could not find the source directory at \"~a\""
|
||||
src-dir))
|
||||
(when (directory-exists? src-dir)
|
||||
(unless (directory-exists? native-dir) (make-directory* native-dir))
|
||||
(parameterize ([current-directory src-dir])
|
||||
(for-each build-library (directory-list))))))
|
||||
(for ([path (directory-list)])
|
||||
(when (and (directory-exists? path)
|
||||
(not (member (path->string path) '("CVS" ".svn"))))
|
||||
(parameterize ([current-directory path])
|
||||
(build-library path))))))
|
||||
|
|
Loading…
Reference in New Issue
Block a user