Skip to content

Commit

Permalink
Make it possible to build a Mac App Store version of CCL
Browse files Browse the repository at this point in the history
from the main development branch (rather than having to use
a separate store-only branch).

The way this works is that you start up ccl, push :mac-app-store
onto features, and then do (require 'cocoa-application) as
usual.

To package up the result for the Mac App Store, you first have to
get the appropriate certificates from Apple.  Xcode make this
easy enough.  With those in hand, scripts/make-store-app
will do the rest.
  • Loading branch information
xrme committed Oct 27, 2018
1 parent c915689 commit 7a42fe0
Show file tree
Hide file tree
Showing 10 changed files with 89 additions and 38 deletions.
12 changes: 6 additions & 6 deletions cocoa-ide/Info.plist-proto
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
<key>LSApplicationCategoryType</key>
<string>public.app-category.developer-tools</string>
<key>LSMinimumSystemVersion</key>
<string>10.6.6</string>
<string>10.9.0</string>
<key>CFBundleDevelopmentRegion</key>
<string>English</string>
<key>CFBundleDocumentTypes</key>
Expand All @@ -23,7 +23,7 @@
<string>asd</string>
</array>
<key>CFBundleTypeIconFile</key>
<string>openmcl-icon.icns</string>
<string>OPENMCL-ICONS</string>
<key>CFBundleTypeName</key>
<string>Lisp source code</string>
<key>CFBundleTypeRole</key>
Expand All @@ -35,7 +35,7 @@
</dict>
<dict>
<key>CFBundleTypeIconFile</key>
<string>openmcl-icon.icns</string>
<string>OPENMCL-ICONS</string>
<key>CFBundleTypeName</key>
<string>Listener</string>
<key>CFBundleTypeRole</key>
Expand Down Expand Up @@ -72,12 +72,12 @@
</array>
<key>CFBundleExecutable</key>
<string>OPENMCL-KERNEL</string>
<key>CFBundleHelpBookFolder</key>
<key>HELP-BOOK-FOLDER</key>
<string>Help</string>
<key>CFBundleHelpBookName</key>
<key>HELP-BOOK-NAME</key>
<string>OpenMCL Help</string>
<key>CFBundleIconFile</key>
<string>openmcl-icon.icns</string>
<string>OPENMCL-ICONS</string>
<key>CFBundleIdentifier</key>
<string>OPENMCL-IDENTIFIER</string>
<key>CFBundleInfoDictionaryVersion</key>
Expand Down
9 changes: 7 additions & 2 deletions cocoa-ide/altconsole/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -5,12 +5,17 @@
#
#

INFO_PLIST = AltConsole-Info.plist

ifdef MAC_APP_STORE
INFO_PLIST = AltConsole-mas-Info.plist
endif

APPBASE=.
OBJECTS=main.o AltConsoleDocument.o AltConsoleDocumentController.o
RESOURCES=resource/MainMenu.nib resource/AltConsole.nib resource/Credits.rtf resource/InfoPlist.strings resource/Clear.tiff

CFLAGS=-g -O -mmacosx-version-min=10.6
CFLAGS=-g -O -mmacosx-version-min=10.9

AltConsole: $(OBJECTS)
$(CC) $(CFLAGS) -o $@ $(OBJECTS) -framework Cocoa
Expand All @@ -22,7 +27,7 @@ $(APPBASE)/AltConsole.app: AltConsole $(RESOURCES) AltConsole-Info.plist
cp -r -p $(RESOURCES) $(APPBASE)/AltConsole.app/Contents/Resources/English.lproj
mkdir -p $(APPBASE)/AltConsole.app/Contents/MacOS
cp -p AltConsole $(APPBASE)/AltConsole.app/Contents/MacOS
cp -p AltConsole-Info.plist $(APPBASE)/AltConsole.app/Contents/Info.plist
cp -p $(INFO_PLIST) $(APPBASE)/AltConsole.app/Contents/Info.plist
touch $(APPBASE)/AltConsole.app

install: $(APPBASE)/AltConsole.app
Expand Down
6 changes: 2 additions & 4 deletions cocoa-ide/app-delegate.lisp
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,7 @@
(#/registerDefaults: domain dict)
(#/release dict)
(update-cocoa-defaults)
#-mac-app-store
(when *standalone-cocoa-ide*
(init-ccl-directory-for-ide))))

Expand Down Expand Up @@ -283,10 +284,7 @@

(objc:defmethod (#/showManual: :void) ((self ide-application-delegate) sender)
(declare (ignore sender))
(let* ((p (merge-pathnames "doc/ccl-documentation.html" #p"ccl:"))
(workspace (#/sharedWorkspace ns:ns-workspace)))
(with-cfstring (s (native-translated-namestring p))
(#/openFile: workspace s))))
(ccl::open-url-in-browser "http://ccl.clozure.com/docs/ccl.html"))

(defloadvar *hemlock-commands-window-controller* nil)

Expand Down
15 changes: 12 additions & 3 deletions cocoa-ide/cocoa-application.lisp
Original file line number Diff line number Diff line change
Expand Up @@ -21,20 +21,29 @@
(eval-when (:compile-toplevel :load-toplevel :execute)
(pushnew :cocotron *features*))


#+mac-app-store
(defvar *cocoa-ide-path* "ccl:Clozure CL.app;")
#-mac-app-store
(defvar *cocoa-ide-path*
(let* ((bits (nth-value 1 (host-platform))))
(format nil "ccl:Clozure CL~a.app;" bits)))

(defvar *cocoa-ide-copy-headers-p* t)
(defvar *cocoa-ide-install-altconsole* t)

(defvar *cocoa-ide-bundle-suffix*
(multiple-value-bind (os bits cpu) (host-platform)
(declare (ignore os))
#+mac-app-store
(format nil "store.ccl-~a~a" (string-downcase cpu) bits)
#-mac-app-store
(format nil "Clozure CL-~a~a" (string-downcase cpu) bits)))

(defvar *cocoa-ide-frameworks* #+cocotron '("ccl:cocotron;Foundation.framework;" "ccl:cocotron;AppKit.framework;" "ccl:cocotron;CoreData.framework;") #-cocotron nil)
(defvar *cocoa-ide-libraries* #+cocotron '("ccl:cocotron;Foundation>.1>.0.dll" "ccl:cocotron;AppKit>.1>.0.dll" "ccl:cocotron;CoreData>.1>.0.dll") #-cocotron nil)

(defvar *cocoa-ide-force-compile* nil)

(defvar *cocoa-ide-force-compile* #+mac-app-store t
#-mac-app-store nil)
(load "ccl:cocoa-ide;defsystem.lisp")
(load-ide *cocoa-ide-force-compile*)

Expand Down
14 changes: 4 additions & 10 deletions cocoa-ide/defsystem.lisp
Original file line number Diff line number Diff line change
Expand Up @@ -115,20 +115,20 @@
"preferences"
"processes-window"
"apropos-window"
#-mac-app-store
"xapropos"
"hemlock-commands"
"file-dialogs"
"menus"
"app-delegate"
#-mac-app-store
"ide-self-update"
,(if (use-pre-lion-search-files)
"search-files-pre-lion"
"search-files")
"start"
))

(defparameter *leopard-only-ide-files*
'("xinspector"
#-mac-app-store
"xinspector"
))

(defun load-mac-ui-files (names mac-ui-dir force-compile)
Expand Down Expand Up @@ -172,12 +172,6 @@
force-compile)

(defun load-ide (&optional force-compile)
;; kludge to limit experimental files to Leopard
#+darwin-target
(rlet ((p :int))
(#_Gestalt #$gestaltSystemVersion p)
(when (>= (%get-long p) #x1050)
(setq *ide-files* (append *ide-files* *leopard-only-ide-files*))))
(load-mac-ui-files *mac-ui-files* "ccl:mac-ui;" force-compile)
(load-ide-files *ide-files* "ccl:cocoa-ide;" force-compile)
(require 'build-application)
Expand Down
29 changes: 23 additions & 6 deletions cocoa-ide/ide-bundle.lisp
Original file line number Diff line number Diff line change
Expand Up @@ -46,10 +46,13 @@
(recursive-copy-directory source-dir contents-dir :if-exists if-exists :test #'ignore-test)
(when copy-headers
(let* ((subdirs (ccl::cdb-subdirectory-path))
(ccl-headers (make-pathname :host "ccl" :directory `(:absolute ,@subdirs)))
(dest-headers (make-pathname :host (pathname-host contents-dir)
:directory (append (pathname-directory contents-dir)
(cons "Resources" subdirs)))))
(ccl-headers (make-pathname :host "ccl"
:directory `(:absolute ,@subdirs)))
(dest-headers (make-pathname
:host (pathname-host contents-dir)
:directory
(append (pathname-directory contents-dir)
(list* "Resources" "ccl" subdirs)))))
(recursive-copy-directory ccl-headers dest-headers :if-exists if-exists :test #'ignore-test)))
(when install-altconsole
(install-altconsole bundle-path))
Expand Down Expand Up @@ -84,7 +87,12 @@
(build-directory "ccl:cocoa-ide;altconsole;")
(build-bundle-path "ccl:cocoa-ide;altconsole;AltConsole.app")
(make-output (make-string-output-stream))
(args `("-C" ,(native-translated-namestring build-directory) "install")))
#+mac-app-store
(args `("-C" ,(native-translated-namestring build-directory)
"clean" "install" "MAC_APP_STORE=yes"))
#-mac-app-store
(args `("-C" ,(native-translated-namestring build-directory)
"install")))
(recursive-delete-directory altconsole-path :if-does-not-exist nil)
(unwind-protect
(multiple-value-bind (exit-status code)
Expand Down Expand Up @@ -132,6 +140,12 @@
(declare (ignore os))
(format nil "~d (~a~d)" *openmcl-svn-revision* cpu bits)))
(needles `(("OPENMCL-KERNEL" . ,kernel-name)
("OPENMCL-ICONS" . #+mac-app-store "store.icns"
#-mac-app-store "openmcl-icon.icns")
("HELP-BOOK-FOLDER" . #+mac-app-store "nohelpbookfolder"
#-mac-app-store "CFBundleHelpBookFolder")
("HELP-BOOK-NAME" . #+mac-app-store "nohelpbookname"
#-mac-app-store "CFBundleHelpBookName")
("OPENMCL-NAME" . ,bundle-name)
("OPENMCL-IDENTIFIER" . ,bundle-id)
("OPENMCL-VERSION" . ,bundle-version)
Expand Down Expand Up @@ -209,4 +223,7 @@

(progn
(create-ide-bundle *cocoa-ide-path*)
(fake-cfbundle-path *cocoa-ide-path* "ccl:cocoa-ide;Info.plist-proto" "com.clozure" *cocoa-ide-bundle-suffix* *cocoa-ide-frameworks* *cocoa-ide-libraries* #+windows-target "ccl:cocoa-ide;ide-contents;resources;openmcl-icon.ico"))
(fake-cfbundle-path *cocoa-ide-path* "ccl:cocoa-ide;Info.plist-proto"
"com.clozure" *cocoa-ide-bundle-suffix*
*cocoa-ide-frameworks* *cocoa-ide-libraries*
#+windows-target "ccl:cocoa-ide;ide-contents;resources;openmcl-icon.ico"))
8 changes: 4 additions & 4 deletions cocoa-ide/ide-contents/Resources/English.lproj/Credits.html
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
<html>
<head>
<style type="text/css">
html {
font-family: "Lucida Grande";
body {
font-family: -apple-system, "Helvetica Neue", "Lucida Grande";
font-size: small;
}

Expand All @@ -15,8 +15,8 @@
<body>
<p>
To report bugs or request enhancements, please go to the
<a href="http://trac.clozure.com/ccl">Clozure CL Trac</a>
and create a ticket.
<a href="https://github.com/Clozure/ccl">GitHub page for CCL</a>
and create an issue.
</p>
</body>
</html>
2 changes: 2 additions & 0 deletions cocoa-ide/menus.lisp
Original file line number Diff line number Diff line change
Expand Up @@ -116,6 +116,7 @@
(#/addItemWithTitle:action:keyEquivalent: menu #@"Definitions..." (objc:@selector #/showListDefinitions:) #@"")
menu))

#-mac-app-store
(defun @experiments-menu ()
(let ((menu (#/initWithTitle: (#/alloc ns:ns-menu) #@"Experiments")))
(#/addItemWithTitle:action:keyEquivalent: menu #@"xapropos" (objc:@selector #/showXaproposWindow:) #@"")
Expand Down Expand Up @@ -158,6 +159,7 @@
(add-menu #@"Edit" (#/autorelease (@edit-menu)))
(add-menu #@"Lisp" (#/autorelease (@lisp-menu)))
(add-menu #@"Tools" (#/autorelease (@tools-menu)))
#-mac-app-store
(add-menu #@"Experiments" (#/autorelease (@experiments-menu)))
(let ((window-menu (@window-menu)))
(add-menu #@"Window" window-menu)
Expand Down
6 changes: 3 additions & 3 deletions cocoa-ide/search-files.lisp
Original file line number Diff line number Diff line change
Expand Up @@ -257,7 +257,7 @@
(%null-ptr-p (slot-value self 'text)))

(defun %tree-node-for-grep-result (grep-result)
(let* ((node-data (#/new navigator-search-node-data))
(let* ((node-data (#/new (@class "NavigatorSearchNodeData")))
(node (#/initWithRepresentedObject: (#/alloc ns:ns-tree-node) node-data))
(file (grep-result-file grep-result)))
(#/release node-data)
Expand All @@ -267,7 +267,7 @@
(#/setURL: node-data u))
(let ((matches (grep-result-matches grep-result)))
(dolist (match matches)
(let* ((child-node-data (#/new navigator-search-node-data))
(let* ((child-node-data (#/new (@class "NavigatorSearchNodeData")))
(child-node (#/initWithRepresentedObject: (#/alloc ns:ns-tree-node)
child-node-data))
(line-number (first match))
Expand Down Expand Up @@ -548,7 +548,7 @@
(with-slots (outline-view search-data-source) wc
(#/setTarget: outline-view search-data-source)
(#/setDoubleAction: outline-view (@selector #/editLine:))
(setf search-data-source (#/new grep-results-data-source))
(setf search-data-source (#/new (@class "GrepResultsDataSource")))
(#/setDelegate: outline-view search-data-source)
(#/setDataSource: outline-view search-data-source))
(setf (find-string-value wc) #@"")
Expand Down
26 changes: 26 additions & 0 deletions scripts/make-store-app
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
#!/bin/sh

ccl=/usr/local/src/ccl
app="$ccl/Clozure CL.app"
target="$app/Contents/Resources/ccl"

mkdir "$target"
( cd "$ccl/lisp-kernel/darwinx8664" && make clean )
( cd "$ccl/lisp-kernel/darwinx8632" && make clean )
( cd "$ccl/cocoa-ide/altconsole" && make clean && rm -rf AltConsole.app )

for i in cocoa-ide compiler darwin-x86-headers64 doc examples level-0 level-1 lib library lisp-kernel objc-bridge scripts tools xdump; do
cp -Rp "$ccl/$i" "$target"
# we want the fasls for tools/, mainly because asdf.lisp is slow
# to load from source
if test "$i" != tools; then
find "$target/$i" -type f -name "*.*fsl" -exec rm -rf {} \;
fi
done

find "$app" -type d -name .svn -exec rm -rf {} \;

codesign -s "3rd Party Mac Developer Application: Clozure Associates, LLC" "$app/Contents/Resources/AltConsole.app"
codesign -s "3rd Party Mac Developer Application: Clozure Associates, LLC" "$app"
productbuild --component "$app" /Applications --sign "3rd Party Mac Developer Installer: Clozure Associates, LLC" "$ccl/ccl.pkg"

0 comments on commit 7a42fe0

Please sign in to comment.