Changeset 12141


Ignore:
Timestamp:
May 27, 2009, 9:02:03 PM (10 years ago)
Author:
gb
Message:

Don't return GUI-ish break options string if we're on the AppKit? thread.
(Probably should have some other way to determine whether or not they're
appropriate.)

DON'T REQUIRE SWANK. Aside from other reasons for not wanting to do this,
doing so seems to clobber one or more of *TERMINAL-IO* or *STANDARD-OUTPUT*
in the initial thread. (Feel free to change this back if this doesn't affect
you or if you need to be able to load swank early; it did affect me, and
we should spend more time than I did trying to understand and fix the
clobbering.)

If we're running standalone, assume that we don't have interactive terminal
io, unless fd 0 is attached to something other than /dev/null. If we can
connect to AltConsole?, then that's a (primitive) kind of interactive terminal
i/o device (as may be swank or similar things someday.)

Note that if/when establishing a swank connection provides a stream that
the appkit thread can interact with, we may want to reset that thread so
that appropriate error handling behavior is used.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/source/cocoa-ide/start.lisp

    r12116 r12141  
    6363  (ui-object-exit-backtrace-context o (car args)))
    6464
     65(defmethod ccl::ui-object-do-operation ((o ns:ns-application) (operation (eql :break-options-string)) &rest args)
     66  (unless (typep ccl::*current-process* 'appkit-process)
     67    (destructuring-bind (continuablep) args
     68      (if continuablep
     69        "~&> Type cmd-/ to continue, cmd-/ to abort, cmd-\\ for a list of available restarts."
     70        "~&> Type cmd-. to abort, cmd-\\ for a list of available restarts.~%"))))
    6571
    6672;;; Support for saving a stand-alone IDE
     
    8591  (values nil nil nil nil))
    8692
     93#+no
    8794(eval-when (:compile-toplevel :load-toplevel :execute)
    8895    (require :swank))
     
    94101    (#_ _exit -1))
    95102  (setq *standalone-cocoa-ide* t)
    96   ;; It's probably reasonable to do this here: it's not really IDE-specific
    97   (try-starting-swank)
    98   (try-connecting-to-altconsole)
    99   ;; TODO: to avoid confusion, should now reset *cocoa-application-path* to
    100   ;; actual bundle path where started up.
    101   (start-cocoa-application))
    102 
    103 
    104 
    105 
    106 (defun build-ide (bundle-path)
    107   (setq bundle-path (ensure-directory-pathname bundle-path))
    108 
    109   ;; The bundle is expected to exist, we'll just add the executable into it.
    110   (assert (probe-file bundle-path))
    111 
    112   ;; Wait until we're sure that the Cocoa event loop has started.
    113   (wait-on-semaphore *cocoa-application-finished-launching*)
    114 
    115   (require :easygui)
    116 
    117   (ccl::maybe-map-objc-classes t)
    118   (let* ((missing ()))
    119     (ccl::do-interface-dirs (d)
    120       (ccl::cdb-enumerate-keys
    121        (ccl::db-objc-classes d)
    122        (lambda (name)
    123          (let* ((class (ccl::lookup-objc-class name nil)))
    124            (unless (ccl::objc-class-id  class) (push name missing))))))
    125     (when missing
    126       (break "ObjC classes ~{~&~a~} are declared but not defined." missing)))
    127 
    128   (ccl::touch bundle-path)
    129 
    130   (let ((image-file (make-pathname :name (ccl::standard-kernel-name) :type nil :version nil
    131                                    :defaults (merge-pathnames ";Contents;MacOS;" bundle-path))))
    132     (format *error-output* "~2%Saving application to ~a~2%" (truename bundle-path))
    133     (force-output *error-output*)
    134     (ensure-directories-exist image-file)
    135     (save-application image-file
    136                       :prepend-kernel t
    137                       :application-class 'cocoa-application)))
     103  (with-slots  (have-interactive-terminal-io) ccl::*current-process*
     104    (when (and (eql (nth-value 4 (ccl::%stat "/dev/null"))
     105                    (nth-value 4 (ccl::%fstat 0)))
     106             ;; Should compare st_dev, too
     107             )
     108      (setq have-interactive-terminal-io nil)
     109      ;; It's probably reasonable to do this here: it's not really IDE-specific
     110      #+no
     111      (try-starting-swank)
     112      (when (try-connecting-to-altconsole)
     113        (setq have-interactive-terminal-io t)))
     114    ;; TODO: to avoid confusion, should now reset *cocoa-application-path* to
     115    ;; actual bundle path where started up.
     116    (start-cocoa-application)))
     117
     118
     119
     120
     121  (defun build-ide (bundle-path)
     122    (setq bundle-path (ensure-directory-pathname bundle-path))
     123
     124    ;; The bundle is expected to exist, we'll just add the executable into it.
     125    (assert (probe-file bundle-path))
     126
     127    ;; Wait until we're sure that the Cocoa event loop has started.
     128    (wait-on-semaphore *cocoa-application-finished-launching*)
     129
     130    (require :easygui)
     131
     132    (ccl::maybe-map-objc-classes t)
     133    (let* ((missing ()))
     134      (ccl::do-interface-dirs (d)
     135        (ccl::cdb-enumerate-keys
     136         (ccl::db-objc-classes d)
     137         (lambda (name)
     138           (let* ((class (ccl::lookup-objc-class name nil)))
     139             (unless (ccl::objc-class-id  class) (push name missing))))))
     140      (when missing
     141        (break "ObjC classes ~{~&~a~} are declared but not defined." missing)))
     142
     143    (ccl::touch bundle-path)
     144
     145    (let ((image-file (make-pathname :name (ccl::standard-kernel-name) :type nil :version nil
     146                                     :defaults (merge-pathnames ";Contents;MacOS;" bundle-path))))
     147      (format *error-output* "~2%Saving application to ~a~2%" (truename bundle-path))
     148      (force-output *error-output*)
     149      (ensure-directories-exist image-file)
     150      (save-application image-file
     151                        :prepend-kernel t
     152                        :application-class 'cocoa-application)))
    138153
    139154;;; If we're running as a standalone .app, try to see if a bundle named
Note: See TracChangeset for help on using the changeset viewer.