Today's Smalltalk Daily covered the process (with some Mac specifics) - I thought a post on the topic, in addition to the video, might be useful. First, the important part of the build script (the part I'm omitting loads all the required parcels into a base image and sets some application level state. To get the startup class specified, simply create a subclass of UserApplication, and add a #main method that executes your startup code. I covered that here.
"go to deployment"
DeploymentOptionsSystem current startInRuntime: true.
Notifier current: RuntimePackager.BfRuntimeEmergencyNotifier.
Notifier uheFilename: 'error.log'.
Notifier logToFile: true.
UI.WindowManager noWindowBlock: [:windowManager | ].
stream := WriteStream on: String new.
stream nextPutAll: 'changeRequest'; cr; cr; tab.
stream nextPutAll: '^true'.
VisualLauncher compile: stream contents.
VisualLauncher allInstances do: [:each | each closeAndUnschedule. each release].
Workbook allInstances do: [:each | each closeRequest].
(Delay forSeconds: 10) wait.
promise := [ObjectMemory permSaveAs: 'bottomFeeder' thenQuit: false] promise.
RuntimeSystem isRuntime ifFalse: [ObjectMemory quit].
What does that do? Well, it sets up custom notifiers for the runtime (I don't want the default behavior that RTP specifies, which is "log and quit") when an unhandled exception happens. Then it turns off the "default window" block - that's the behavior whereby the launcher window pops up if all other windows are closed. Then it closes all Launchers and Workspaces, and saves the runtime image. Note that it does that in a separate process - that's so that the runtime doesn't start up and immediately quit :)
That gives me a runtime. I'd like to make it smaller though (not in memory consumption terms, just in disk space terms). So I use this script:
"load the compression code"
) do: [:each |
Parcel loadParcelFrom: each]]
do: [:ex | ex resume: true].
"now compress the image"
[:inFileSize :outFileSize :compTime :decompTime|
nextPutAll: 'Image compressed to ';
print: (outFileSize * 10000 / inFileSize) rounded / 100.0;
nextPutAll: '% of original (';
nextPutAll: 'Deompression + read time ';
print: decompTime // 10 / 100.0;
nextPutAll: ' seconds (compressed in ';
print: compTime // 10 / 100.0;
nextPutAll: ' seconds)';
(Delay forSeconds: 2) wait.
That fires up a new image, loads the compression parcel, and runs it on my image. Here's the shell script that guides the whole thing - and yes, sleeping to ensure that commands have finished is probably sloppy - if you're better at shell scripting, I'm sure you'll have a better answer there:
echo "Running basic image creation..."
./startvw visual.im -fileIn build-bf-non-windows.st
echo "Running image compression..."
./startvw visual.im -fileIn compress-bf-image.st
echo "Pushing new image into the .app..."
cp bfSmall.im macBuildDir/bottomFeeder.app/Contents/Resources/resource.im
That copy command drops the image into the Mac App bundle. As it happens, that bundle is just a directory structure, with the VM in one place, the image in another, and an XML file to explain it. That's documented - look in the "packaging" directory in the distro.
Finally, what about specifying your own app image for the dock? Well, in the app bundle is a file called "herald.tiff". Drop your image there in TIFF format, and you should be good to go.