From 512c6c49ccd19ca477eef515e24fa2537269d037 Mon Sep 17 00:00:00 2001 From: Eli Barzilay Date: Thu, 14 Aug 2008 14:31:35 +0000 Subject: [PATCH] misc improvements, quiet the C compilation/linking svn: r11240 --- collects/plot/extend.ss | 5 +- collects/plot/pre-installer.ss | 128 +++++++++++++++------------------ 2 files changed, 61 insertions(+), 72 deletions(-) diff --git a/collects/plot/extend.ss b/collects/plot/extend.ss index 29778c6988..e4c4ec113e 100644 --- a/collects/plot/extend.ss +++ b/collects/plot/extend.ss @@ -1,4 +1,4 @@ -#lang scheme +#lang scheme/base (require "plot-extend.ss" "renderer-helpers.ss" @@ -7,8 +7,7 @@ (provide (except-out (all-from-out "plot-extend.ss") define-plot-type) plot-view% - - + sample-size scale-vectors x-values diff --git a/collects/plot/pre-installer.ss b/collects/plot/pre-installer.ss index 5c72f45747..96db31bd53 100644 --- a/collects/plot/pre-installer.ss +++ b/collects/plot/pre-installer.ss @@ -1,72 +1,62 @@ -(module pre-installer mzscheme - (require mzlib/etc mzlib/file mzlib/list - dynext/file dynext/link dynext/compile) +#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] - [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)))))) +(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)) - (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)) - (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)))))) +(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)])) + (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 '()]) + (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))))))