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"
|
(require "plot-extend.ss"
|
||||||
"renderer-helpers.ss"
|
"renderer-helpers.ss"
|
||||||
|
@ -7,8 +7,7 @@
|
||||||
(provide (except-out (all-from-out "plot-extend.ss")
|
(provide (except-out (all-from-out "plot-extend.ss")
|
||||||
define-plot-type)
|
define-plot-type)
|
||||||
plot-view%
|
plot-view%
|
||||||
|
|
||||||
|
|
||||||
sample-size
|
sample-size
|
||||||
scale-vectors
|
scale-vectors
|
||||||
x-values
|
x-values
|
||||||
|
|
|
@ -1,72 +1,62 @@
|
||||||
(module pre-installer mzscheme
|
#lang scheme/base
|
||||||
(require mzlib/etc mzlib/file mzlib/list
|
(require scheme/runtime-path scheme/path scheme/file
|
||||||
dynext/file dynext/link dynext/compile)
|
dynext/file dynext/link dynext/compile)
|
||||||
|
|
||||||
(define top-dir (this-expression-source-directory))
|
(define-runtime-path top-dir ".")
|
||||||
(define src-dir (build-path top-dir "src"))
|
(define (from-top . ps) (simplify-path (apply build-path top-dir ps) #f))
|
||||||
(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 (build-library lib)
|
(define dir->libname '(["all" "libplplot"] ["fit" "libfit"]))
|
||||||
(when (and (directory-exists? lib)
|
(define src-dir (from-top "src"))
|
||||||
(not (member (path->string lib) '("CVS" ".svn"))))
|
(define tmp-dir (from-top "src/tmp"))
|
||||||
(let* ([libname (cond
|
(define sys-subpath (system-library-subpath #f))
|
||||||
[(assoc (path->string lib) dir->libname) => cadr]
|
(define native-dir (from-top "compiled" "native" sys-subpath))
|
||||||
[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
|
|
||||||
(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)))
|
|
||||||
(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)
|
|
||||||
(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)
|
|
||||||
(parameterize ([current-directory tmp-dir])
|
|
||||||
(link-extension #f (append
|
|
||||||
(directory-list tmp-dir)
|
|
||||||
(if (string=? "i386-cygwin"
|
|
||||||
(path->string (system-library-subpath #f)))
|
|
||||||
;; DLL needs every dependence explicit:
|
|
||||||
'("-lc" "-lm" "-lcygwin" "-lkernel32")
|
|
||||||
null))
|
|
||||||
so-name))
|
|
||||||
(delete-directory/files tmp-dir))))))
|
|
||||||
|
|
||||||
(provide pre-installer)
|
(define (build-library lib)
|
||||||
(define (pre-installer main-collects-parent-dir)
|
(define libname (cond [(assoc (path->string lib) dir->libname) => cadr]
|
||||||
(unless (directory-exists? src-dir)
|
[else (error 'plot-preinstaller
|
||||||
(error 'plot-preinstall "Could not find the source directory at ~a"
|
"Found an unknown source directory: ~s\n"
|
||||||
src-dir))
|
lib)]))
|
||||||
(when (directory-exists? src-dir)
|
(define so-name (build-path native-dir (append-extension-suffix libname)))
|
||||||
(unless (directory-exists? native-dir) (make-directory* native-dir))
|
(define c-files (filter (lambda (f)
|
||||||
(parameterize ([current-directory src-dir])
|
(regexp-match? "\\.[cC]$" (path->string f)))
|
||||||
(for-each build-library (directory-list))))))
|
(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 '()])
|
||||||
|
(when (or (not (file-exists? so-name))
|
||||||
|
(let ([so-time (file-or-directory-modify-seconds 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 ([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])
|
||||||
|
(let* ([o-files (directory-list)]
|
||||||
|
[flags (if (string=? "i386-cygwin" (path->string sys-subpath))
|
||||||
|
;; DLL needs every dependence explicit:
|
||||||
|
'("-lc" "-lm" "-lcygwin" "-lkernel32")
|
||||||
|
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)
|
||||||
|
(unless (directory-exists? src-dir)
|
||||||
|
(error 'plot-preinstall "Could not find the source directory at \"~a\""
|
||||||
|
src-dir))
|
||||||
|
(unless (directory-exists? native-dir) (make-directory* native-dir))
|
||||||
|
(parameterize ([current-directory src-dir])
|
||||||
|
(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