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