Opened 7 years ago

Last modified 7 years ago

#955 new defect

build-applications generates an application that tries to load the file used to generate the application.

Reported by: pjb@… Owned by: gb
Priority: normal Milestone:
Component: IDE Version: 1.7
Keywords: Cc:

Description

I have a file named generate-application.lisp:

;; (ql:quickload :application)

(require :cocoa)
(require :build-application)

(defmethod  ccl:application-init-file :around (app)
  (declare (ignorable app))
  (make-pathname :name  "application-init" :type "lisp"
                 :defaults (user-homedir-pathname)))

(ccl::build-application
 :name "application"
 :directory #P"~/Desktop/"
 :copy-ide-resources t)

I use it with a Makefile that does:

application:clean
   ccl -n -b -e  '(load "generate-application.lisp")' -e '(ccl:quit)'

The application is generated successfully; when I launch it, I get the following error in the listener window:

> Error: File "generate-application.lisp" does not exist.
> While executing: CCL::%LOAD, in process Listener(6).
> Type cmd-/ to continue, cmd-. to abort, cmd-\ for a list of available restarts.
> If continued: Skip evaluation of (load "generate-application.lisp")
> Type :? for other options.
1 > 

using --load instead of --eval gives the same result.

Change History (2)

comment:1 Changed 7 years ago by gb

(In [15327]) cocoa-ide/builder-utilites.lisp: in MAKE-DOCTYPE-DICT, declare unused keyword args to be ignorable.

cocoa-ide/cocoa-application.lisp, objc-bridge/objc-runtime.lisp: move code which nukes NXArgc/NXArgv to a point just before Cocoa is loaded, where it seems to work as intended. This makes it safer than it has been to (REQUIRE "COCOA") in a lisp that was started with command-line arguments.

See ticket:955, and likely some others.

comment:2 Changed 7 years ago by gb

  • Owner set to gb

It generally doesn't work to do (require :cocoa) from a lisp session started with command-line arguments. Those arguments are passed to the Cocoa framework, which may try to interpret them (if you change your "generate-application" file to call (sleep 10) before calling BUILD-APPLICATION, you'll likely see a dialog that gives a clue as to how Cocoa interprets '-e' ...). I don't know that Cocoa's processing of command-line options is documented anywhere, don't know if it's actually used on OSX or just leftover from !NextSTEP, and don't know if its misinterpretation of command-line args is always benign.

The lisp-side bug here is that the results of processing command-line args in the session used to save an image persist in the saved image (and may not be reinitialized if that image processes command-line arguments differently or effectively doesn't process them at all, as is the case with an event-driven Cocoa application.) That doesn't have anything to do with BUILD-APPLICATION, but it's certainly worth fixing.

The simplest workaround for both problems is to change your Makefile rule to something like:

application:clean
   ccl < generate-application.lisp

or otherwise refrain from using command-line args. (No, that isn't exactly the same as what you're doing. The result of processing -n also persists in the saved image; I don't know if -b (or -n) are processed by Cocoa or how they would be if so.)

r15326 makes the effects of processing -e/-n/-l options (and equivalents) per-session, and r15327 tries to prevent Cocoa from processing the command-line args with which CCL was invoked. These changes will likely get propagated from the trunk to the release soon; until then, you're probably better off avoiding both issues as suggested above.

Note: See TracTickets for help on using tickets.