[Openmcl-devel] Building Cocoa apps from command line

mikel evins mevins at mac.com
Wed May 7 13:41:43 PDT 2008

On Apr 14, 2008, at 3:29 PM, Joe Jones wrote:
> Why is it necessary to build from the IDE and not from the command  
> line? Is there a way to build a cocoa app from the command line?

It turns out that you can pretty easily build a Cocoa application from  
the command line with the existing version of BUILD-APPLICATION. I  
didn't want to say that until I'd had a chance to test it for myself.  
I've had that chance and it does indeed work.

After testing the code I added a section to the docs describing how it  
works. Here's that section:

5.6.1. Running the Application Builder From the Command Line
It's possible to automate use of the application builder by running a  
call to CCL:BUILD-APPLICATION from the terminal command line. For  
example, the following command, entered at a shell prompt in Mac OS  
X's Terminal window, builds a working copy of the Clozure CL  
environment called "Foo.app":

ccl -b -e "(require :cocoa)" -e "(require :build-application)" -e  
"(ccl::build-application :name \"Foo\")"
You can use the same method to automate building your Lisp/Cocoa  
applications. Clozure CL handles each Lisp expressions passed with a - 
e argument in order, so you can simply evaluate a sequence of Lisp  
expressions as in the above example to build your application, ending  
can process all the same arguments as if you evaluated it in a  
Listener window in the Clozure CL IDE.

Building a substantial Cocoa application (rather than just reproducing  
the Lisp environment using defaults, as is done in the above example)  
is likely to involve a relatively complicated sequence of loading  
source files and perhaps evaluating Lisp forms. You might be best  
served to place your command line in a shell script that you can more  
easily edit and test.

One potentially complicated issue concerns loading all your Lisp  
source files in the right order. You might consider using ASDF to  
define and load a system that includes all the parts of your  
application before calling CCL:BUILD-APPLICATION. ASDF is a "another  
system-definition facility", a sort of make for Lisp, and is included  
in the Clozure CL distribution. You can read more about ASDF at the  
ASDF home page.

Alternatively, you could use the standard features of Common Lisp to  
load your application's files in the proper order.


More information about the Openmcl-devel mailing list