Changeset 13041


Ignore:
Timestamp:
11/21/10 19:40:25 (10 years ago)
Author:
Mark Evenson
Message:

Reworked Lisp-based build now works for ecl.

Based on a patch from Pascal J. Bourguignon.

Refactored elements of Lisp-based build to improve error handling and
present more of a informative view of what is occuring.

Location:
trunk/abcl
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • trunk/abcl/build-abcl.lisp

    r13039 r13041  
    2222
    2323(defun safe-namestring (pathname)
    24   (let* ((string (namestring pathname))
    25          (len (length string)))
     24  (let ((string (namestring pathname)))
    2625    (when (position #\space string)
    2726      (setf string (concatenate 'string "\""
     
    7069  (cond ((member :win32 *features*)
    7170         :windows)
    72         ((zerop (ext:run-shell-command "uname | grep -i darwin" :output nil))
     71        ((equal 0 (ext:run-shell-command "uname | grep -i darwin" :output nil))
    7372         :darwin)
    74         ((zerop (ext:run-shell-command "uname | grep -i linux" :output nil))
     73        ((equal 0 (ext:run-shell-command "uname | grep -i linux" :output nil))
    7574         :linux)
    7675        (t
     
    9594                               command)))
    9695  (sb-ext:process-exit-code
    97    (sb-ext:run-program
     96   (sb-ext:run-program 
    9897    "/bin/sh"
    9998    (list  "-c" command)
     
    169168    exitcode))
    170169
    171 #+(or sbcl cmu lispworks openmcl)
     170#+ecl
     171(defun run-shell-command (command &key directory (output *standard-output*))
     172  (when directory
     173    (if (member :windows *features*)
     174        (error "Unimplemented.")
     175        (setf command (concatenate 'string
     176                                   "\\cd \""
     177                                   (namestring (pathname directory))
     178                                   "\" && "
     179                                   command))))
     180  (ext:system command))
     181  ;; (multiple-value-bind (stream exit details)
     182  ;;     (ext:run-program
     183  ;;      "/bin/sh" (list "-c" command)
     184  ;;      :input nil :output :stream :error :output)
     185  ;;   (declare (ignore details))
     186  ;;   (loop for line = (read-line stream nil)
     187  ;;      while line do (format output "~A~%" line))
     188  ;;   exit))
     189
     190
     191#+(or sbcl cmu lispworks openmcl ecl)
    172192(defun probe-directory (pathspec)
    173193  (let* ((truename (probe-file pathspec)) ; TRUENAME is a pathname.
     
    286306(defun java-compile-file (source-file)
    287307  (let ((cmdline (build-javac-command-line source-file)))
    288     (zerop (run-shell-command cmdline :directory *abcl-dir*))))
    289 
    290 (defun make-classes (force batch)
     308    (equal 0 (run-shell-command cmdline :directory *abcl-dir*))))
     309
     310(defun do-compile-classes (force batch)
    291311  (let* ((source-files
    292312          (remove-if-not
     
    300320                 (or force
    301321                     (file-newer name output-name))))
    302            (mapcan #'(lambda (default)
    303                        (directory (merge-pathnames "*.java"
    304                                                    default)))
    305                    (list *abcl-dir*
    306                          (merge-pathnames "util/" *abcl-dir*))))))
     322           (directory (merge-pathnames "**/*.java" *source-root*)))))
    307323    (format t "~&JDK: ~A~%" *jdk*)
    308324    (format t "Java compiler: ~A~%" *java-compiler*)
    309325    (format t "Compiler options: ~A~%~%" (if *java-compiler-options* *java-compiler-options* ""))
     326    (format t "~&Compiling Java sources...")
    310327    (finish-output)
    311328    (cond ((null source-files)
     
    316333           (cond (batch
    317334                  (ensure-directories-exist *build-root*)
    318                   (let* ((dir (pathname-directory *abcl-dir*))
    319                          (cmdline (with-output-to-string (s)
     335                  (let* ((cmdline (with-output-to-string (s)
    320336                                    (princ *java-compiler-command-line-prefix* s)
    321337                                    (princ " -d " s)
     
    323339                                    (princ #\Space s)
    324340                                    (dolist (source-file source-files)
    325                                       (princ
    326                                        (safe-namestring
    327                                         (if (equal (pathname-directory source-file) dir)
    328                                             (file-namestring source-file)
    329                                             (namestring source-file)))
    330                                        s)
     341                                      (princ (safe-namestring (namestring source-file)) s)
    331342                                      (princ #\space s))))
    332                          (status (run-shell-command cmdline :directory *abcl-dir*)))
    333                     (zerop status)))
     343                         (status (run-shell-command cmdline :directory *tree-root*)))
     344                    (format t "  done.~%")
     345                    (equal 0 status)))
    334346                 (t
    335347                  (ensure-directories-exist *build-root*)
     
    351363      (ensure-directories-exist *dist-root*)
    352364      (let ((status (run-shell-command command :directory *tree-root*)))
    353         (unless (zerop status)
     365        (unless (equal 0 status)
    354366          (format t "~A returned ~S~%" command status))
    355367        status))))
    356368
    357369(defun do-compile-system (&key (zip t))
     370  (format t "~&Compiling Lisp sources...")
    358371  (terpri)
    359372  (finish-output)
     
    380393                          output-path)))
    381394    (ensure-directories-exist output-path)
    382     (setf status
    383           (run-shell-command cmdline
    384                              :directory *tree-root*))
     395    (setf status (run-shell-command cmdline :directory *tree-root*))
     396    (format t " done.~%")
    385397    status))
    386398
     
    434446
    435447(defun clean ()
     448  (format t "~&Cleaning compilation results."
    436449  (dolist (f (list (list *tree-root* "abcl.jar" "abcl.bat" "make-jar.bat"
    437450                         "compile-system.bat")
     
    482495    (when clean
    483496      (clean))
    484     ;; classes
    485     (unless (make-classes force batch)
     497    ;; Compile Java source into classes
     498    (unless (do-compile-classes force batch)
    486499      (format t "Build failed.~%")
    487500      (return-from build-abcl nil))
     
    490503      (let* ((zip    (if (or full jar) nil t))
    491504             (status (do-compile-system :zip zip)))
    492         (unless (zerop status)
     505        (unless (equal 0 status)
    493506          (format t "Build failed.~%")
    494507          (return-from build-abcl nil))))
     
    496509    (when (or full jar)
    497510      (let ((status (make-jar)))
    498         (unless (zerop status)
     511        (unless (equal 0 status)
    499512          (format t "Build failed.~%")
    500513          (return-from build-abcl nil))))
     
    519532                    (princ "--main=org.armedbear.lisp.Main -o lisp" s)))
    520533         (result (run-shell-command cmdline :directory *abcl-dir*)))
    521     (zerop result)))
     534    (equal 0 result)))
    522535
    523536(defvar *copy-verbose* nil)
     
    592605                            version-string version-string))
    593606           (status (run-shell-command command :directory parent-dir)))
    594       (unless (zerop status)
     607      (unless (equal 0 status)
    595608        (format t "~A returned ~S~%" command status)))
    596609    (let* ((command (format nil "zip -q -r ~A~A.zip ~A"
     
    598611                            version-string version-string))
    599612           (status (run-shell-command command :directory parent-dir)))
    600       (unless (zerop status)
     613      (unless (equal 0 status)
    601614        (format t "~A returned ~S~%" command status)))))
  • trunk/abcl/build-from-lisp.sh

    r12052 r13041  
    7373}
    7474
     75ecl()
     76{
     77    exec "$1" -norc -load "$2" -eval "(progn $3 (ext:quit))"
     78}
     79
    7580clisp()
    7681{
     
    121126        notimplemented "$IMPL" "$FILE" "$FORM" ;;
    122127    ecl*)
    123         notimplemented "$IMPL" "$FILE" "$FORM" ;;
     128        ecl   "$IMPL" "$FILE" "$FORM"          ;;
    124129    alisp*)
    125130        notimplemented "$IMPL" "$FILE" "$FORM" ;;
Note: See TracChangeset for help on using the changeset viewer.