ProjectBuilder.st
author Claus Gittinger <cg@exept.de>
Fri, 23 Oct 2009 14:47:28 +0200
changeset 2680 3f2dbbd7743f
parent 2678 cca2788228ad
child 2683 ff39502be3a2
permissions -rw-r--r--
*** empty log message ***
     1 "{ Package: 'stx:libtool2' }"
     2 
     3 "{ NameSpace: Tools }"
     4 
     5 Object subclass:#ProjectBuilder
     6 	instanceVariableNames:'package projectDefinitionClass sourceCodeManager buildDirectory
     7 		myWorkingDirectory mySTXTopDirectory myTopDirectory outputStream
     8 		makeExeOnly usedCompiler'
     9 	classVariableNames:'PreviousBuildDirectory'
    10 	poolDictionaries:''
    11 	category:'System-Support-Projects'
    12 !
    13 
    14 
    15 !ProjectBuilder class methodsFor:'accessing'!
    16 
    17 previousBuildDirectory
    18     ^ PreviousBuildDirectory
    19 !
    20 
    21 previousBuildDirectory:something
    22     PreviousBuildDirectory := something.
    23 ! !
    24 
    25 !ProjectBuilder class methodsFor:'examples'!
    26 
    27 example1
    28     Smalltalk loadPackage:'stx:projects/helloWorldApp' asAutoloaded:true.
    29 
    30     self new
    31         package:'stx:projects/helloWorldApp';
    32         build
    33 !
    34 
    35 example2
    36     |builder|
    37 
    38     Smalltalk loadPackage:'stx:clients/Demos/foxCalcApplication' asAutoloaded:true.
    39 
    40     builder := self new.
    41     builder package:'stx:clients/Demos/foxCalcApplication'.
    42     builder build.
    43 
    44     UserPreferences fileBrowserClass openOnDirectory:builder packageBuildDirectory.
    45 ! !
    46 
    47 !ProjectBuilder methodsFor:'accessing'!
    48 
    49 buildDirectory
    50     ^ buildDirectory
    51 !
    52 
    53 buildDirectory:something
    54     buildDirectory := something.
    55 !
    56 
    57 makeExeOnly:aBoolean
    58     makeExeOnly := aBoolean.
    59 !
    60 
    61 package:aPackageIDOrSymbol
    62     package := aPackageIDOrSymbol asPackageId.
    63 !
    64 
    65 packageBuildDirectory
    66     "the directoray, where the deployable binary is created (xxxSetup.exe)"
    67 
    68     ^ buildDirectory / (package asPackageId module) / (package asPackageId directory)
    69 !
    70 
    71 projectDefinitionClass:something
    72     projectDefinitionClass := something.
    73 !
    74 
    75 usedCompiler:something
    76     usedCompiler := something.
    77 ! !
    78 
    79 !ProjectBuilder methodsFor:'building'!
    80 
    81 build
    82     "/ intermediate - this will move into a commonly used utility class
    83     "/ (where all the project code support will be collected).
    84 
    85     |makeOutput|
    86 
    87     makeOutput := TextStream on:(Text new:10000).
    88     self buildWithColorizedOutputTo:makeOutput.
    89 
    90     TextView openWith:makeOutput contents.
    91 !
    92 
    93 buildWithColorizedOutputTo:makeOutput
    94     "/ intermediate - this will move into a commonly used utility class
    95     "/ (where all the project code support will be collected).
    96 
    97     |stdOut stdErr lock|
    98 
    99     lock := Semaphore forMutualExclusion.
   100 
   101     stdErr := ActorStream new
   102                     nextPutBlock:[:char |
   103                         lock critical:[
   104                             makeOutput emphasis:{#backgroundColor->Color red. #color->Color white.}.
   105                             makeOutput nextPut:char.
   106                             makeOutput emphasis:nil.
   107                         ]
   108                     ];
   109                     nextPutAllBlock:[:char |
   110                         lock critical:[
   111                             makeOutput emphasis:{#backgroundColor->Color red. #color->Color white.}.
   112                             makeOutput nextPutAll:char.
   113                             makeOutput emphasis:nil.
   114                         ]
   115                     ].
   116     stdOut := ActorStream new
   117                     nextPutBlock:[:char |
   118                         lock critical:[
   119                             makeOutput nextPut:char.
   120                         ]
   121                     ];
   122                     nextPutAllBlock:[:char |
   123                         lock critical:[
   124                             makeOutput nextPutAll:char.
   125                         ]
   126                     ].
   127 
   128     self buildWithOutputTo:stdOut errorTo:stdErr.
   129 !
   130 
   131 buildWithOutputTo:stdOut errorTo:stdErr
   132     "/ intermediate - this will move into a commonly used utility class
   133     "/ (where all the project code support will be collected).
   134 
   135     |module directory|
   136 
   137     projectDefinitionClass := ProjectDefinition definitionClassForPackage:package.
   138     projectDefinitionClass isNil ifTrue:[
   139         self error:('Missing ProjectDefinition class for "',package asString,'"')
   140     ].
   141 
   142     "/ ensure that everything is loaded...
   143     projectDefinitionClass loadAsAutoloaded:false.
   144     projectDefinitionClass loadExtensions.
   145     projectDefinitionClass loadAllClassesAsAutoloaded:false.
   146 
   147     module := package module.
   148     directory := package directory.
   149 
   150     buildDirectory isNil ifTrue:[
   151         buildDirectory := PreviousBuildDirectory ifNil:[ UserPreferences current buildDirectory ].
   152         buildDirectory isNil ifTrue:[
   153             buildDirectory := Filename tempDirectory construct:'stx_build'.
   154         ].
   155     ].
   156     buildDirectory := buildDirectory asFilename.
   157 
   158     "/ self validateBuildDirectoryIsPresent.
   159 
   160     PreviousBuildDirectory := buildDirectory.
   161 
   162     "/ UserPreferences current localBuild:true
   163     UserPreferences current localBuild ifFalse:[
   164         SourceCodeManager notNil ifTrue:[
   165             sourceCodeManager := SourceCodeManagerUtilities sourceCodeManagerFor:projectDefinitionClass.
   166         ]
   167     ].
   168     sourceCodeManager := nil.
   169 
   170     myTopDirectory := 
   171         Smalltalk packagePath 
   172             detect:[:aPath |
   173                 (aPath asFilename / 'stx' / 'include') exists
   174                 and: [ (aPath asFilename / 'stx' / 'rules') exists ]]
   175             ifNone:nil.       
   176     myTopDirectory isNil ifTrue:[
   177         self error:('Cannot figure out my top directory (where stx/include and stx/rules are)')
   178     ].
   179     myTopDirectory := myTopDirectory asFilename.
   180     mySTXTopDirectory := myTopDirectory / 'stx'.
   181 
   182     self setupBuildDirectory.
   183     self activityNotification:'Generating stc directory...'.
   184     self copySTCDirectoryForBuild.
   185     self activityNotification:'Generating source files...'.
   186     self generateSourceFiles.
   187     self activityNotification:'Copying dlls for linkage...'.
   188     self copyDLLsForLinkage.
   189     self activityNotification:'Copying support files for linkage...'.
   190     self copySupportFilesForLinkage.
   191     self copyStartupFilesFromSmalltalk.
   192 
   193     self activityNotification:'Executing make...'.
   194     self makeWithOutputTo:stdOut errorTo:stdErr.
   195 !
   196 
   197 copyDLLsForLinkage
   198     |targetBuildDir|
   199 
   200     targetBuildDir := buildDirectory / package module / package directory.
   201 
   202     (projectDefinitionClass allPreRequisites)
   203     do:[:eachPackageToFileout |
   204         |packageId packageDef packageModule packageDirectory packageTargetDir
   205          dllSource dllSourceDir libraryName dllRelativePath|
   206 
   207         packageId := eachPackageToFileout asPackageId.
   208         packageModule := packageId module.
   209         packageDirectory := packageId directory.
   210         packageTargetDir := (buildDirectory / packageModule / packageDirectory) recursiveMakeDirectory.
   211 
   212         packageDef := packageId projectDefinitionClass.
   213         libraryName := packageDef libraryName.
   214 
   215         "/ mhmh - take them from my tree or from the projects/smalltalk execution directory ??
   216         dllSourceDir := myTopDirectory / packageModule / packageDirectory.
   217         OperatingSystem isMSWINDOWSlike ifTrue:[
   218 "/            dllRelativePath := 'objvc','/',(libraryName,'.dll').
   219 "/            (dllSourceDir / dllRelativePath) exists 
   220             false ifFalse:[
   221                 dllRelativePath := 'objbc','/',(libraryName,'.dll').
   222             ]
   223         ] ifFalse:[
   224             dllRelativePath := libraryName,'.so'.
   225         ].
   226         ((packageTargetDir / dllRelativePath) exists
   227         and:[ (dllSourceDir / dllRelativePath) fileSize = (packageTargetDir / dllRelativePath) fileSize
   228         and:[ (dllSourceDir / dllRelativePath) modificationTime < (packageTargetDir / dllRelativePath) modificationTime
   229         "/ and:[ (dllSourceDir / dllRelativePath) sameContentsAs:(packageTargetDir / dllRelativePath) ]
   230         ]]) ifFalse:[
   231             (packageTargetDir / dllRelativePath) directory recursiveMakeDirectory.
   232             (dllSourceDir / dllRelativePath) copyTo:(packageTargetDir / dllRelativePath).    
   233         ]
   234     ].
   235 !
   236 
   237 copyDirectory:relativepath
   238     "/ need rules in stx
   239     ((Smalltalk projectDirectoryForPackage:'stx') asFilename construct:relativepath)
   240         recursiveCopyTo:(buildDirectory construct:'stx').
   241 !
   242 
   243 copyDirectoryForBuild:subdir
   244     |targetDir targetFile|
   245 
   246     targetDir := buildDirectory / 'stx' / subdir.
   247     targetDir exists ifFalse:[
   248         targetDir makeDirectory.
   249     ].
   250     (mySTXTopDirectory / subdir) directoryContentsAsFilenamesDo:[:eachFile |
   251         eachFile isDirectory ifFalse:[
   252             targetFile := targetDir / eachFile baseName.
   253             (targetFile exists not
   254             or:[ targetFile modificationTime < eachFile modificationTime ]) ifTrue:[
   255                 self activityNotification:'copying ',eachFile pathName,'...'.
   256                 eachFile copyTo:(targetDir construct:eachFile baseName)
   257             ]
   258         ].
   259     ].
   260     self activityNotification:nil
   261 !
   262 
   263 copyResourcesForPackage:aPackage
   264     |module directory|
   265 
   266     module := aPackage asPackageId module.
   267     directory := aPackage asPackageId directory.
   268 
   269     (myTopDirectory / module / directory / 'resources' ) exists ifTrue:[
   270         (myTopDirectory / module / directory / 'resources' )
   271             recursiveCopyTo:(buildDirectory / module / directory)
   272     ].
   273     (myTopDirectory / module / directory / 'styles' ) exists ifTrue:[
   274         (myTopDirectory / module / directory / 'styles' )
   275             recursiveCopyTo:(buildDirectory / module / directory)
   276     ].
   277 !
   278 
   279 copySTCDirectoryForBuild
   280     |targetDir stc files|
   281 
   282     targetDir := buildDirectory / 'stx' / 'stc'.
   283     targetDir exists ifFalse:[ targetDir makeDirectory ].
   284 
   285     stc := OperatingSystem isMSWINDOWSlike 
   286                 ifTrue:[ 'stc.exe' ]
   287                 ifFalse:[ 'stc' ].
   288 
   289     files := #( ) copyWith:stc.
   290 
   291     files do:[:eachFile |
   292         |sourceFile targetFile|
   293 
   294         sourceFile := mySTXTopDirectory / 'stc' / eachFile.
   295         targetFile := targetDir / eachFile.
   296         (targetFile exists not
   297         or:[ targetFile modificationTime < sourceFile modificationTime ]) ifTrue:[
   298             self activityNotification:'copying ',sourceFile pathName,'...'.
   299             sourceFile copyTo:targetFile
   300         ].
   301     ].
   302     self activityNotification:nil
   303 !
   304 
   305 copyStartupFilesFromSmalltalk
   306     (buildDirectory / 'stx' / 'projects/smalltalk' ) exists ifFalse:[
   307         (buildDirectory / 'stx' / 'projects/smalltalk' ) recursiveMakeDirectory.
   308     ].
   309 
   310     #( 
   311         'keyboard.rc' 
   312         'keyboardMacros.rc' 
   313         'display.rc' 
   314         'd_win32.rc'
   315         'host.rc' 
   316         'h_win32.rc'  
   317         'smalltalk.rc'  
   318         'private.rc'  
   319     ) do:[:fn |
   320         (myTopDirectory / 'stx' / 'projects/smalltalk' / fn)
   321             copyTo: (buildDirectory / 'stx' / 'projects/smalltalk' / fn)
   322     ].
   323 
   324     (myTopDirectory / 'stx' / 'doc/online/english/LICENCE_STX.html')
   325             copyTo: (buildDirectory / 'stx' / 'projects/smalltalk' / 'LICENCE_STX.html').
   326 !
   327 
   328 copySupportFilesForLinkage
   329     |files|
   330 
   331     OperatingSystem isMSWINDOWSlike ifTrue:[
   332         files := #( 
   333                     'support/win32/borland/cs3245.dll' 
   334                     'support/win32/X11.dll'
   335                     'support/win32/Xext.dll'
   336                     'librun/librun.dll'
   337                     'libbc/librun.lib'
   338                     'libbc/cs32i.lib'
   339                     'librun/genDate.exe'
   340                     'librun/main.c'
   341                     'projects/smalltalk/stx_16x16.ico'
   342                     'projects/smalltalk/stx_32x32.ico'
   343                     'projects/smalltalk/stx_splash.bmp'
   344                  ).
   345     ] ifFalse:[
   346         files := #(
   347                     'librun/genDate'
   348                     'librun/main.c'
   349                     'librun/librun.so'
   350                 )
   351     ].
   352     files := files asOrderedCollection.
   353 
   354     OperatingSystem isMSWINDOWSlike ifTrue:[
   355         projectDefinitionClass applicationIconFileName notNil ifTrue:[
   356             files add:('projects/smalltalk/',projectDefinitionClass applicationIconFileName,'.ico')
   357         ].
   358         projectDefinitionClass splashFileName notNil ifTrue:[
   359             files add:('projects/smalltalk/',projectDefinitionClass splashFileName,'.bmp')
   360         ].
   361     ].
   362 
   363     files do:[:dllRelativePath |
   364         ((buildDirectory / 'stx' / dllRelativePath) exists
   365         and:[ (mySTXTopDirectory / dllRelativePath) fileSize = (buildDirectory / 'stx' / dllRelativePath) fileSize
   366         and:[ (mySTXTopDirectory / dllRelativePath) modificationTime < (buildDirectory / 'stx' / dllRelativePath) modificationTime
   367         "/ and:[ (mySTXTopDirectory / dllRelativePath) sameContentsAs:(targetBuildDir / dllRelativePath) ]
   368         ]]) ifFalse:[
   369             (buildDirectory / 'stx' / dllRelativePath) directory recursiveMakeDirectory.
   370             (mySTXTopDirectory / dllRelativePath) copyTo:(buildDirectory / 'stx' / dllRelativePath).    
   371         ]
   372     ].
   373 !
   374 
   375 createHeaderFileFor:aClass in:packageTargetDir
   376     |instVarList classInstVarList classVarList bindings superclassFilename
   377      template file newContents oldContents|
   378 
   379     instVarList := StringCollection new.
   380     aClass instVarNames do:[:v |
   381         instVarList add:('OBJ %1;' bindWith:v)
   382     ].
   383     classInstVarList := StringCollection new.
   384     aClass class instVarNames do:[:v |
   385 (v includes:$_) ifTrue:[self halt].
   386         classInstVarList add:('OBJ %1;' bindWith:v)
   387     ].
   388     classVarList := StringCollection new.
   389     aClass classVarNames do:[:v |
   390         classVarList add:('extern OBJ %1_%2;' bindWith:aClass name with:v)
   391     ].
   392 
   393     bindings := Dictionary new.
   394     bindings at:'ClassName' put:aClass name. 
   395     aClass superclass isNil ifTrue:[
   396         bindings at:'SuperclassName' put:'-'. 
   397         bindings at:'SuperclassFileInclude' put:nil.
   398     ] ifFalse:[
   399         bindings at:'SuperclassName' put:aClass superclass name. 
   400         bindings at:'SuperclassFileName' put:(superclassFilename := Smalltalk fileNameForClass:aClass superclass).
   401         bindings at:'SuperclassFileInclude' put:('#include "%1.STH"' bindWith:superclassFilename).
   402     ].
   403     bindings at:'InstVarList' put:instVarList asString. 
   404     bindings at:'ClassVarList' put:classVarList asString. 
   405     bindings at:'ClassInstVarList' put:classInstVarList asString. 
   406 
   407     template := 
   408 '/* This file was generated by ProjectBuilder. */
   409 /* !!!!!!!! Do not change by hand !!!!!!!! */
   410 
   411 /* Class: %(ClassName) */
   412 /* Superclass: %(SuperclassName) */
   413 
   414 %(SuperclassFileInclude)
   415 
   416 /* INDIRECTGLOBALS */
   417 #ifdef _HEADER_INST_
   418 %(InstVarList)
   419 #endif /* _HEADER_INST_ */
   420 
   421 #ifdef _HEADER_CLASS_
   422 %(ClassVarList)
   423 #endif /* _HEADER_CLASS_ */
   424 
   425 #ifdef _HEADER_CLASSINST_
   426 %(ClassInstVarList)
   427 #endif /* _HEADER_CLASSINST_ */
   428 '.
   429     newContents := template bindWithArguments:bindings.
   430     file := packageTargetDir asFilename / ((Smalltalk fileNameForClass:aClass),'.STH').
   431     (file exists not
   432     or:[ (oldContents := file contents) ~= newContents ]) ifTrue:[
   433         file contents: newContents.
   434     ].
   435 !
   436 
   437 generateSourceFiles
   438     sourceCodeManager notNil ifTrue:[
   439         "/ check out / generate files there
   440         self generateSourceFilesByCheckingOutUsing:sourceCodeManager
   441     ] ifFalse:[
   442         "/ local build
   443         "/ fileout the project
   444         self generateSourceFilesByFilingOut
   445     ]
   446 !
   447 
   448 generateSourceFilesByCheckingOutUsing:aSourceCodeManager
   449     "/ will no longer be needed/supported
   450 
   451     |repository stxRepository module directory|
   452 
   453 self halt.
   454     "/ check out / generate files there
   455     repository := (aSourceCodeManager repositoryNameForModule:module) ifNil:[aSourceCodeManager repositoryName].
   456     stxRepository := aSourceCodeManager repositoryName.
   457 
   458     (buildDirectory construct:'stx') exists ifFalse:[
   459         (module ~= 'stx') ifTrue:[
   460             OperatingSystem
   461                 executeCommand:('cvs -d ',stxRepository,' co stx')
   462                 inputFrom:nil
   463                 outputTo:Transcript
   464                 errorTo:Transcript
   465                 inDirectory:buildDirectory
   466                 onError:[:status| self error:'cvs update stx failed'].
   467         ].
   468     ].
   469 
   470     ((buildDirectory construct:module) construct:'CVS') exists ifFalse:[
   471         OperatingSystem
   472             executeCommand:('cvs -d ',repository,' co -l ',directory)
   473             inputFrom:nil
   474             outputTo:Transcript
   475             errorTo:Transcript
   476             inDirectory:buildDirectory
   477             onError:[:status| self error:'cvs update failed'].
   478     ].
   479     OperatingSystem
   480         executeCommand:'cvs upd -d'
   481         inputFrom:nil
   482         outputTo:Transcript
   483         errorTo:Transcript
   484         inDirectory:(buildDirectory construct:module)
   485         onError:[:status| self error:'cvs update failed'].
   486 self halt.
   487 !
   488 
   489 generateSourceFilesByFilingOut
   490     "/ local build
   491     "/ fileout the project
   492 
   493     (package module ~= 'stx') ifTrue:[
   494         (buildDirectory / package module) makeDirectory.
   495     ].
   496 
   497     "/ file out the package(s) which are to be built
   498     ((Array with:package))
   499     do:[:eachPackageToFileout |
   500         |packageId packageModule packageDirectory packageTargetDir packageDef|
   501 
   502         packageId := eachPackageToFileout asPackageId.
   503         packageModule := packageId module.
   504         packageDirectory := packageId directory.
   505         packageTargetDir := (buildDirectory / packageModule / packageDirectory) recursiveMakeDirectory.
   506 
   507         packageDef := packageId projectDefinitionClass.
   508         (packageDef compiled_classNames_common ,
   509         packageDef compiled_classNamesForPlatform) do:[:eachClassName |
   510             |cls fileName newSource|
   511 
   512             cls := Smalltalk classNamed:eachClassName.
   513             self assert:cls isLoaded.
   514             fileName := (Smalltalk fileNameForClass:cls),'.st'.
   515             fileName := packageTargetDir asFilename construct:fileName.
   516             fileName exists ifTrue:[
   517                 newSource := String streamContents:[:s | cls fileOutOn:s withTimeStamp:false].
   518                 newSource = fileName contentsAsString ifFalse:[
   519                     fileName contents:newSource
   520                 ].
   521             ] ifFalse:[
   522                 cls fileOutIn:packageTargetDir withTimeStamp:false
   523             ].
   524         ].
   525 
   526 "/        (Smalltalk allClassesInPackage:eachPackageToFileout) do:[:cls |
   527 "/            cls isPrivate ifFalse:[
   528 "/                cls isLoaded ifFalse:[
   529 "/                    self halt.
   530 "/                    cls autoload.
   531 "/                ].
   532 "/                cls fileOutIn:packageTargetDir
   533 "/            ]
   534 "/        ].
   535 
   536         projectDefinitionClass forEachFileNameAndGeneratedContentsDo:[:fileName :fileContents |
   537             ((packageTargetDir / fileName) exists
   538             and:[ (packageTargetDir / fileName) contents = fileContents ]) ifFalse:[
   539                 (packageTargetDir / fileName) contents:fileContents.
   540             ].
   541         ].    
   542     ].
   543 
   544     "/ generate header files in prerequisite packages...
   545     (projectDefinitionClass allPreRequisites)
   546     do:[:eachPackageToFileout |
   547         |packageId packageDef packageModule packageDirectory packageTargetDir|
   548 
   549         packageId := eachPackageToFileout asPackageId.
   550         packageModule := packageId module.
   551         packageDirectory := packageId directory.
   552         packageTargetDir := (buildDirectory / packageModule / packageDirectory) recursiveMakeDirectory.
   553 
   554         packageDef := packageId projectDefinitionClass.
   555         (packageDef compiled_classNames_common ,
   556         packageDef compiled_classNamesForPlatform) do:[:eachClassName |
   557             |cls|
   558 
   559             cls := Smalltalk classNamed:eachClassName.
   560             "/ self assert:cls isLoaded.
   561             cls isLoaded ifTrue:[    
   562                 self createHeaderFileFor:cls in:packageTargetDir
   563             ].
   564         ].
   565         self copyResourcesForPackage:eachPackageToFileout.
   566     ].
   567 
   568 "/    stx_libbasic2 preRequisitesForBuilding#(#'stx:libbasic')
   569 !
   570 
   571 makeWithOutputTo:stdOut errorTo:stdErr
   572     |module directory compilerFlag makeCommand|
   573 
   574     module := package module.
   575     directory := package directory.
   576 
   577     makeCommand := ParserFlags makeCommand.
   578     usedCompiler = 'vc' ifTrue:[ makeCommand := 'vcmake'. compilerFlag := 'USEVC=1' ].
   579     usedCompiler = 'lcc' ifTrue:[ makeCommand := 'lcmake'. compilerFlag := 'USELCC=1' ].
   580     usedCompiler = 'gcc' ifTrue:[ makeCommand := 'make'. ].
   581 
   582     projectDefinitionClass isLibraryDefinition ifTrue:[
   583         OperatingSystem
   584             executeCommand:(makeCommand,' classLibRule')
   585             inputFrom:nil
   586             outputTo:stdOut
   587             errorTo:stdErr
   588             inDirectory:(buildDirectory / module / directory)
   589             onError:[:status| self error:'make failed'].
   590     ] ifFalse:[
   591         OperatingSystem
   592             executeCommand:(makeCommand,' exe')
   593             inputFrom:nil
   594             outputTo:stdOut
   595             errorTo:stdErr
   596             inDirectory:(buildDirectory / module / directory)
   597             onError:[:status| self error:'make failed'].
   598 
   599         (makeExeOnly ? false) ifFalse:[
   600             OperatingSystem
   601                 executeCommand:(makeCommand,' setup')
   602                 inputFrom:nil
   603                 outputTo:stdOut
   604                 errorTo:stdErr
   605                 inDirectory:(buildDirectory / module / directory)
   606                 onError:[:status| self error:'make failed'].
   607         ]
   608     ]
   609 !
   610 
   611 setupBuildDirectory
   612     buildDirectory exists ifFalse:[
   613         buildDirectory recursiveMakeDirectory.
   614     ].
   615     (buildDirectory / 'stx') exists ifFalse:[
   616         (buildDirectory / 'stx') makeDirectory.
   617     ].
   618 
   619     self copyDirectoryForBuild:'include'.
   620     self copyDirectoryForBuild:'rules'.
   621 !
   622 
   623 validateBuildDirectoryIsPresent
   624 
   625     ^ self.
   626 
   627 "/    [
   628 "/        |default directoryIsOKForMe stc |
   629 "/
   630 "/        default := (buildDirectory ?
   631 "/                          PreviousBuildDirectory)
   632 "/                          ifNil:[ UserPreferences current buildDirectory].
   633 "/
   634 "/        buildDirectory := Dialog requestDirectoryName:'Temporary Work-ROOT for build:'
   635 "/                                 default:default.
   636 "/
   637 "/        buildDirectory isEmptyOrNil ifTrue:[^ self].
   638 "/        buildDirectory := buildDirectory asFilename.
   639 "/        directoryIsOKForMe := true.
   640 "/
   641 "/        buildDirectory exists ifFalse:[
   642 "/            Dialog warn:(self classResources string:'Work directory %1 does not exist.' with:buildDirectory).
   643 "/            directoryIsOKForMe := false.
   644 "/        ] ifTrue:[
   645 "/            (buildDirectory construct:'stx') exists ifFalse:[
   646 "/                Dialog warn:(self classResources stringWithCRs:'Work directory must contain an stx subDirectory,\which contains (at least) the stc and include subdirectories.').
   647 "/                directoryIsOKForMe := false.
   648 "/            ] ifTrue:[
   649 "/                stc := (OperatingSystem isMSDOSlike) ifTrue:['stc.exe'] ifFalse:['stc'].
   650 "/                (((buildDirectory construct:'stx')construct:'stc')construct:stc) exists ifFalse:[
   651 "/                    Dialog warn:(self classResources stringWithCRs:'Work directory must contain an stc compiler in the stx/stc subDirectory.').
   652 "/                    directoryIsOKForMe := false.
   653 "/                ].
   654 "/                ((buildDirectory construct:'stx')construct:'include') exists ifFalse:[
   655 "/                    Dialog warn:(self classResources stringWithCRs:'Work directory must have had a make run before (for include files to exists).').
   656 "/                    directoryIsOKForMe := false.
   657 "/                ].
   658 "/            ]
   659 "/        ].
   660 "/        directoryIsOKForMe
   661 "/    ] whileFalse
   662 ! !
   663 
   664 !ProjectBuilder class methodsFor:'documentation'!
   665 
   666 version_CVS
   667     ^ '$Header$'
   668 ! !