Changeset 9348


Ignore:
Timestamp:
May 2, 2008, 6:07:40 PM (11 years ago)
Author:
mikel
Message:

added support and documentation for user-defined Info.plist objects

Location:
trunk/source
Files:
3 edited

Legend:

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

    r9333 r9348  
    1818;;;  1. make a way to specify a user-defined Info.plist in build-application
    1919;;;  2. make a way to specify a user-defined app delegate in build-application
     20
     21;;; BUILD-APPLICATION
     22;;; ------------------------------------------------------------------------
     23;;; Builds an application bundle and saves an executable lisp image
     24;;; into it. Populates the bundle directory with the files needed to
     25;;; run the lisp image when the bundle is double-clicked.
     26
    2027(defun build-application (&key
    2128                          (name $default-application-bundle-name)
     
    2431                          (directory (current-directory))
    2532                          (copy-ide-resources t) ; whether to copy the IDE's resources
     33                          (info-plist nil) ; optional user-defined info-plist
    2634                          (nibfiles nil) ; a list of user-specified nibfiles
    2735                                        ; to be copied into the app bundle
     
    3240                          (toplevel-function nil))
    3341
    34   (let* ((info-plist (if copy-ide-resources
    35                          (get-ide-bundle-info-plist)
    36                          (make-info-dict)))
    37          (ide-bundle (#/mainBundle ns:ns-bundle))
    38          (ide-bundle-path-nsstring (#/bundlePath ide-bundle))
    39          (ide-bundle-path (pathname
    40                            (ensure-directory-pathname
    41                             (lisp-string-from-nsstring ide-bundle-path-nsstring))))
     42  (let* ((info-plist (or info-plist ; if the user supplied one then we use it
     43                         (if copy-ide-resources
     44                             ;; otherwise: if copying resources use ide's
     45                             (get-ide-bundle-info-plist)
     46                             ;; else, create a new one
     47                             (make-info-dict))))
     48         (ide-bundle-path (get-ide-bundle-path))
    4249         ;; create the bundle directory
    43          (app-bundle (make-application-bundle :name name
    44                                               :project-path directory))
     50         (app-bundle (make-application-bundle :name name :project-path directory))
    4551         (image-path (namestring (path app-bundle "Contents" "MacOS" name))))
    46     ;; copy IDE resources to the bundle
     52    ;; maybe copy IDE resources to the bundle
    4753    (when copy-ide-resources
    4854      (recursive-copy-directory (path ide-bundle-path "Contents" "Resources/")
     
    5359                      name type-string creator-string :main-nib-name main-nib-name)
    5460    ;; write Pkginfo
    55     (write-pkginfo (path app-bundle "Contents" "PkgInfo")
    56                    type-string creator-string)
    57     ;; copy user nibfiles into the bundle
     61    (write-pkginfo (path app-bundle "Contents" "PkgInfo") type-string creator-string)
     62    ;; copy any user nibfiles into the bundle
    5863    (when nibfiles
    5964      (let ((nib-paths (mapcar #'pathname nibfiles)))
     
    7378(require :build-application)
    7479(load "/usr/local/ccl/trunk/source/cocoa-ide/builder-utilities.lisp")
     80(load "/usr/local/ccl/trunk/source/cocoa-ide/build-application.lisp")
    7581(ccl::build-application :name "Foo"
    7682                        :directory "/Users/mikel/Desktop"
  • trunk/source/cocoa-ide/builder-utilities.lisp

    r9333 r9348  
    8181
    8282;;; COPY-NIBFILE (srcnib dest-directory &key (if-exists :overwrite))
     83;;; ------------------------------------------------------------------------
    8384;;; Copies a nibfile (which may in fact be a directory) to the
    8485;;; destination path (which may already exist, and may need to
     
    101102
    102103;;; BASENAME path
     104;;; ------------------------------------------------------------------------
    103105;;; returns the final component of a pathname--that is, the
    104106;;; filename (with type extension) if it names a file, or the
     
    126128
    127129;;; PATH (&rest components)
     130;;; ------------------------------------------------------------------------
    128131;;; returns a pathname. The input COMPONENTS are treated as
    129132;;; directory names, each contained in the one to the left, except
     
    140143
    141144;;; WRITE-PKGINFO path package-type bundle-signature
     145;;; ------------------------------------------------------------------------
    142146;;; Writes a PkgInfo file of the sort used by Cocoa applications
    143147;;; to identify their package types and signatures. Writes
     
    152156
    153157;;; MAKE-INFO-DICT
     158;;; ------------------------------------------------------------------------
    154159;;; returns a newly-created NSDictionary with contents
    155160;;; specified by the input parameters
     
    193198
    194199;;; READ-INFO-PLIST info-path
     200;;; ------------------------------------------------------------------------
    195201;;; returns a newly-created NSDictionary with the contents
    196202;;; of the plist file at INFO-PATH
     
    206212                                       info-path-str))))
    207213
    208 (defun info-dict-from-specification (spec)
    209   (cond
    210     ((typep spec 'ns:ns-dictionary) spec)
    211     ((and (typep spec 'pathname)
    212           (string-equal (pathname-type spec) "plist")
    213           (probe-file spec)) (read-info-plist spec))
    214     (t (error "Argument to INFO-DICT-FROM-SPECIFICATION must be the pathname of a valid plist file or an instance of NSDictionary"))))
    215 
    216214;;; WRITE-INFO-PLIST info-plist path name package-type bundle-signature
     215;;; ------------------------------------------------------------------------
    217216;;; sets the name, package-type, and bundle-signature of the
    218217;;; info-plist from the inputs; writes the changed dictionary to a new
     
    242241      (#/writeToFile:atomically: info-dict app-plist-path-str #$YES))))
    243242
     243;;; GET-IDE-BUNDLE-PATH
     244;;; ------------------------------------------------------------------------
     245;;; Returns the llisp pathname of the running IDE bundle
     246
     247(defun get-ide-bundle-path ()
     248  (let* ((ide-bundle (#/mainBundle ns:ns-bundle))
     249         (ide-bundle-path-nsstring (#/bundlePath ide-bundle)))
     250    (pathname
     251     (ensure-directory-pathname
     252      (lisp-string-from-nsstring ide-bundle-path-nsstring)))))
     253
     254;;; GET-IDE-BUNDLE-INFO-PLIST
     255;;; ------------------------------------------------------------------------
     256;;; Returns an NSDictionary instance created by reading the Info.plist
     257;;; file from the running IDE's application bundle
     258
    244259(defun get-ide-bundle-info-plist ()
    245260  (let* ((ide-bundle (#/mainBundle ns:ns-bundle))
     
    252267
    253268;;; MAKE-APPLICATION-BUNDLE name package-type bundle-signature project-path
     269;;; ------------------------------------------------------------------------
    254270;;; Build the directory structure of a Cocoa application bundle and
    255271;;; populate it with the required PkgInfo and Info.plist files.
  • trunk/source/doc/src/ide.xml

    r9347 r9348  
    217217        (<parameter>directory</parameter> <replaceable>(current-directory)</replaceable>)
    218218        (<parameter>copy-ide-resources</parameter> <replaceable>t</replaceable>)
     219        (<parameter>info-plist</parameter> <replaceable>NIL</replaceable>)
    219220        (<parameter>nibfiles</parameter> <replaceable>NIL</replaceable>)
    220221        (<parameter>main-nib-name</parameter> <replaceable>NIL</replaceable>)
     
    309310
    310311      <varlistentry>
     312        <term><varname>info-plist</varname></term>
     313        <listitem>
     314          <para>A user-supplied NSDictionary object that defines the
     315          contents of the Info.plist file to be written to the
     316          application bundle. The default value
     317          is <literal>NIL</literal>, which specifies that the
     318          Info.plist from the IDE is to be used
     319          if <replaceable>copy-ide-resources</replaceable> is true,
     320          and a new dictionary created with default values is to be
     321          used otherwise. You can create a suitable NSDictionary
     322          object using the
     323          function <literal>make-info-dict</literal>. For details on
     324          the parameters to this function, see its definition in
     325          "ccl/cocoa-ide/builder-utilities.lisp".</para>
     326        </listitem>
     327      </varlistentry>
     328
     329      <varlistentry>
    311330        <term><varname>nibfiles</varname></term>
    312331        <listitem>
Note: See TracChangeset for help on using the changeset viewer.