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