# HG changeset patch # User tz # Date 891543722 -7200 # Node ID ba7044e40ba00b28ba9f93ab4209b135ada81def # Parent ed8ff581872b507e1c06b560d302e89703428ecd revised diff -r ed8ff581872b -r ba7044e40ba0 ApplicationBuilder.st --- a/ApplicationBuilder.st Thu Apr 02 20:59:17 1998 +0200 +++ b/ApplicationBuilder.st Thu Apr 02 21:02:02 1998 +0200 @@ -1,10 +1,22 @@ ToolApplicationModel subclass:#ApplicationBuilder - instanceVariableNames:'task shellView' - classVariableNames:'Aspects' + instanceVariableNames:'task shellView aspects' + classVariableNames:'' poolDictionaries:'' category:'Interface-Smalltalk' ! +ApplicationBuilder class instanceVariableNames:'aspects' + +" + The following class instance variables are inherited by this class: + + ToolApplicationModel - history clipboard settings showHelp + ApplicationModel - ClassResources + Model - + Object - +" +! + !ApplicationBuilder class methodsFor:'documentation'! documentation @@ -12,20 +24,21 @@ The Application Builder of ST/X allows you to build ST/X-applications by following steps: 0. Clobber the target directory of the application - 1. Generation of the h-file with symbols - 2. Generation of the c-file with modules - 3. Compilation of the modules init file - 4. Compilation of the startup C-file - 5. Defining of the symbolic links to the libraries - 6. Linking of the libraries to the application - 7. Defining of the symbolic links to the resources + 1. Generate the h-file with symbols + 2. Generate the c-file with modules + 3. Compile the modules init file + 4. Compile the startup C-file + 5. Define the symbolic links to the libraries + 6. Link the libraries to the application + 7. Define the symbolic links to the resources + [instance variables:] task task of the running build shellView shell view for outputing the build results - [class variables:] - Aspects aspects of the settings + [instance class variables:] + aspects aspects of the settings [start with:] ApplicationBuilder open @@ -38,6 +51,21 @@ " ! ! +!ApplicationBuilder class methodsFor:'accessing'! + +aspects + + aspects isNil ifTrue: [aspects := IdentityDictionary new]. + ^aspects + + +! + +aspects: anIdentityDictionary + + aspects := anIdentityDictionary +! ! + !ApplicationBuilder class methodsFor:'help specs'! helpSpec @@ -62,7 +90,7 @@ 'Name of the application.' #build -'Starts the process of building the application.' +'Starts the process of building the target.' #buildDate 'Build date of the application.' @@ -73,6 +101,9 @@ #libraryDirectory 'Directory of the ST/X libraries.' +#link +'Starts the process of linking the application.' + #start 'Start the build application.' @@ -89,7 +120,7 @@ 'Startup module of ST/X for the application.' #stop -'Stops the process of application building.' +'Stops the process of the building.' #stxLibraries 'List of the ST/X library names.' @@ -107,10 +138,10 @@ 'Create symbolic links to the sources of ST/X.' #systemLibaries -'Libraries of the operating system needed by the application.' +'Libraries of the operating system needed by the target.' #targetDirectory -'Target directory of the application.' +'Directory where the target will build.' #topDirectory 'Top directory of ST/X.' @@ -144,11 +175,11 @@ #window: #(#WindowSpec #name: 'Application Builder' - #layout: #(#LayoutFrame 37 0 199 0 536 0 658 0) + #layout: #(#LayoutFrame 428 0 301 0 927 0 760 0) #label: 'Application Builder' #min: #(#Point 420 220) #max: #(#Point 1152 900) - #bounds: #(#Rectangle 37 199 537 659) + #bounds: #(#Rectangle 428 301 928 761) #menu: #menu #usePreferredExtent: false ) @@ -158,7 +189,7 @@ #( #(#ViewSpec #name: 'Box1' - #layout: #(#LayoutFrame 0 0.0 0 0 0 1.0 288 0) + #layout: #(#LayoutFrame 0 0.0 3 0 0 1.0 292 0) #component: #(#SpecCollection #collection: @@ -219,7 +250,7 @@ #model: #configuration ) #(#DividerSpec - #name: 'divider1' + #name: 'Separator2' #layout: #(#LayoutFrame 0 0 102 0 0 1 105 0) ) #(#ActionButtonSpec @@ -275,12 +306,12 @@ #model: #startupCFile ) #(#DividerSpec - #name: 'divider2' + #name: 'Separator3' #layout: #(#LayoutFrame 0 0.0 208 0 0 1.0 211 0) ) #(#LabelSpec #name: 'stxLibraryButton' - #layout: #(#LayoutFrame 4 0 215 0 147 0 239 0) + #layout: #(#AlignmentOrigin 147 0 227 0 1 0.5) #label: 'ST/X Libraries:' ) #(#ComboBoxSpec @@ -327,6 +358,11 @@ ) ) ) + #(#DividerSpec + #name: 'Separator4' + #layout: #(#LayoutFrame -144 1 0 0.0 -138 1 0 1.0) + #orientation: #vertical + ) #(#ViewSpec #name: 'Box3' #layout: #(#LayoutFrame -134 1 0 0.0 0 1.0 0 1.0) @@ -336,7 +372,7 @@ #( #(#FramedBoxSpec #name: 'FramedBox' - #layout: #(#LayoutFrame -4 0.0 0 0.0 0 1.0 -98 1.0) + #layout: #(#LayoutFrame -4 0.0 4 0.0 0 1.0 -150 1.0) #component: #(#SpecCollection #collection: @@ -376,7 +412,7 @@ ) #(#VerticalPanelViewSpec #name: 'VerticalPanel' - #layout: #(#LayoutFrame 0 0.0 -90 1 -6 1.0 0 1.0) + #layout: #(#LayoutFrame 0 0.0 -144 1 -6 1.0 -2 1.0) #component: #(#SpecCollection #collection: @@ -386,21 +422,28 @@ #activeHelpKey: #build #label: 'Build' #model: #doBuild - #extent: #(#Point 128 28) + #extent: #(#Point 128 33) + ) + #(#ActionButtonSpec + #name: 'linkButton' + #activeHelpKey: #link + #label: 'Link' + #model: #doLink + #extent: #(#Point 128 34) ) #(#ActionButtonSpec #name: 'stopButton' #activeHelpKey: #stop #label: 'Stop' #model: #doStop - #extent: #(#Point 128 28) + #extent: #(#Point 128 33) ) #(#ActionButtonSpec #name: 'Button1' #activeHelpKey: #start #label: 'Start' #model: #doStart - #extent: #(#Point 128 28) + #extent: #(#Point 128 33) ) ) ) @@ -412,21 +455,13 @@ ) ) ) - #(#DividerSpec - #name: 'Separator1' - #layout: #(#LayoutFrame -144 1 0 0.0 -138 1 0 1.0) - #orientation: #vertical - ) ) ) - ) - #(#DividerSpec - #name: 'Separator2' - #layout: #(#LayoutFrame 0 0.0 290 0 0 1.0 293 0) + #borderWidth: 1 ) #(#SubCanvasSpec - #name: 'SubCanvas' - #layout: #(#LayoutFrame 0 0.0 296 0 0 1.0 -26 1) + #name: 'shellViewSubCanvas' + #layout: #(#LayoutFrame 0 0.0 294 0 0 1.0 -26 1) #hasHorizontalScrollBar: false #hasVerticalScrollBar: false #clientHolder: #shellView @@ -475,6 +510,11 @@ #activeHelpKey: #build ) #(#MenuItem + #label: 'Link' + #value: #doLink + #activeHelpKey: #link + ) + #(#MenuItem #label: 'Stop' #value: #doStop #activeHelpKey: #stop @@ -575,13 +615,13 @@ doBuild "builds the application by doing following tasks: 0. Clobber the target directory of the application - 1. Generation of the h-file with symbols - 2. Generation of the c-file with modules - 3. Compilation of the modules init file - 4. Compilation of the startup C-file - 5. Creating of the symbolic links to the libraries - 6. Linking of the libraries to the application - 7. Creating of the symbolic links to the resources + 1. Generate the h-file with symbols + 2. Generate the c-file with modules + 3. Compile the modules init file + 4. Compile the startup C-file + 5. Define the symbolic links to the libraries + 6. Link the libraries to the application + 7. Define the symbolic links to the resources " |dir compilerPath compilerFlags block0 block1 block2 block3 block4 block5 block6 block7 priority| @@ -589,7 +629,7 @@ self inform: 'Starting building of application...' asBoldText. - (dir := self getApplicationDirectory) isNil + (dir := self getTargetDirectory) isNil ifTrue: [^self warn: 'Could not create application directory!!']. shellView directory: dir. @@ -598,66 +638,14 @@ ifTrue: [^self warn:'Define first a system compiler!!']. compilerFlags := self getCompilerFlags. - block0 := - [ - self inform: 'Clobbering the target directory...'. - self clobberTargetDirectory: dir. - task := nil - ]. - block1 := - [ - self inform: 'Starting generation of the h-file with symbols...'. - self generateHFileWithSymbolsIn: dir. - (dir asFilename construct: 'symbols.h') exists - ifTrue: [task := nil] - ifFalse: [self warn:'Could not generate the h-file with symbols!!'] - ]. - block2 := - [ - self inform: 'Starting generation of the C-file with modules...'. - self generateCFileWithModulesIn: dir. - (dir asFilename construct: 'modulList.c') exists - ifTrue: [task := nil] - ifFalse: [self warn:'Could not generate the C-file with libraries!!'] - ]. - block3 := - [ - self inform: 'Starting compilation of the modules init file...'. - self compileModulListFileWith: compilerPath, compilerFlags inDirectory: dir. - (dir asFilename construct: 'modulList.o') exists - ifTrue: [task := nil] - ifFalse: [self warn:'Could not compile the modules file!!'] - ]. - block4 := - [ - ((Aspects at: #startupCFile) value asFilename) exists - ifFalse: [task := nil. self warn: 'Defined startup C-file not found!!']. - self inform: 'Starting compilation of the startup C-file...'. - self compileStartupCFileWith: compilerPath, compilerFlags inDirectory: dir. - (dir asFilename construct: 'main.o') exists - ifTrue: [task := nil] - ifFalse: [self warn:'Could not compile the startup C-file!!'] - ]. - block5 := - [ - self inform: 'Starting defining of the symbolic links to the libraries...'. - self createSymbolicLinksToTheLibrariesIn: dir. - task := nil. - ]. - block6 := - [ - self inform: 'Starting linking of the libraries to the application...'. - self linkLibrariesToTheApplicationIn: dir. - (dir asFilename construct: (Aspects at: #applicationName) value) exists - ifTrue: [task := nil] - ifFalse: [self warn:'Could not build the application!!'] - ]. - block7 := - [ - self inform: 'Starting linking of the resources...'. - self createSymbolicLinksToTheResourcesIn: dir. - task := nil. - ]. + block0 := self getBlockForClobberingTargetDirectory: dir. + block1 := self getBlockForGeneratingHFileWithSymbolsIn: dir. + block2 := self getBlockForGeneratingCFileWithModulesIn: dir. + block3 := self getBlockForCompilingModulListFileWith: compilerPath, compilerFlags inDirectory: dir. + block4 := self getBlockForCompilingStartupCFileWith: compilerPath, compilerFlags inDirectory: dir. + block5 := self getBlockForCreatingSymbolicLinksToTheLibrariesIn: dir. + block6 := self getBlockForLinkingLibrariesToTheApplicationIn: dir. + block7 := self getBlockForCreatingSymbolicLinksToTheResourcesIn: dir. priority := Processor userBackgroundPriority. task := block0 forkAt: priority. @@ -698,30 +686,25 @@ task := block7 forkAt: priority. task addExitAction: [ - task := nil. - self inform: 'Application build.' asBoldText. + task isNil + ifTrue: [self inform: 'Application build.' asBoldText] + ifFalse: [self informTargetBuildingFailured]. Display beep. ] - ] + ] ifFalse: [self informTargetBuildingFailured] ] - ] + ] ifFalse: [self informTargetBuildingFailured] ] - ] + ] ifFalse: [self informTargetBuildingFailured] ] - ] + ] ifFalse: [self informTargetBuildingFailured] ] - ] + ] ifFalse: [self informTargetBuildingFailured] ] - ] + ] ifFalse: [self informTargetBuildingFailured] ] - ] + ] ifFalse: [self informTargetBuildingFailured] ] - - - - - - ! doDefineApplicationLinkDefines @@ -730,22 +713,49 @@ |box| box := EnterBox new. box label: 'Application Link Defines'. - box initialText: (Aspects at: #applicationLinkDefines) value. + box initialText: (aspects at: #applicationLinkDefines) value. box showAtPointer. box accepted ifTrue: [ - (Aspects at: #applicationLinkDefines) value: box contents + (aspects at: #applicationLinkDefines) value: box contents ]. box destroy ! +doLink + "links the application" + + |dir block priority| + + task notNil ifTrue: [self warn: 'There is already a build running!!']. + + self inform: 'Starting building of application...' asBoldText. + + (dir := self getTargetDirectory) isNil + ifTrue: [^self warn: 'Could not create application directory!!']. + + shellView directory: dir. + + block := self getBlockForLinkingLibrariesToTheApplicationIn: dir. + + priority := Processor userBackgroundPriority. + task := block forkAt: priority. + task addExitAction: + [ + task isNil + ifTrue: [self inform: 'Application build.' asBoldText] + ifFalse:[self informTargetBuildingFailured]. + Display beep. + ] +! + doSelectCFile: whichFile "opens a FileSelectionBrowser in order to select C-file" |currentFile selectedFile| - currentFile := Aspects at: whichFile asLowercaseFirst asSymbol. + currentFile := aspects at: whichFile asLowercaseFirst asSymbol. ((selectedFile := FileSelectionBrowser request: 'Select Your ', whichFile, ' File' @@ -763,7 +773,7 @@ |currentDir selectedDir| - currentDir := Aspects at: (whichDir asLowercaseFirst, 'Directory') asSymbol. + currentDir := aspects at: (whichDir asLowercaseFirst, 'Directory') asSymbol. ((selectedDir := FileSelectionBrowser request: 'Select Your ', whichDir, ' Directory' @@ -781,7 +791,7 @@ |currentFile selectedFile| - currentFile := Aspects at: whichFile asLowercaseFirst asSymbol. + currentFile := aspects at: whichFile asLowercaseFirst asSymbol. ((selectedFile := FileSelectionBrowser request: 'Select Your ', whichFile, ' File' @@ -799,11 +809,11 @@ |dir| self doStop. - (dir := self getApplicationDirectory) isNil + (dir := self getTargetDirectory) isNil ifTrue: [^self warn: 'Application directory does not exists!!']. shellView directory: dir. - shellView executeCommand: (Aspects at: #applicationName) value. + shellView executeCommand: (aspects at: #applicationName) value. ! @@ -815,6 +825,46 @@ shellView executeCommand: 'clear'. self inform: '' +! + +executeCommand: aCommand inDirectory: dir + "executes aCommand in directory dir; put aCommand and the result into the shell view" + + |outStream| + + shellView directory: dir. + shellView append: shellView getDirectoryTextString, ' ', aCommand. + + outStream:= PipeStream readingFrom: aCommand errorDisposition:#inline inDirectory: dir. + [ + outStream canReadWithoutBlocking + ifTrue: + [ + outStream readWait. + shellView append: shellView getDirectoryTextString, ' ', + (Text string: (outStream upTo: Character cr) color: Color red). + ]. + ] doWhile:[outStream atEnd not]. + + outStream close + +! + +inform: aString + "outputs aString via shell view as information" + + shellView commandInputField contents: aString + + + + +! + +informTargetBuildingFailured + "informs that something went wrong" + + self inform: 'Application building failured.' asBoldText. + task := nil ! ! !ApplicationBuilder methodsFor:'aspects'! @@ -822,14 +872,13 @@ aspectFor:aKey "returns an aspect at aKey" - ^Aspects at: aKey ifAbsent: [super aspectFor:aKey] - + ^aspects at: aKey ifAbsent: [super aspectFor:aKey] ! aspectsAt: aKey putFirst: anObject "puts firstly anObject as ValueHolder at aKey and returns it" - ^Aspects at: aKey ifAbsent: [Aspects at: aKey put: anObject asValue] + ^aspects at: aKey ifAbsent: [aspects at: aKey put: anObject asValue] @@ -863,228 +912,221 @@ shellView "returns a shell view" - shellView isNil ifTrue: [shellView := ShellView new. shellView directory: (Aspects at: #topDirectory) value]. + shellView isNil ifTrue: [shellView := ShellView new. shellView directory: (aspects at: #topDirectory) value]. ^shellView ! ! -!ApplicationBuilder methodsFor:'building'! - -clobberTargetDirectory: dir - "clobbers the target directory of the application" +!ApplicationBuilder methodsFor:'building blocks'! - self executeCommand: 'rm -r *' inDirectory: dir - - - - +getBlockForClobberingTargetDirectory: dir + "returns the block for clobbering the target directory of the application" -! - -compileModulListFileWith: ccPathAndFlags inDirectory: dir - "compiles the C-file with the list of the module names" - - |command| - - command := ccPathAndFlags , ' -c -fPIC -O6 -fomit-frame-pointer -m486 -DDEBUG -Di386 modulList.c'. - - self executeCommand: command inDirectory: dir + ^ + [ + self inform: 'Clobbering the target directory...'. + self executeCommand: 'rm -r *' inDirectory: dir. + task := nil + ] ! -compileStartupCFileWith: ccPathAndFlags inDirectory: dir - "compiles the startup file with passing startup class, startup selector, configuration string, and build date" - - |startUpClass cls startUpSelector startupFile command| +getBlockForCompilingModulListFileWith: compilerPathAndFlags inDirectory: dir + "returns the block for compiling the C-file with the list of the module names" - startUpClass := ((Aspects at: #startupMessage) value upTo: $ ) asSymbol. - (cls := Smalltalk at: startUpClass) isNil ifTrue: [^self warn: 'Defined class not found in system!!']. - startUpSelector := ((Aspects at: #startupMessage) value copy reverse upTo: $ ) reverse asSymbol. - (cls respondsTo: startUpSelector) ifFalse: [^self warn: 'Defined class does not respond to the defined selector!!']. - startupFile := (Aspects at: #startupCFile) value asFilename. - startupFile copyTo: (startupFile := dir asFilename construct: (Aspects at: #startupCFile) value asFilename baseName). - command := ccPathAndFlags , ' -o main.o -c -O -O6 -fomit-frame-pointer -m486 -DDEBUG -Di386 ', - '-DSTARTUP_CLASS="\"', startUpClass, '\"" ', - '-DSTARTUP_SELECTOR="\"', startUpSelector, '\"" ', - '-DCONFIGURATION_STRING="\"', (Aspects at: #configuration) value, '\"" ', - '-DBUILD_DATE="\"', (Aspects at: #buildDate) value, '\"" ', - startupFile name. - - self executeCommand: command inDirectory: dir + ^ + [ + |command| + self inform: 'Starting compilation of the modules init file...'. + command := compilerPathAndFlags , ' -c -fPIC -O6 -fomit-frame-pointer -m486 -DDEBUG -Di386 modulList.c'. + self executeCommand: command inDirectory: dir. + (dir asFilename construct: 'modulList.o') exists + ifTrue: [task := nil] + ifFalse: [self warn:'Could not compile the modules file!!'] + ] ! -compileStartupFileWith: ccPathAndFlags inDirectory: dir - "compiles the startup file with passing startup class, startup selector, configuration string, and build date" +getBlockForCompilingStartupCFileWith: compilerPathAndFlags inDirectory: dir + "returns the block for compiling the startup file with passing startup class, startup selector, configuration string, and build date" - |startUpClass cls startUpSelector startupFile command| + ^ + [ + |startUpClass cls startUpSelector startupFile command| + ((aspects at: #startupCFile) value asFilename) exists + ifFalse: + [ + self warn: 'Defined startup C-file not found!!' + ] + ifTrue: + [ + self inform: 'Starting compilation of the startup C-file...'. - startUpClass := ((Aspects at: #startupMessage) value upTo: $ ) asSymbol. - (cls := Smalltalk at: startUpClass) isNil ifTrue: [^self warn: 'Defined class not found in system!!']. - startUpSelector := ((Aspects at: #startupMessage) value copy reverse upTo: $ ) reverse asSymbol. - (cls respondsTo: startUpSelector) ifFalse: [^self warn: 'Defined class does not respond to the defined selector!!']. - startupFile := (Aspects at: #startupModule) value asFilename. - startupFile copyTo: (startupFile := dir asFilename construct: (Aspects at: #startupModule) value asFilename baseName). - command := ccPathAndFlags , ' -o main.o -c -O -O6 -fomit-frame-pointer -m486 -DDEBUG -Di386 ', - '-DSTARTUP_CLASS="\"', startUpClass, '\"" ', - '-DSTARTUP_SELECTOR="\"', startUpSelector, '\"" ', - '-DCONFIGURATION_STRING="\"', (Aspects at: #configuration) value, '\"" ', - '-DBUILD_DATE="\"', (Aspects at: #buildDate) value, '\"" ', - startupFile name. + startUpClass := ((aspects at: #startupMessage) value upTo: $ ) asSymbol. + (cls := Smalltalk at: startUpClass) isNil ifTrue: [^self warn: 'Defined class not found in system!!']. + startUpSelector := ((aspects at: #startupMessage) value copy reverse upTo: $ ) reverse asSymbol. + (cls respondsTo: startUpSelector) ifFalse: [^self warn: 'Defined class does not respond to the defined selector!!']. + startupFile := (aspects at: #startupCFile) value asFilename. + startupFile copyTo: (startupFile := dir asFilename construct: (aspects at: #startupCFile) value asFilename baseName). + command := compilerPathAndFlags , ' -o main.o -c -O -O6 -fomit-frame-pointer -m486 -DDEBUG -Di386 ', + '-DSTARTUP_CLASS="\"', startUpClass, '\"" ', + '-DSTARTUP_SELECTOR="\"', startUpSelector, '\"" ', + '-DCONFIGURATION_STRING="\"', (aspects at: #configuration) value, '\"" ', + '-DBUILD_DATE="\"', (aspects at: #buildDate) value, '\"" ', + startupFile name. - self executeCommand: command inDirectory: dir + self executeCommand: command inDirectory: dir. + ]. + (dir asFilename construct: 'main.o') exists + ifTrue: [task := nil] + ifFalse: [self warn:'Could not compile the startup C-file!!'] + ] ! -createSymbolicLinksToTheLibrariesIn: dir - "creates the symbolic links to the libraries" +getBlockForCreatingSymbolicLinksToTheLibrariesIn: dir + "returns the block for creating the symbolic links to the libraries" - self getLibraryFileNames value do: - [:libPath| - self executeCommand: 'ln -s ', libPath , ' ', libPath asFilename head inDirectory: dir + ^ + [ + self inform: 'Starting defining of the symbolic links to the libraries...'. + self getLibraryFileNames value do: + [:libPath| + self executeCommand: 'ln -s ', libPath , ' ', libPath asFilename head inDirectory: dir + ]. + task := nil. ] - - - ! -createSymbolicLinksToTheResourcesIn: dir - "creates the symbolic links to the resources" +getBlockForCreatingSymbolicLinksToTheResourcesIn: dir + "returns the block for creating the symbolic links to the resources" - (Aspects at: #linkRCFiles) value - ifTrue: - [ - self executeCommand: - 'ln -s ', - ((Aspects at: #libraryDirectory) value asFilename construct: '*.rc') name, ' ', - (Aspects at: #targetDirectory) value inDirectory: dir. - ]. - (Aspects at: #linkResources) value - ifTrue: - [ - self executeCommand: - 'cp -r -d ', - ((Aspects at: #libraryDirectory) value asFilename construct: 'resources') name, ' ', - (Aspects at: #targetDirectory) value inDirectory: dir. - ]. - (Aspects at: #linkSources) value - ifTrue: - [ - self executeCommand: - 'cp -r -d ', - ((Aspects at: #libraryDirectory) value asFilename construct: 'source') name, ' ', - (Aspects at: #targetDirectory) value inDirectory: dir. - ]. - (Aspects at: #linkBitmaps) value - ifTrue: - [ - self executeCommand: - 'cp -r -d ', - ((Aspects at: #libraryDirectory) value asFilename construct: 'bitmaps') name, ' ', - (Aspects at: #targetDirectory) value inDirectory: dir. - ]. - - -! - -executeCommand: aCommand inDirectory: dir - "executes aCommand in directory dir; put aCommand and the result into the shell view" - - |outStream| - - shellView directory: dir. - shellView append: shellView getDirectoryTextString, ' ', aCommand. - - outStream:= PipeStream readingFrom: aCommand errorDisposition:#inline inDirectory: dir. - [ - outStream canReadWithoutBlocking + ^ + [ + self inform: 'Starting linking of the resources...'. + (aspects at: #linkRCFiles) value + ifTrue: + [ + self executeCommand: + 'ln -s ', + ((aspects at: #libraryDirectory) value asFilename construct: '*.rc') name, ' ', + (aspects at: #targetDirectory) value inDirectory: dir. + ]. + (aspects at: #linkResources) value ifTrue: - [ - outStream readWait. - shellView append: shellView getDirectoryTextString, ' ', - (Text string: (outStream upTo: Character cr) color: Color red). + [ + self executeCommand: + 'cp -r -d ', + ((aspects at: #libraryDirectory) value asFilename construct: 'resources') name, ' ', + (aspects at: #targetDirectory) value inDirectory: dir. ]. - ] doWhile:[outStream atEnd not]. - - outStream close + (aspects at: #linkSources) value + ifTrue: + [ + self executeCommand: + 'cp -r -d ', + ((aspects at: #libraryDirectory) value asFilename construct: 'source') name, ' ', + (aspects at: #targetDirectory) value inDirectory: dir. + ]. + (aspects at: #linkBitmaps) value + ifTrue: + [ + self executeCommand: + 'cp -r -d ', + ((aspects at: #libraryDirectory) value asFilename construct: 'bitmaps') name, ' ', + (aspects at: #targetDirectory) value inDirectory: dir. + ]. + task := nil. + ] ! -generateCFileWithModulesIn: dir - "generates a C-file with the modules in directory dir" +getBlockForGeneratingCFileWithModulesIn: dir + "returns the block for generating a C-file with the modules in directory dir" - |selectionOfLibraries| + ^ + [ + |selectionOfLibraries| + + self inform: 'Starting generation of the C-file with modules...'. - selectionOfLibraries := self getModuleNames. - self executeCommand: 'echo "#include " > modulList.c' inDirectory: dir. - self executeCommand: 'echo "typedef void (*vf)();" >> modulList.c' inDirectory: dir. - selectionOfLibraries do: - [:lib| - self executeCommand: 'echo "extern void _', lib, '_Init();" >> modulList.c' inDirectory: dir. - ]. - self executeCommand: 'echo "static vf modules[] = {" >> modulList.c' inDirectory: dir. - selectionOfLibraries do: - [:lib| - self executeCommand: 'echo "_', lib, '_Init," >> modulList.c' inDirectory: dir. - ]. - self executeCommand: 'echo "(vf)0};" >> modulList.c' inDirectory: dir. - self executeCommand: 'echo "vf *__modules__ = modules;" >> modulList.c' inDirectory: dir + selectionOfLibraries := self getModuleNames. + self executeCommand: 'echo "#include " > modulList.c' inDirectory: dir. + self executeCommand: 'echo "typedef void (*vf)();" >> modulList.c' inDirectory: dir. + selectionOfLibraries do: + [:lib| + self executeCommand: 'echo "extern void _', lib, '_Init();" >> modulList.c' inDirectory: dir. + ]. + self executeCommand: 'echo "static vf modules[] = {" >> modulList.c' inDirectory: dir. + selectionOfLibraries do: + [:lib| + self executeCommand: 'echo "_', lib, '_Init," >> modulList.c' inDirectory: dir. + ]. + self executeCommand: 'echo "(vf)0};" >> modulList.c' inDirectory: dir. + self executeCommand: 'echo "vf *__modules__ = modules;" >> modulList.c' inDirectory: dir. + (dir asFilename construct: 'modulList.c') exists + ifTrue: [task := nil] + ifFalse: [self warn:'Could not generate the C-file with libraries!!'] + ] ! -generateHFileWithSymbolsIn: dir - "generates a H-file with the symbols in directory dir" +getBlockForGeneratingHFileWithSymbolsIn: dir + "returns the block for generating a H-file with the symbols in directory dir" + + ^ + [ + |symbolsFile realInc| + + self inform: 'Starting generation of the h-file with symbols...'. - |symbolsFile realInc| - ByteCodeCompiler stcCompilationIncludes asArrayOfSubstrings do: - [:inc| - realInc := inc readStream. - realInc upTo: $/. - realInc := '/', realInc upToEnd. - (symbolsFile := realInc asFilename construct: 'symbols.stc') exists - ifTrue: - [ - self executeCommand: 'echo "char *__symbols[] = {" > symbols.h' inDirectory: dir. - self executeCommand: 'sed ''s/^/"/'' < ', symbolsFile name,' | sed ''s/$/",/'' | sed ''s/\\/\\\\/g'' >> symbols.h' inDirectory: dir. - self executeCommand: 'echo "0 };" >> symbols.h' inDirectory: dir. - ] - ]. - ^nil + ByteCodeCompiler stcCompilationIncludes asArrayOfSubstrings do: + [:inc| + realInc := inc readStream. + realInc upTo: $/. + realInc := '/', realInc upToEnd. + (symbolsFile := realInc asFilename construct: 'symbols.stc') exists + ifTrue: + [ + self executeCommand: 'echo "char *__symbols[] = {" > symbols.h' inDirectory: dir. + self executeCommand: 'sed ''s/^/"/'' < ', symbolsFile name,' | sed ''s/$/",/'' | sed ''s/\\/\\\\/g'' >> symbols.h' inDirectory: dir. + self executeCommand: 'echo "0 };" >> symbols.h' inDirectory: dir. + ] + ]. - + (dir asFilename construct: 'symbols.h') exists + ifTrue: [task := nil] + ifFalse: [self warn:'Could not generate the h-file with symbols!!'] + ] ! -inform: aString - "outputs aString via shell view as information" - - shellView commandInputField contents: aString - +getBlockForLinkingLibrariesToTheApplicationIn: dir + "returns the block for linking the libraries to the application" - + ^ + [ + |appName command| -! + self inform: 'Starting linking of the libraries to the application...'. -linkLibrariesToTheApplicationIn: dir - "links the libraries to the application" + appName := (aspects at: #applicationName) value. - |appName command| - - appName := (Aspects at: #applicationName) value. + command := ByteCodeCompiler ccPath, + ' ', (aspects at: #applicationLinkDefines) value, ' ', + ' -o ' , appName, + ' modulList.o main.o ', + ((aspects at: #libraryDirectory) value asFilename construct: 'librun', ObjectFileLoader sharedLibraryExtension) name, ' ', + ((self getLibraryFileNames, (aspects at: #systemLibraries) value) asStringCollection asStringWith: $ ). - command := ByteCodeCompiler ccPath, - ' ', (Aspects at: #applicationLinkDefines) value, ' ', - ' -o ' , appName, - ' modulList.o main.o ', - ((Aspects at: #libraryDirectory) value asFilename construct: 'librun', ObjectFileLoader sharedLibraryExtension) name, ' ', - ((self getLibraryFileNames, (Aspects at: #systemLibraries) value) asStringCollection asStringWith: $ ). + self executeCommand: command inDirectory: dir. - self executeCommand: command inDirectory: dir - - - + (dir asFilename construct: (aspects at: #applicationName) value) exists + ifTrue: [task := nil] + ifFalse: [self warn:'Could not build the application!!'] + ] ! ! @@ -1095,46 +1137,33 @@ |library libraries| - (changedObject == (Aspects at: #stxLibrary)) + changedObject == (aspects at: #stxLibrary ifAbsent: nil) ifTrue: [ - libraries := (Aspects at: #stxLibraries) value. - (Aspects at: #stxLibrary) value size = 0 ifTrue: [libraries remove: (Aspects at: #oldSTXLibrary) value ifAbsent: nil]. - (Aspects at: #oldSTXLibrary) value: (library := (Aspects at: #stxLibrary) value). - (libraries includes: library) not & - library notEmpty - ifTrue: - [ - libraries addFirst: library - ] + libraries := (aspects at: #stxLibraries) value. + (aspects at: #stxLibrary) value size = 0 ifTrue: [libraries remove: (aspects at: #oldSTXLibrary) value ifAbsent: nil]. + (aspects at: #oldSTXLibrary) value: (library := (aspects at: #stxLibrary) value). ]. - (changedObject == (Aspects at: #systemLibrary)) + changedObject == (aspects at: #systemLibrary) ifTrue: [ - libraries := (Aspects at: #systemLibraries) value. - (Aspects at: #systemLibrary) value size = 0 ifTrue: [libraries remove: (Aspects at: #oldSystemLibrary) value ifAbsent: nil]. - (Aspects at: #oldSystemLibrary) value: (library := (Aspects at: #systemLibrary) value). - (libraries includes: library) not & - library notEmpty - ifTrue: - [ - libraries addFirst: library - ] + libraries := (aspects at: #systemLibraries) value. + (aspects at: #systemLibrary) value size = 0 ifTrue: [libraries remove: (aspects at: #oldSystemLibrary) value ifAbsent: nil]. + (aspects at: #oldSystemLibrary) value: (library := (aspects at: #systemLibrary) value). ]. - (changedObject == (Aspects at: #userLibrary)) + changedObject == (aspects at: #userLibrary ifAbsent: nil) ifTrue: [ - libraries := (Aspects at: #userLibraries) value. - (Aspects at: #userLibrary) value size = 0 ifTrue: [libraries remove: (Aspects at: #oldUserLibrary) value ifAbsent: nil]. - (Aspects at: #oldUserLibrary) value: (library := (Aspects at: #userLibrary) value). - (libraries includes: library) not & - library notEmpty - ifTrue: - [ - libraries addFirst: library - ] + libraries := (aspects at: #userLibraries) value. + (aspects at: #userLibrary) value size = 0 ifTrue: [libraries remove: (aspects at: #oldUserLibrary) value ifAbsent: nil]. + (aspects at: #oldUserLibrary) value: (library := (aspects at: #userLibrary) value). ]. - + (libraries includes: library) not & + library notEmpty + ifTrue: + [ + libraries addFirst: library + ] @@ -1151,55 +1180,48 @@ super initialize. - Aspects := Aspects ? IdentityDictionary new. + aspects := self class aspects. homeDir := Filename homeDirectory asFilename. + self aspectsAt: #topDirectory putFirst: (homeDir construct: 'stx') name. + self aspectsAt: #systemLibraries putFirst: ObjectFileLoader searchedLibraries. + (aspects at: #systemLibrary put: ((aspects at: #systemLibraries) value at: 1 ifAbsent: '') asValue) addDependent: self. + self aspectsAt: #oldSystemLibrary putFirst: (aspects at: #systemLibrary) value. + self aspectsAt: #configuration putFirst: Smalltalk configuration. + + self class ~~ ApplicationBuilder ifTrue: [^nil]. + self aspectsAt: #applicationName putFirst: 'application'. self aspectsAt: #startupMessage putFirst: 'Smalltalk start'. self aspectsAt: #startupCFile putFirst: (homeDir construct: 'stx/librun/main.c') name. - self aspectsAt: #topDirectory putFirst: (homeDir construct: 'stx') name. + self aspectsAt: #targetDirectory putFirst: (homeDir construct: 'stx/projects/application') name. self aspectsAt: #libraryDirectory putFirst: (homeDir construct: 'stx/projects/smalltalk') name. self aspectsAt: #stxLibraries putFirst: (ObjectMemory binaryModuleInfo collect: [:binMoInfo| (binMoInfo name copy reverse upTo: $ ) reverse]) asSortedCollection. - self aspectsAt: #systemLibraries putFirst: ObjectFileLoader searchedLibraries. + self aspectsAt: #userLibraries putFirst: OrderedCollection new. - Aspects at: #buildDate put: Date today printString, ' ', Time now printString. - self aspectsAt: #configuration putFirst: Smalltalk configuration. + aspects at: #buildDate put: Date today printString, ' ', Time now printString. self aspectsAt: #linkRCFiles putFirst: true. self aspectsAt: #linkResources putFirst: true. self aspectsAt: #linkSources putFirst: true. self aspectsAt: #linkBitmaps putFirst: true. - (Aspects at: #stxLibrary put: ((Aspects at: #stxLibraries) value at: 1 ifAbsent: '') asValue) addDependent: self. - (Aspects at: #systemLibrary put: ((Aspects at: #systemLibraries) value at: 1 ifAbsent: '') asValue) addDependent: self. - (Aspects at: #userLibrary put: ((Aspects at: #userLibraries) value at: 1 ifAbsent: '') asValue) addDependent: self. + (aspects at: #stxLibrary put: ((aspects at: #stxLibraries) value at: 1 ifAbsent: '') asValue) addDependent: self. + (aspects at: #userLibrary put: ((aspects at: #userLibraries) value at: 1 ifAbsent: '') asValue) addDependent: self. - self aspectsAt: #oldSTXLibrary putFirst: (Aspects at: #stxLibrary) value. - self aspectsAt: #oldSystemLibrary putFirst: (Aspects at: #systemLibrary) value. - self aspectsAt: #oldUserLibrary putFirst: (Aspects at: #userLibrary) value. + self aspectsAt: #oldSTXLibrary putFirst: (aspects at: #stxLibrary) value. + self aspectsAt: #oldUserLibrary putFirst: (aspects at: #userLibrary) value. self aspectsAt: #applicationLinkDefines putFirst: '-L/usr/X11/lib -Llib -Lbinary -L. -L/usr/local/lib -L/usr/lib -L/lib -lm -ldl -lXext -lX11'. ! ! !ApplicationBuilder methodsFor:'queries'! -getApplicationDirectory - "returns the directory of the application; if not present, create it" - - |appDir| - - (appDir := (Aspects at: #targetDirectory) value asFilename) exists ifFalse:[appDir makeDirectory]. - (appDir isReadable and:[appDir isWritable]) ifFalse: [^nil]. - - ^appDir name - -! - getCompilerFlags "returns the defines of the OS and the compiler flags of the ByteCodeCompiler" @@ -1225,18 +1247,18 @@ libraryFileNames := OrderedCollection new. - (Aspects at: #stxLibraries) value do: + (aspects at: #stxLibraries) value do: [:lib| |abbrevLib libPath| abbrevLib := lib. lib = 'GLXWorkstation' ifTrue: [abbrevLib := 'GLXWorkstat']. lib = 'XWorkstation' ifTrue: [abbrevLib := 'XWorkstat' ]. lib = 'ObjectFileLoader' ifTrue: [abbrevLib := 'ObjFLoader' ]. - (libPath := (Aspects at: #libraryDirectory) value asFilename construct: abbrevLib, ObjectFileLoader sharedLibraryExtension) exists + (libPath := (aspects at: #libraryDirectory) value asFilename construct: abbrevLib, ObjectFileLoader sharedLibraryExtension) exists ifTrue: [libraryFileNames add: libPath name] ]. - ^libraryFileNames, (Aspects at: #userLibraries) value + ^libraryFileNames, (aspects at: #userLibraries) value ! @@ -1246,12 +1268,25 @@ |moduleNames| moduleNames := OrderedCollection new. - (Aspects at: #userLibraries) value do: + (aspects at: #userLibraries) value do: [:lib| lib asFilename exists ifTrue: [moduleNames add: (lib asFilename baseName upTo: $.)] ]. - ^(Aspects at: #stxLibraries) value, moduleNames + ^(aspects at: #stxLibraries) value, moduleNames +! + +getTargetDirectory + "returns the directory of the application; if not present, create it" + + |targetDirectory| + + (targetDirectory := (aspects at: #targetDirectory) value asFilename) exists ifFalse:[targetDirectory makeDirectory]. + (targetDirectory isReadable and:[targetDirectory isWritable]) ifFalse: [^nil]. + + ^targetDirectory name + + ! ! !ApplicationBuilder methodsFor:'startup / release'! @@ -1260,7 +1295,7 @@ "close request; before closing stop the running build, then release the dependents of all aspects" self doStop. - Aspects do: [:aspect| aspect release]. + aspects do: [:aspect| aspect release]. super closeRequest @@ -1269,5 +1304,5 @@ !ApplicationBuilder class methodsFor:'documentation'! version - ^ '$Header: /cvs/stx/stx/libtool/ApplicationBuilder.st,v 1.1 1998-03-31 18:22:48 tz Exp $' + ^ '$Header: /cvs/stx/stx/libtool/ApplicationBuilder.st,v 1.2 1998-04-02 19:02:02 tz Exp $' ! !