[squeak-dev] [VM] [ENTERTAINMENT] A one-step VM build for hobby
David T. Lewis
lewis at mail.msen.com
Sun Oct 7 16:00:33 UTC 2012
>From time to time, I try to update the instructions for building a unix
interpreter VM. These tend to get out of date, so I decided to try doing
it in the form of a script that can be run from a clean Squeak image to
load, generate, configure, and build a VM.
If you have a Unix/Linux system with development tools, you may want to
try this yourself. Start in a clean directory, then run the attached
VMUnixBuild.st script as follows:
$ squeak myImage VMUnixBuild.st
You can also evaluate the script piece-by-piece in a workspace to get
a better feel for the process. Note that the steps that are done with
OSProcess/CommandShell can be done in a normal unix terminal window,
but I did it here with OSProcess so that the entire process can be done
in a script.
I don't know if this works on Mac OS X. If someone can give it a try,
please let us know if it works.
-------------- next part --------------
" --- VMUnixBuild.st ---
7 October 2012 dtl
Generate and build a standard interpreter VM on Linux. Requires the
usual Linux development tools and libraries to be installed, as well
as the Subversion version control client.
This is a script file that may be supplied to Squeak at image startup.
It is intended to be run in a clean working directory. A large number
of packages will be installed, so start with a freshly downloaded
Run the script like this:
$ /usr/local/bin/squeak myImage.image VMUnixBuild.st
"Variables used in this script. You may skip this if you are evaluating
this script in a workspace, because a workspace declares its own variables
| exitWhenDone fullScreen exitWith log project shell shellWindow vmmTool cwd configCommand |
" --- configuration --- "
"If exitWhenDone is true, image will exit without saving when this
script is complete or if an error is encountered."
"EDIT BELOW. Set to true if the image should exit without saving when
this script is complete, or set false if script should be interactive."
exitWhenDone := false. "<== EDIT THIS"
"It is easier to watch the proceedings in full screen mode."
fullScreen := false. "If true, set to full screen mode"
"The configure command will specify various build time options. Define it
here so that it can be easily changed."
"With the following command, configure will build a VM using the
sources that VMMaker will generate in the src directory."
configCommand := '../platforms/unix/cmake/configure --src=../src'.
"Or you can tell configure to build a VM for 64-bit images as follows."
"configCommand := '../platforms/unix/cmake/configure --src=../src --image64'."
"If certain plugins are causing problems, they can be explicity removed
from the configuration. For example, if CameraPlugin and WeDoPlugin are
causing a problem, they can be excluded with the following configure command."
'../platforms/unix/cmake/configure --src=../src --without-CameraPlugin --without-WeDoPlugin'."
" --- subroutines --- "
"Log block. Write a message with time stamp to standard output."
log := [:msg | FileStream stdout
nextPutAll: DateAndTime now printString, ': ';
nextPut: Character lf;
"Exit block. When running as a script, exit the image. If interactive,
open a notifier and let the user decide what to do."
exitWith := [:reason | exitWhenDone
ifTrue: [log value: reason asString.
log value: 'exiting image'.
Smalltalk snapshot: false andQuit: true]
ifFalse: [self notify: reason asString]].
" --- start of script --- "
"If running with a display, show as much as possible so the command
shell window will be visible (see configuration variable above)."
fullScreen ifTrue: [Project current fullScreenOn].
log value: 'starting VM builder image'.
(Smalltalk hasClassNamed: #OSProcess) ifFalse: [
log value: 'begin install OSProcess'.
[MCMcmUpdater updateFromRepositories: #('http://www.squeaksource.com/OSProcess')]
do: [exitWith value: 'failed loading OSProcess'].
log value: 'install OSProcess complete'].
"AioEventHandler presents a warning dialog if the plugin is not
present, as may be the case if we are running a Cog VM. Initialize
it now so the dialog is not invoked if we are running headless."
Smalltalk at: #AioEventHandler ifPresent: [:aio | aio perform: #initializeAioPluginPresent].
(Smalltalk hasClassNamed: #CommandShell) ifFalse: [
log value: 'begin install CommandShell'.
[MCMcmUpdater updateFromRepositories: #('http://www.squeaksource.com/CommandShell')]
do: [exitWith value: 'failed loading CommandShell'].
log value: 'install CommandShell complete'].
"Open a shell. This will be used for later command invocation."
shell := Smalltalk at: #CommandShell ifPresent: [:cs | cs new].
shellWindow := shell open.
"Expand the shell window so we can see what is happening."
shellWindow dependents do: [:dep |
(dep isKindOf: SystemWindow)
ifTrue: [dep height: (dep height * 1.4) asInteger]].
"Perform the remainder of the script in a separate process. This permits
the shell window to be updated in the foreground UI process while shell
commands are being performed."
["Background block starts here"
"Make sure that Subversion is installed before proceeding"
shell if: 'svn --version'
then: [log value: 'Subversion is installed on this system']
else: [log value: 'Subversion is not installed on this system, ',
'required for obtaining platform sources'.
log value: 'exiting'.
exitWith value: 'Subversion client not installed'].
"Save previous ./src directory"
log value: 'save ./src directory if it exists'.
shell if: 'test -e src'
then: [shell script: 'rm -rf src-old
mv src src-old']
else: ["nothing to save"].
"Get the latest version of the platforms sources from the master repository."
shell if: 'test -e platforms'
then: [log value: 'update ./platforms from repository'.
shell if: 'svn update platforms'
then: [log value: 'platforms source update complete'.]
else: [log value: 'platforms source update failed, exiting'.
exitWith value: 'platforms source update failed']]
else: [log value: 'check out ./platforms from repository'.
shell if: 'svn co http://squeakvm.org/svn/squeak/trunk/platforms'
then: [log value: 'platforms source checkout complete'.]
else: [log value: 'platforms source checkout failed, exiting'.
exitWith value: 'platforms source checkout failed']].
"Install VMMaker trunk for interpreter VM building"
(Smalltalk hasClassNamed: #VMMaker)
ifTrue: [log value: 'begin VMMaker updateFromServer'.
[(Smalltalk at: #VMMaker) updateFromServer]
do: [exitWith value: 'failed VMMaker updateFromServer'].
log value: 'VMMaker updateFromServer complete']
ifFalse: [log value: 'begin install VMMaker (trunk)'.
[MCMcmUpdater updateFromRepositories: #('http://source.squeak.org/VMMaker')]
do: [exitWith value: 'failed loading VMMaker'].
(Smalltalk at: #VMMaker) initializeBrowserSupport. "activate Slang browsing"
log value: 'install VMMaker complete'].
"Open a VMMaker tool initialized with the default Unix plugins.
This should be done after loading the platforms sources, because the
VMMaker will initialize only those plugins for which platform support
vmmTool := Smalltalk at: #VMMakerTool ifPresent: [:vmm | vmm forUnix].
"Generate new sources"
log value: 'generate all sources'.
vmmTool vmMaker deleteEntireGeneratedTree. "make sure ./src is empty"
vmmTool vmMaker generateEntire.
log value: 'source generation complete'.
"Build a VM from sources"
cwd := FileDirectory default pathName.
log value: 'create build directory ./build'.
shell command: 'rm -rf build'. "delete previous build directory"
shell command: 'mkdir build'.
shell command: 'cd build'.
"The configure command is defined earlier in this script, see above."
log value: 'cd to build, then run ', configCommand.
shell if: configCommand
then: [log value: 'configure completed successfully'.
log value: 'begin make'.
shell if: 'make'
then: [log value: 'make completed with successful VM build'.
log value: 'to install, cd to ./build and do "make install"']
else: [log value: 'error in make']]
else: [log value: 'problem in configure, make will not be run'].
shell command: 'cd ', cwd. "back to home"
log value: 'platform sources are in ./platforms'.
log value: 'generated sources are in ./src'.
log value: 'build is in ./build'.
"See below for some of the documentation included in the platforms/unix source true.
Please also visit squeakvm.org for further information."
"The configure script is a shell script that invokes CMake to set up a build configuration.
The help output for the configure script explains how it is used, and what parameters
may be passed to it for various custom configurations, or to adapt to platform constraints.
Show the help for configure in an edit window."
shell command: 'platforms/unix/cmake/configure -help | edit'.
"More detailed information about the CMake build process is in README.CMake."
shell command: 'edit platforms/unix/README.CMake'.
"You will find lots of other documentation in platforms/unix/doc, and the other platforms
directories may have similar documentation (e.g. platforms/win32/docs). If you would
like to make contributions to the unix platforms code, it is a good idea to read the coding
guidelines from the doc directory here."
shell command: 'edit platforms/unix/doc/README.Contributing'.
exitWith value: 'source generation and VM build complete'.
More information about the Squeak-dev