ProjectBuilder.st
author Stefan Vogel <sv@exept.de>
Sun, 15 Nov 2009 23:19:23 +0100
changeset 2723 d03a850ebc29
parent 2684 80fe0f753fd8
child 2741 783dda495655
permissions -rw-r--r--
changed: #copyDLLsForLinkage
need some implicitely linked DLL for linux
     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 preRequisites dllRelativePaths|
   203 
   204 
   205     targetBuildDir := buildDirectory / package module / package directory.
   206 
   207     preRequisites := projectDefinitionClass allPreRequisites.
   208     OperatingSystem isUNIXlike ifTrue:[
   209         "For now: unix Makefiles require some libs implicitely..."
   210         preRequisites := preRequisites union:#(
   211                                'stx:goodies/refactoryBrowser/parser'
   212                                'stx:libtool'
   213                             ).
   214     ].
   215 
   216     preRequisites do:[:eachPackageToFileout |
   217         |packageId packageDef packageModule packageDirectory packageTargetDir
   218          dllSource dllSourceDir libraryName dllRelativePath|
   219 
   220         packageId := eachPackageToFileout asPackageId.
   221         packageModule := packageId module.
   222         packageDirectory := packageId directory.
   223         packageTargetDir := (buildDirectory / packageModule / packageDirectory) recursiveMakeDirectory.
   224 
   225         packageDef := packageId projectDefinitionClass.
   226         libraryName := packageDef libraryName.
   227 
   228         "/ mhmh - take them from my tree or from the projects/smalltalk execution directory ??
   229         dllSourceDir := myTopDirectory / packageModule / packageDirectory.
   230         OperatingSystem isMSWINDOWSlike ifTrue:[
   231 "/            dllRelativePath := 'objvc','/',(libraryName,'.dll').
   232 "/            (dllSourceDir / dllRelativePath) exists 
   233             dllRelativePaths := Array with:('objbc\', libraryName, '.dll').
   234         ] ifFalse:[
   235             dllRelativePaths := Array with:(libraryName,'.so').
   236             (packageModule = 'stx' and:[packageDirectory = 'libview']) ifTrue:[
   237                 dllRelativePaths := dllRelativePaths, #('XWorkstation.so' 'GLXWorkstation.so').
   238             ].
   239         ].
   240         dllRelativePaths do:[:dllRelativePath|
   241             ((packageTargetDir / dllRelativePath) exists not
   242              or:[(dllSourceDir / dllRelativePath) fileSize ~= (packageTargetDir / dllRelativePath) fileSize
   243              or:[(dllSourceDir / dllRelativePath) modificationTime >= (packageTargetDir / dllRelativePath) modificationTime
   244              "/ or:[ ((dllSourceDir / dllRelativePath) sameContentsAs:(packageTargetDir / dllRelativePath)) not ]
   245             ]]) ifTrue:[
   246                 (packageTargetDir / dllRelativePath) directory recursiveMakeDirectory.
   247                 (dllSourceDir / dllRelativePath) copyTo:(packageTargetDir / dllRelativePath).    
   248             ].
   249         ].
   250     ].
   251 !
   252 
   253 copyDirectory:relativepath
   254     "/ need rules in stx
   255     ((Smalltalk projectDirectoryForPackage:'stx') asFilename construct:relativepath)
   256         recursiveCopyTo:(buildDirectory construct:'stx').
   257 !
   258 
   259 copyDirectoryForBuild:subdir
   260     |targetDir targetFile|
   261 
   262     targetDir := buildDirectory / 'stx' / subdir.
   263     targetDir exists ifFalse:[
   264         targetDir makeDirectory.
   265     ].
   266     (mySTXTopDirectory / subdir) directoryContentsAsFilenamesDo:[:eachFile |
   267         eachFile isDirectory ifFalse:[
   268             targetFile := targetDir / eachFile baseName.
   269             (targetFile exists not
   270             or:[ targetFile modificationTime < eachFile modificationTime ]) ifTrue:[
   271                 self activityNotification:'copying ',eachFile pathName,'...'.
   272                 eachFile copyTo:(targetDir construct:eachFile baseName)
   273             ]
   274         ].
   275     ].
   276     self activityNotification:nil
   277 !
   278 
   279 copyResourcesForPackage:aPackage
   280     |module directory|
   281 
   282     module := aPackage asPackageId module.
   283     directory := aPackage asPackageId directory.
   284 
   285     (myTopDirectory / module / directory / 'resources' ) exists ifTrue:[
   286         (myTopDirectory / module / directory / 'resources' )
   287             recursiveCopyTo:(buildDirectory / module / directory)
   288     ].
   289     (myTopDirectory / module / directory / 'styles' ) exists ifTrue:[
   290         (myTopDirectory / module / directory / 'styles' )
   291             recursiveCopyTo:(buildDirectory / module / directory)
   292     ].
   293 !
   294 
   295 copySTCDirectoryForBuild
   296     |targetDir stc files|
   297 
   298     targetDir := buildDirectory / 'stx' / 'stc'.
   299     targetDir exists ifFalse:[ targetDir makeDirectory ].
   300 
   301     stc := OperatingSystem isMSWINDOWSlike 
   302                 ifTrue:[ 'stc.exe' ]
   303                 ifFalse:[ 'stc' ].
   304 
   305     files := #( ) copyWith:stc.
   306 
   307     files do:[:eachFile |
   308         |sourceFile targetFile|
   309 
   310         sourceFile := mySTXTopDirectory / 'stc' / eachFile.
   311         targetFile := targetDir / eachFile.
   312         (targetFile exists not
   313         or:[ targetFile modificationTime < sourceFile modificationTime ]) ifTrue:[
   314             self activityNotification:'copying ',sourceFile pathName,'...'.
   315             sourceFile copyTo:targetFile
   316         ].
   317     ].
   318 
   319     OperatingSystem isUNIXlike ifTrue:[
   320         (targetDir / 'stc') makeExecutableForAll    
   321     ].
   322 
   323     self activityNotification:nil
   324 !
   325 
   326 copyStartupFilesFromSmalltalk
   327     (buildDirectory / 'stx' / 'projects/smalltalk' ) exists ifFalse:[
   328         (buildDirectory / 'stx' / 'projects/smalltalk' ) recursiveMakeDirectory.
   329     ].
   330 
   331     #( 
   332         'keyboard.rc' 
   333         'keyboardMacros.rc' 
   334         'display.rc' 
   335         'd_win32.rc'
   336         'host.rc' 
   337         'h_win32.rc'  
   338         'smalltalk.rc'  
   339         'private.rc'  
   340     ) do:[:fn |
   341         (myTopDirectory / 'stx' / 'projects/smalltalk' / fn)
   342             copyTo: (buildDirectory / 'stx' / 'projects/smalltalk' / fn)
   343     ].
   344 
   345     (myTopDirectory / 'stx' / 'doc/online/english/LICENCE_STX.html')
   346             copyTo: (buildDirectory / 'stx' / 'projects/smalltalk' / 'LICENCE_STX.html').
   347 !
   348 
   349 copySupportFilesForLinkage
   350     |files|
   351 
   352     OperatingSystem isMSWINDOWSlike ifTrue:[
   353         files := #( 
   354                     'support/win32/borland/cs3245.dll' 
   355                     'support/win32/X11.dll'
   356                     'support/win32/Xext.dll'
   357                     'librun/librun.dll'
   358                     'libbc/librun.lib'
   359                     'libbc/cs32i.lib'
   360                     'librun/genDate.exe'
   361                     'librun/main.c'
   362                     'projects/smalltalk/stx_16x16.ico'
   363                     'projects/smalltalk/stx_32x32.ico'
   364                     'projects/smalltalk/stx_splash.bmp'
   365                  ).
   366     ] ifFalse:[
   367         files := #(
   368                     'librun/main.c'
   369                     'librun/librun.so'
   370                 )
   371     ].
   372     files := files asOrderedCollection.
   373 
   374     OperatingSystem isMSWINDOWSlike ifTrue:[
   375         projectDefinitionClass applicationIconFileName notNil ifTrue:[
   376             files add:('projects/smalltalk/',projectDefinitionClass applicationIconFileName,'.ico')
   377         ].
   378         projectDefinitionClass splashFileName notNil ifTrue:[
   379             files add:('projects/smalltalk/',projectDefinitionClass splashFileName,'.bmp')
   380         ].
   381     ].
   382 
   383     files do:[:dllRelativePath |
   384         (mySTXTopDirectory / dllRelativePath) exists ifTrue:[
   385             ((buildDirectory / 'stx' / dllRelativePath) exists
   386             and:[ (mySTXTopDirectory / dllRelativePath) fileSize = (buildDirectory / 'stx' / dllRelativePath) fileSize
   387             and:[ (mySTXTopDirectory / dllRelativePath) modificationTime < (buildDirectory / 'stx' / dllRelativePath) modificationTime
   388             "/ and:[ (mySTXTopDirectory / dllRelativePath) sameContentsAs:(targetBuildDir / dllRelativePath) ]
   389             ]]) ifFalse:[
   390                 (buildDirectory / 'stx' / dllRelativePath) directory recursiveMakeDirectory.
   391                 (mySTXTopDirectory / dllRelativePath) copyTo:(buildDirectory / 'stx' / dllRelativePath).    
   392             ]
   393         ] ifFalse:[
   394             self error:'Missing file: ',dllRelativePath printString mayProceed:true.
   395         ].
   396     ].
   397 !
   398 
   399 createHeaderFileFor:aClass in:packageTargetDir
   400     |instVarList classInstVarList classVarList bindings superclassFilename
   401      template file newContents oldContents|
   402 
   403     instVarList := StringCollection new.
   404     aClass instVarNames do:[:v |
   405         instVarList add:('OBJ %1;' bindWith:v)
   406     ].
   407     classInstVarList := StringCollection new.
   408     aClass class instVarNames do:[:v |
   409 (v includes:$_) ifTrue:[self halt].
   410         classInstVarList add:('OBJ %1;' bindWith:v)
   411     ].
   412     classVarList := StringCollection new.
   413     aClass classVarNames do:[:v |
   414         classVarList add:('extern OBJ %1_%2;' bindWith:aClass name with:v)
   415     ].
   416 
   417     bindings := Dictionary new.
   418     bindings at:'ClassName' put:aClass name. 
   419     aClass superclass isNil ifTrue:[
   420         bindings at:'SuperclassName' put:'-'. 
   421         bindings at:'SuperclassFileInclude' put:nil.
   422     ] ifFalse:[
   423         bindings at:'SuperclassName' put:aClass superclass name. 
   424         bindings at:'SuperclassFileName' put:(superclassFilename := Smalltalk fileNameForClass:aClass superclass).
   425         bindings at:'SuperclassFileInclude' put:('#include "%1.STH"' bindWith:superclassFilename).
   426     ].
   427     bindings at:'InstVarList' put:instVarList asString. 
   428     bindings at:'ClassVarList' put:classVarList asString. 
   429     bindings at:'ClassInstVarList' put:classInstVarList asString. 
   430 
   431     template := 
   432 '/* This file was generated by ProjectBuilder. */
   433 /* !!!!!!!! Do not change by hand !!!!!!!! */
   434 
   435 /* Class: %(ClassName) */
   436 /* Superclass: %(SuperclassName) */
   437 
   438 %(SuperclassFileInclude)
   439 
   440 /* INDIRECTGLOBALS */
   441 #ifdef _HEADER_INST_
   442 %(InstVarList)
   443 #endif /* _HEADER_INST_ */
   444 
   445 #ifdef _HEADER_CLASS_
   446 %(ClassVarList)
   447 #endif /* _HEADER_CLASS_ */
   448 
   449 #ifdef _HEADER_CLASSINST_
   450 %(ClassInstVarList)
   451 #endif /* _HEADER_CLASSINST_ */
   452 '.
   453     newContents := template bindWithArguments:bindings.
   454     file := packageTargetDir asFilename / ((Smalltalk fileNameForClass:aClass),(self suffixForHeaderFiles)).
   455     (file exists not
   456     or:[ (oldContents := file contents) ~= newContents ]) ifTrue:[
   457         file contents: newContents.
   458     ].
   459 !
   460 
   461 generateSourceFiles
   462     sourceCodeManager notNil ifTrue:[
   463         "/ check out / generate files there
   464         self generateSourceFilesByCheckingOutUsing:sourceCodeManager
   465     ] ifFalse:[
   466         "/ local build
   467         "/ fileout the project
   468         self generateSourceFilesByFilingOut
   469     ]
   470 !
   471 
   472 generateSourceFilesByCheckingOutUsing:aSourceCodeManager
   473     "/ will no longer be needed/supported
   474 
   475     |repository stxRepository module directory|
   476 
   477 self halt.
   478     "/ check out / generate files there
   479     repository := (aSourceCodeManager repositoryNameForModule:module) ifNil:[aSourceCodeManager repositoryName].
   480     stxRepository := aSourceCodeManager repositoryName.
   481 
   482     (buildDirectory construct:'stx') exists ifFalse:[
   483         (module ~= 'stx') ifTrue:[
   484             OperatingSystem
   485                 executeCommand:('cvs -d ',stxRepository,' co stx')
   486                 inputFrom:nil
   487                 outputTo:Transcript
   488                 errorTo:Transcript
   489                 inDirectory:buildDirectory
   490                 onError:[:status| self error:'cvs update stx failed'].
   491         ].
   492     ].
   493 
   494     ((buildDirectory construct:module) construct:'CVS') exists ifFalse:[
   495         OperatingSystem
   496             executeCommand:('cvs -d ',repository,' co -l ',directory)
   497             inputFrom:nil
   498             outputTo:Transcript
   499             errorTo:Transcript
   500             inDirectory:buildDirectory
   501             onError:[:status| self error:'cvs update failed'].
   502     ].
   503     OperatingSystem
   504         executeCommand:'cvs upd -d'
   505         inputFrom:nil
   506         outputTo:Transcript
   507         errorTo:Transcript
   508         inDirectory:(buildDirectory construct:module)
   509         onError:[:status| self error:'cvs update failed'].
   510 self halt.
   511 !
   512 
   513 generateSourceFilesByFilingOut
   514     "/ local build
   515     "/ fileout the project
   516 
   517     (package module ~= 'stx') ifTrue:[
   518         (buildDirectory / package module) makeDirectory.
   519     ].
   520 
   521     "/ file out the package(s) which are to be built
   522     ((Array with:package))
   523     do:[:eachPackageToFileout |
   524         |packageId packageModule packageDirectory packageTargetDir packageDef|
   525 
   526         packageId := eachPackageToFileout asPackageId.
   527         packageModule := packageId module.
   528         packageDirectory := packageId directory.
   529         packageTargetDir := (buildDirectory / packageModule / packageDirectory) recursiveMakeDirectory.
   530 
   531         packageDef := packageId projectDefinitionClass.
   532         (packageDef compiled_classNames_common ,
   533         packageDef compiled_classNamesForPlatform) do:[:eachClassName |
   534             |cls fileName newSource|
   535 
   536             cls := Smalltalk classNamed:eachClassName.
   537             self assert:cls isLoaded.
   538             fileName := (Smalltalk fileNameForClass:cls),'.st'.
   539             fileName := packageTargetDir asFilename construct:fileName.
   540             fileName exists ifTrue:[
   541                 newSource := String streamContents:[:s | cls fileOutOn:s withTimeStamp:false].
   542                 newSource = fileName contentsAsString ifFalse:[
   543                     fileName contents:newSource
   544                 ].
   545             ] ifFalse:[
   546                 cls fileOutIn:packageTargetDir withTimeStamp:false
   547             ].
   548         ].
   549 
   550 "/        (Smalltalk allClassesInPackage:eachPackageToFileout) do:[:cls |
   551 "/            cls isPrivate ifFalse:[
   552 "/                cls isLoaded ifFalse:[
   553 "/                    self halt.
   554 "/                    cls autoload.
   555 "/                ].
   556 "/                cls fileOutIn:packageTargetDir
   557 "/            ]
   558 "/        ].
   559 
   560         projectDefinitionClass forEachFileNameAndGeneratedContentsDo:[:fileName :fileContents |
   561             ((packageTargetDir / fileName) exists
   562             and:[ (packageTargetDir / fileName) contents = fileContents ]) ifFalse:[
   563                 (packageTargetDir / fileName) contents:fileContents.
   564             ].
   565         ].    
   566     ].
   567 
   568     "/ generate header files in prerequisite packages...
   569     (projectDefinitionClass allPreRequisites)
   570     do:[:eachPackageToFileout |
   571         |packageId packageDef packageModule packageDirectory packageTargetDir|
   572 
   573         packageId := eachPackageToFileout asPackageId.
   574         packageModule := packageId module.
   575         packageDirectory := packageId directory.
   576         packageTargetDir := (buildDirectory / packageModule / packageDirectory) recursiveMakeDirectory.
   577 
   578         packageDef := packageId projectDefinitionClass.
   579         (packageDef compiled_classNames_common ,
   580         packageDef compiled_classNamesForPlatform) do:[:eachClassName |
   581             |cls|
   582 
   583             cls := Smalltalk classNamed:eachClassName.
   584             "/ self assert:cls isLoaded.
   585             cls isLoaded ifTrue:[    
   586                 self createHeaderFileFor:cls in:packageTargetDir
   587             ].
   588         ].
   589         self copyResourcesForPackage:eachPackageToFileout.
   590     ].
   591 
   592 "/    stx_libbasic2 preRequisitesForBuilding#(#'stx:libbasic')
   593 !
   594 
   595 makeWithOutputTo:stdOut errorTo:stdErr
   596     |module directory compilerFlag makeCommand|
   597 
   598     module := package module.
   599     directory := package directory.
   600 
   601     makeCommand := ParserFlags makeCommand.
   602     usedCompiler = 'vc' ifTrue:[ makeCommand := 'vcmake'. compilerFlag := 'USEVC=1' ].
   603     usedCompiler = 'lcc' ifTrue:[ makeCommand := 'lcmake'. compilerFlag := 'USELCC=1' ].
   604     usedCompiler = 'gcc' ifTrue:[ makeCommand := 'make'. ].
   605 
   606     OperatingSystem isUNIXlike ifTrue:[
   607         OperatingSystem
   608             executeCommand:'sh ../../stx/rules/stmkmf'
   609             inputFrom:nil
   610             outputTo:stdOut
   611             errorTo:stdErr
   612             inDirectory:(buildDirectory / module / directory)
   613             onError:[:status| self error:'make failed'].
   614     ].
   615 
   616     projectDefinitionClass isLibraryDefinition ifTrue:[
   617         OperatingSystem
   618             executeCommand:(makeCommand,' classLibRule')
   619             inputFrom:nil
   620             outputTo:stdOut
   621             errorTo:stdErr
   622             inDirectory:(buildDirectory / module / directory)
   623             onError:[:status| self error:'make failed'].
   624     ] ifFalse:[
   625         OperatingSystem
   626             executeCommand:(makeCommand,' exe')
   627             inputFrom:nil
   628             outputTo:stdOut
   629             errorTo:stdErr
   630             inDirectory:(buildDirectory / module / directory)
   631             onError:[:status| self error:'make failed'].
   632 
   633         (makeExeOnly ? false) ifFalse:[
   634             OperatingSystem
   635                 executeCommand:(makeCommand,' setup')
   636                 inputFrom:nil
   637                 outputTo:stdOut
   638                 errorTo:stdErr
   639                 inDirectory:(buildDirectory / module / directory)
   640                 onError:[:status| self error:'make failed'].
   641         ]
   642     ]
   643 !
   644 
   645 recursiveCopyDirectoryForBuild:subdir
   646     |targetDir|
   647 
   648     targetDir := buildDirectory / 'stx' / subdir.
   649     targetDir exists ifFalse:[
   650         targetDir makeDirectory.
   651     ].
   652     (mySTXTopDirectory / subdir) directoryContentsAsFilenamesDo:[:eachFile |
   653         eachFile recursiveCopyTo:(targetDir construct:eachFile baseName)
   654     ].
   655     self activityNotification:nil
   656 !
   657 
   658 setupBuildDirectory
   659     buildDirectory exists ifFalse:[
   660         buildDirectory recursiveMakeDirectory.
   661     ].
   662     (buildDirectory / 'stx') exists ifFalse:[
   663         (buildDirectory / 'stx') makeDirectory.
   664     ].
   665 
   666     self copyDirectoryForBuild:'include'.
   667     self copyDirectoryForBuild:'rules'.
   668     OperatingSystem isUNIXlike ifTrue:[
   669         self recursiveCopyDirectoryForBuild:'configurations'.
   670     ]
   671 !
   672 
   673 validateBuildDirectoryIsPresent
   674 
   675     ^ self.
   676 
   677 "/    [
   678 "/        |default directoryIsOKForMe stc |
   679 "/
   680 "/        default := (buildDirectory ?
   681 "/                          PreviousBuildDirectory)
   682 "/                          ifNil:[ UserPreferences current buildDirectory].
   683 "/
   684 "/        buildDirectory := Dialog requestDirectoryName:'Temporary Work-ROOT for build:'
   685 "/                                 default:default.
   686 "/
   687 "/        buildDirectory isEmptyOrNil ifTrue:[^ self].
   688 "/        buildDirectory := buildDirectory asFilename.
   689 "/        directoryIsOKForMe := true.
   690 "/
   691 "/        buildDirectory exists ifFalse:[
   692 "/            Dialog warn:(self classResources string:'Work directory %1 does not exist.' with:buildDirectory).
   693 "/            directoryIsOKForMe := false.
   694 "/        ] ifTrue:[
   695 "/            (buildDirectory construct:'stx') exists ifFalse:[
   696 "/                Dialog warn:(self classResources stringWithCRs:'Work directory must contain an stx subDirectory,\which contains (at least) the stc and include subdirectories.').
   697 "/                directoryIsOKForMe := false.
   698 "/            ] ifTrue:[
   699 "/                stc := (OperatingSystem isMSDOSlike) ifTrue:['stc.exe'] ifFalse:['stc'].
   700 "/                (((buildDirectory construct:'stx')construct:'stc')construct:stc) exists ifFalse:[
   701 "/                    Dialog warn:(self classResources stringWithCRs:'Work directory must contain an stc compiler in the stx/stc subDirectory.').
   702 "/                    directoryIsOKForMe := false.
   703 "/                ].
   704 "/                ((buildDirectory construct:'stx')construct:'include') exists ifFalse:[
   705 "/                    Dialog warn:(self classResources stringWithCRs:'Work directory must have had a make run before (for include files to exists).').
   706 "/                    directoryIsOKForMe := false.
   707 "/                ].
   708 "/            ]
   709 "/        ].
   710 "/        directoryIsOKForMe
   711 "/    ] whileFalse
   712 ! !
   713 
   714 !ProjectBuilder class methodsFor:'documentation'!
   715 
   716 version_CVS
   717     ^ '$Header$'
   718 ! !