ProjectBuilder.st
author sr
Fri, 23 Oct 2009 15:38:38 +0200
changeset 2683 ff39502be3a2
parent 2680 3f2dbbd7743f
child 2684 80fe0f753fd8
permissions -rw-r--r--
some tries for UNIX - unfinished
     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         ((buildDirectory / 'stx' / dllRelativePath) exists
   373         and:[ (mySTXTopDirectory / dllRelativePath) fileSize = (buildDirectory / 'stx' / dllRelativePath) fileSize
   374         and:[ (mySTXTopDirectory / dllRelativePath) modificationTime < (buildDirectory / 'stx' / dllRelativePath) modificationTime
   375         "/ and:[ (mySTXTopDirectory / dllRelativePath) sameContentsAs:(targetBuildDir / dllRelativePath) ]
   376         ]]) ifFalse:[
   377             (buildDirectory / 'stx' / dllRelativePath) directory recursiveMakeDirectory.
   378             (mySTXTopDirectory / dllRelativePath) copyTo:(buildDirectory / 'stx' / dllRelativePath).    
   379         ]
   380     ].
   381 !
   382 
   383 createHeaderFileFor:aClass in:packageTargetDir
   384     |instVarList classInstVarList classVarList bindings superclassFilename
   385      template file newContents oldContents|
   386 
   387     instVarList := StringCollection new.
   388     aClass instVarNames do:[:v |
   389         instVarList add:('OBJ %1;' bindWith:v)
   390     ].
   391     classInstVarList := StringCollection new.
   392     aClass class instVarNames do:[:v |
   393 (v includes:$_) ifTrue:[self halt].
   394         classInstVarList add:('OBJ %1;' bindWith:v)
   395     ].
   396     classVarList := StringCollection new.
   397     aClass classVarNames do:[:v |
   398         classVarList add:('extern OBJ %1_%2;' bindWith:aClass name with:v)
   399     ].
   400 
   401     bindings := Dictionary new.
   402     bindings at:'ClassName' put:aClass name. 
   403     aClass superclass isNil ifTrue:[
   404         bindings at:'SuperclassName' put:'-'. 
   405         bindings at:'SuperclassFileInclude' put:nil.
   406     ] ifFalse:[
   407         bindings at:'SuperclassName' put:aClass superclass name. 
   408         bindings at:'SuperclassFileName' put:(superclassFilename := Smalltalk fileNameForClass:aClass superclass).
   409         bindings at:'SuperclassFileInclude' put:('#include "%1.STH"' bindWith:superclassFilename).
   410     ].
   411     bindings at:'InstVarList' put:instVarList asString. 
   412     bindings at:'ClassVarList' put:classVarList asString. 
   413     bindings at:'ClassInstVarList' put:classInstVarList asString. 
   414 
   415     template := 
   416 '/* This file was generated by ProjectBuilder. */
   417 /* !!!!!!!! Do not change by hand !!!!!!!! */
   418 
   419 /* Class: %(ClassName) */
   420 /* Superclass: %(SuperclassName) */
   421 
   422 %(SuperclassFileInclude)
   423 
   424 /* INDIRECTGLOBALS */
   425 #ifdef _HEADER_INST_
   426 %(InstVarList)
   427 #endif /* _HEADER_INST_ */
   428 
   429 #ifdef _HEADER_CLASS_
   430 %(ClassVarList)
   431 #endif /* _HEADER_CLASS_ */
   432 
   433 #ifdef _HEADER_CLASSINST_
   434 %(ClassInstVarList)
   435 #endif /* _HEADER_CLASSINST_ */
   436 '.
   437     newContents := template bindWithArguments:bindings.
   438     file := packageTargetDir asFilename / ((Smalltalk fileNameForClass:aClass),(self suffixForHeaderFiles)).
   439     (file exists not
   440     or:[ (oldContents := file contents) ~= newContents ]) ifTrue:[
   441         file contents: newContents.
   442     ].
   443 !
   444 
   445 generateSourceFiles
   446     sourceCodeManager notNil ifTrue:[
   447         "/ check out / generate files there
   448         self generateSourceFilesByCheckingOutUsing:sourceCodeManager
   449     ] ifFalse:[
   450         "/ local build
   451         "/ fileout the project
   452         self generateSourceFilesByFilingOut
   453     ]
   454 !
   455 
   456 generateSourceFilesByCheckingOutUsing:aSourceCodeManager
   457     "/ will no longer be needed/supported
   458 
   459     |repository stxRepository module directory|
   460 
   461 self halt.
   462     "/ check out / generate files there
   463     repository := (aSourceCodeManager repositoryNameForModule:module) ifNil:[aSourceCodeManager repositoryName].
   464     stxRepository := aSourceCodeManager repositoryName.
   465 
   466     (buildDirectory construct:'stx') exists ifFalse:[
   467         (module ~= 'stx') ifTrue:[
   468             OperatingSystem
   469                 executeCommand:('cvs -d ',stxRepository,' co stx')
   470                 inputFrom:nil
   471                 outputTo:Transcript
   472                 errorTo:Transcript
   473                 inDirectory:buildDirectory
   474                 onError:[:status| self error:'cvs update stx failed'].
   475         ].
   476     ].
   477 
   478     ((buildDirectory construct:module) construct:'CVS') exists ifFalse:[
   479         OperatingSystem
   480             executeCommand:('cvs -d ',repository,' co -l ',directory)
   481             inputFrom:nil
   482             outputTo:Transcript
   483             errorTo:Transcript
   484             inDirectory:buildDirectory
   485             onError:[:status| self error:'cvs update failed'].
   486     ].
   487     OperatingSystem
   488         executeCommand:'cvs upd -d'
   489         inputFrom:nil
   490         outputTo:Transcript
   491         errorTo:Transcript
   492         inDirectory:(buildDirectory construct:module)
   493         onError:[:status| self error:'cvs update failed'].
   494 self halt.
   495 !
   496 
   497 generateSourceFilesByFilingOut
   498     "/ local build
   499     "/ fileout the project
   500 
   501     (package module ~= 'stx') ifTrue:[
   502         (buildDirectory / package module) makeDirectory.
   503     ].
   504 
   505     "/ file out the package(s) which are to be built
   506     ((Array with:package))
   507     do:[:eachPackageToFileout |
   508         |packageId packageModule packageDirectory packageTargetDir packageDef|
   509 
   510         packageId := eachPackageToFileout asPackageId.
   511         packageModule := packageId module.
   512         packageDirectory := packageId directory.
   513         packageTargetDir := (buildDirectory / packageModule / packageDirectory) recursiveMakeDirectory.
   514 
   515         packageDef := packageId projectDefinitionClass.
   516         (packageDef compiled_classNames_common ,
   517         packageDef compiled_classNamesForPlatform) do:[:eachClassName |
   518             |cls fileName newSource|
   519 
   520             cls := Smalltalk classNamed:eachClassName.
   521             self assert:cls isLoaded.
   522             fileName := (Smalltalk fileNameForClass:cls),'.st'.
   523             fileName := packageTargetDir asFilename construct:fileName.
   524             fileName exists ifTrue:[
   525                 newSource := String streamContents:[:s | cls fileOutOn:s withTimeStamp:false].
   526                 newSource = fileName contentsAsString ifFalse:[
   527                     fileName contents:newSource
   528                 ].
   529             ] ifFalse:[
   530                 cls fileOutIn:packageTargetDir withTimeStamp:false
   531             ].
   532         ].
   533 
   534 "/        (Smalltalk allClassesInPackage:eachPackageToFileout) do:[:cls |
   535 "/            cls isPrivate ifFalse:[
   536 "/                cls isLoaded ifFalse:[
   537 "/                    self halt.
   538 "/                    cls autoload.
   539 "/                ].
   540 "/                cls fileOutIn:packageTargetDir
   541 "/            ]
   542 "/        ].
   543 
   544         projectDefinitionClass forEachFileNameAndGeneratedContentsDo:[:fileName :fileContents |
   545             ((packageTargetDir / fileName) exists
   546             and:[ (packageTargetDir / fileName) contents = fileContents ]) ifFalse:[
   547                 (packageTargetDir / fileName) contents:fileContents.
   548             ].
   549         ].    
   550     ].
   551 
   552     "/ generate header files in prerequisite packages...
   553     (projectDefinitionClass allPreRequisites)
   554     do:[:eachPackageToFileout |
   555         |packageId packageDef packageModule packageDirectory packageTargetDir|
   556 
   557         packageId := eachPackageToFileout asPackageId.
   558         packageModule := packageId module.
   559         packageDirectory := packageId directory.
   560         packageTargetDir := (buildDirectory / packageModule / packageDirectory) recursiveMakeDirectory.
   561 
   562         packageDef := packageId projectDefinitionClass.
   563         (packageDef compiled_classNames_common ,
   564         packageDef compiled_classNamesForPlatform) do:[:eachClassName |
   565             |cls|
   566 
   567             cls := Smalltalk classNamed:eachClassName.
   568             "/ self assert:cls isLoaded.
   569             cls isLoaded ifTrue:[    
   570                 self createHeaderFileFor:cls in:packageTargetDir
   571             ].
   572         ].
   573         self copyResourcesForPackage:eachPackageToFileout.
   574     ].
   575 
   576 "/    stx_libbasic2 preRequisitesForBuilding#(#'stx:libbasic')
   577 !
   578 
   579 makeWithOutputTo:stdOut errorTo:stdErr
   580     |module directory compilerFlag makeCommand|
   581 
   582     module := package module.
   583     directory := package directory.
   584 
   585     makeCommand := ParserFlags makeCommand.
   586     usedCompiler = 'vc' ifTrue:[ makeCommand := 'vcmake'. compilerFlag := 'USEVC=1' ].
   587     usedCompiler = 'lcc' ifTrue:[ makeCommand := 'lcmake'. compilerFlag := 'USELCC=1' ].
   588     usedCompiler = 'gcc' ifTrue:[ makeCommand := 'make'. ].
   589 
   590     OperatingSystem isUNIXlike ifTrue:[
   591         OperatingSystem
   592             executeCommand:'sh ../../stx/rules/stmkmf'
   593             inputFrom:nil
   594             outputTo:stdOut
   595             errorTo:stdErr
   596             inDirectory:(buildDirectory / module / directory)
   597             onError:[:status| self error:'make failed'].
   598     ].
   599 
   600     projectDefinitionClass isLibraryDefinition ifTrue:[
   601         OperatingSystem
   602             executeCommand:(makeCommand,' classLibRule')
   603             inputFrom:nil
   604             outputTo:stdOut
   605             errorTo:stdErr
   606             inDirectory:(buildDirectory / module / directory)
   607             onError:[:status| self error:'make failed'].
   608     ] ifFalse:[
   609         OperatingSystem
   610             executeCommand:(makeCommand,' exe')
   611             inputFrom:nil
   612             outputTo:stdOut
   613             errorTo:stdErr
   614             inDirectory:(buildDirectory / module / directory)
   615             onError:[:status| self error:'make failed'].
   616 
   617         (makeExeOnly ? false) ifFalse:[
   618             OperatingSystem
   619                 executeCommand:(makeCommand,' setup')
   620                 inputFrom:nil
   621                 outputTo:stdOut
   622                 errorTo:stdErr
   623                 inDirectory:(buildDirectory / module / directory)
   624                 onError:[:status| self error:'make failed'].
   625         ]
   626     ]
   627 !
   628 
   629 recursiveCopyDirectoryForBuild:subdir
   630     |targetDir|
   631 
   632     targetDir := buildDirectory / 'stx' / subdir.
   633     targetDir exists ifFalse:[
   634         targetDir makeDirectory.
   635     ].
   636     (mySTXTopDirectory / subdir) directoryContentsAsFilenamesDo:[:eachFile |
   637         eachFile recursiveCopyTo:(targetDir construct:eachFile baseName)
   638     ].
   639     self activityNotification:nil
   640 !
   641 
   642 setupBuildDirectory
   643     buildDirectory exists ifFalse:[
   644         buildDirectory recursiveMakeDirectory.
   645     ].
   646     (buildDirectory / 'stx') exists ifFalse:[
   647         (buildDirectory / 'stx') makeDirectory.
   648     ].
   649 
   650     self copyDirectoryForBuild:'include'.
   651     self copyDirectoryForBuild:'rules'.
   652     OperatingSystem isUNIXlike ifTrue:[
   653         self recursiveCopyDirectoryForBuild:'configurations'.
   654     ]
   655 !
   656 
   657 validateBuildDirectoryIsPresent
   658 
   659     ^ self.
   660 
   661 "/    [
   662 "/        |default directoryIsOKForMe stc |
   663 "/
   664 "/        default := (buildDirectory ?
   665 "/                          PreviousBuildDirectory)
   666 "/                          ifNil:[ UserPreferences current buildDirectory].
   667 "/
   668 "/        buildDirectory := Dialog requestDirectoryName:'Temporary Work-ROOT for build:'
   669 "/                                 default:default.
   670 "/
   671 "/        buildDirectory isEmptyOrNil ifTrue:[^ self].
   672 "/        buildDirectory := buildDirectory asFilename.
   673 "/        directoryIsOKForMe := true.
   674 "/
   675 "/        buildDirectory exists ifFalse:[
   676 "/            Dialog warn:(self classResources string:'Work directory %1 does not exist.' with:buildDirectory).
   677 "/            directoryIsOKForMe := false.
   678 "/        ] ifTrue:[
   679 "/            (buildDirectory construct:'stx') exists ifFalse:[
   680 "/                Dialog warn:(self classResources stringWithCRs:'Work directory must contain an stx subDirectory,\which contains (at least) the stc and include subdirectories.').
   681 "/                directoryIsOKForMe := false.
   682 "/            ] ifTrue:[
   683 "/                stc := (OperatingSystem isMSDOSlike) ifTrue:['stc.exe'] ifFalse:['stc'].
   684 "/                (((buildDirectory construct:'stx')construct:'stc')construct:stc) exists ifFalse:[
   685 "/                    Dialog warn:(self classResources stringWithCRs:'Work directory must contain an stc compiler in the stx/stc subDirectory.').
   686 "/                    directoryIsOKForMe := false.
   687 "/                ].
   688 "/                ((buildDirectory construct:'stx')construct:'include') exists ifFalse:[
   689 "/                    Dialog warn:(self classResources stringWithCRs:'Work directory must have had a make run before (for include files to exists).').
   690 "/                    directoryIsOKForMe := false.
   691 "/                ].
   692 "/            ]
   693 "/        ].
   694 "/        directoryIsOKForMe
   695 "/    ] whileFalse
   696 ! !
   697 
   698 !ProjectBuilder class methodsFor:'documentation'!
   699 
   700 version_CVS
   701     ^ '$Header$'
   702 ! !