The Artima Developer Community
Sponsored Link

Agile Buzz Forum
Scripting a Build

0 replies on 1 page.

Welcome Guest
  Sign In

Go back to the topic listing  Back to Topic List Click to reply to this topic  Reply to this Topic Click to search messages in this forum  Search Forum Click for a threaded view of the topic  Threaded View   
Previous Topic   Next Topic
Flat View: This topic has 0 replies on 1 page
James Robertson

Posts: 29924
Nickname: jarober61
Registered: Jun, 2003

David Buck, Smalltalker at large
Scripting a Build Posted: Feb 24, 2009 11:21 AM
Reply to this message Reply

This post originated from an RSS feed registered with Agile Buzz by James Robertson.
Original Post: Scripting a Build
Feed Title: Cincom Smalltalk Blog - Smalltalk with Rants
Feed URL: http://www.cincomsmalltalk.com/rssBlog/rssBlogView.xml
Feed Description: James Robertson comments on Cincom Smalltalk, the Smalltalk development community, and IT trends and issues in general.
Latest Agile Buzz Posts
Latest Agile Buzz Posts by James Robertson
Latest Posts From Cincom Smalltalk Blog - Smalltalk with Rants

Advertisement

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:




"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.

promise value.

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"

[#(

       '$(VISUALWORKS)/packaging/ImageCompression.pcl'

) do: [:each |

        Parcel loadParcelFrom: each]]

	on: MissingParcelSource

	do: [:ex | ex resume: true].



"now compress the image"

ObjectMemory

	compressImageFile: 'bottomFeeder.im'

	to: 'bfSmall.im'

	resultsTo: 

		[:inFileSize :outFileSize :compTime :decompTime|

			 Transcript

				cr;

				nextPutAll: 'Image compressed to ';

				print: (outFileSize * 10000 / inFileSize) rounded / 100.0;

				nextPutAll: '% of original (';

				print: inFileSize->outFileSize;

				nextPut: $);

				cr;

				nextPutAll: 'Deompression + read time ';

				print: decompTime // 10 / 100.0;

				nextPutAll: ' seconds (compressed in ';

				print: compTime // 10 / 100.0;

				nextPutAll: ' seconds)';

				flush].

(Delay forSeconds: 2) wait.

ObjectMemory quit.





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:




#!/bin/sh

echo "Running basic image creation..."

./startvw visual.im  -fileIn build-bf-non-windows.st

sleep 120

echo "Running image compression..."

./startvw visual.im -fileIn compress-bf-image.st

sleep 30

echo "Pushing new image into the .app..."

cp bfSmall.im macBuildDir/bottomFeeder.app/Contents/Resources/resource.im

echo "done"





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.

Technorati Tags:

Read: Scripting a Build

Topic: Coulton at the Ramshead in Annapolis Previous Topic   Next Topic Topic: Coulton in Annapolis

Sponsored Links



Google
  Web Artima.com   

Copyright © 1996-2019 Artima, Inc. All Rights Reserved. - Privacy Policy - Terms of Use