ProjectBuilder.st
author Stefan Vogel <sv@exept.de>
Wed, 22 Jun 2011 14:16:09 +0200
changeset 2844 5e4e46856d8d
parent 2793 e03152b97cdd
child 2845 0d52c66fbc8e
permissions -rw-r--r--
changed: #generateSourceFilesByFilingOut
take care for files like 'autopackage/default.apspec'
     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     |fullPathName|
   544 
   545     (package module ~= 'stx') ifTrue:[
   546         (buildDirectory / package module) makeDirectory.
   547     ].
   548 
   549     "/ file out the package(s) which are to be built
   550     ((Array with:package))
   551     do:[:eachPackageToFileout |
   552         |packageId packageModule packageDirectory packageTargetDir packageDef|
   553 
   554         packageId := eachPackageToFileout asPackageId.
   555         packageModule := packageId module.
   556         packageDirectory := packageId directory.
   557         packageTargetDir := (buildDirectory / packageModule / packageDirectory) recursiveMakeDirectory.
   558 
   559         packageDef := packageId projectDefinitionClass.
   560         (packageDef compiled_classNames_common ,
   561         packageDef compiled_classNamesForPlatform) do:[:eachClassName |
   562             |cls fileName newSource|
   563 
   564             cls := Smalltalk classNamed:eachClassName.
   565             self assert:cls isLoaded.
   566             fileName := (Smalltalk fileNameForClass:cls),'.st'.
   567             fileName := packageTargetDir asFilename construct:fileName.
   568             fileName exists ifTrue:[
   569                 newSource := String streamContents:[:s | cls fileOutOn:s withTimeStamp:false].
   570                 newSource = fileName contentsAsString ifFalse:[
   571                     fileName contents:newSource
   572                 ].
   573             ] ifFalse:[
   574                 cls fileOutIn:packageTargetDir withTimeStamp:false
   575             ].
   576         ].
   577 
   578 "/        (Smalltalk allClassesInPackage:eachPackageToFileout) do:[:cls |
   579 "/            cls isPrivate ifFalse:[
   580 "/                cls isLoaded ifFalse:[
   581 "/                    self halt.
   582 "/                    cls autoload.
   583 "/                ].
   584 "/                cls fileOutIn:packageTargetDir
   585 "/            ]
   586 "/        ].
   587 
   588         projectDefinitionClass forEachFileNameAndGeneratedContentsDo:[:fileName :fileContents |
   589             fullPathName := packageTargetDir construct:fileName.
   590             fullPathName directory exists ifFalse:[
   591                 "take care for files like 'autopackage/default.apspec'"
   592                 fullPathName directory makeDirectory.
   593             ].
   594             (fullPathName exists
   595              and:[ fullPathName contents = fileContents ]) ifFalse:[
   596                 fullPathName contents:fileContents.
   597             ].
   598         ].    
   599     ].
   600 
   601     "/ generate header files in prerequisite packages...
   602     (projectDefinitionClass allPreRequisites)
   603     do:[:eachPackageToFileout |
   604         |packageId packageDef packageModule packageDirectory packageTargetDir|
   605 
   606         packageId := eachPackageToFileout asPackageId.
   607         packageModule := packageId module.
   608         packageDirectory := packageId directory.
   609         packageTargetDir := (buildDirectory / packageModule / packageDirectory) recursiveMakeDirectory.
   610 
   611         packageDef := packageId projectDefinitionClass.
   612         (packageDef compiled_classNames_common ,
   613         packageDef compiled_classNamesForPlatform) do:[:eachClassName |
   614             |cls|
   615 
   616             cls := Smalltalk classNamed:eachClassName.
   617             "/ self assert:cls isLoaded.
   618             cls isLoaded ifTrue:[    
   619                 self createHeaderFileFor:cls in:packageTargetDir
   620             ].
   621         ].
   622         self copyResourcesForPackage:eachPackageToFileout.
   623     ].
   624 
   625 "/    stx_libbasic2 preRequisitesForBuilding#(#'stx:libbasic')
   626 !
   627 
   628 makeWithOutputTo:stdOut errorTo:stdErr
   629     |module directory compilerFlag makeCommand|
   630 
   631     module := package module.
   632     directory := package directory.
   633 
   634     makeCommand := ParserFlags makeCommand.
   635     usedCompiler = 'vc' ifTrue:[ makeCommand := 'vcmake'. compilerFlag := '-DUSEVC' ].
   636     usedCompiler = 'lcc' ifTrue:[ makeCommand := 'lcmake'. compilerFlag := '-DUSELCC' ].
   637     usedCompiler = 'gcc' ifTrue:[ makeCommand := 'make'. ].
   638 
   639     OperatingSystem isUNIXlike ifTrue:[
   640         OperatingSystem
   641             executeCommand:'sh ../../stx/rules/stmkmf'
   642             inputFrom:nil
   643             outputTo:stdOut
   644             errorTo:stdErr
   645             inDirectory:(buildDirectory / module / directory)
   646             onError:[:status| self error:'make failed'].
   647     ].
   648 
   649     projectDefinitionClass isLibraryDefinition ifTrue:[
   650         OperatingSystem
   651             executeCommand:(makeCommand,' classLibRule')
   652             inputFrom:nil
   653             outputTo:stdOut
   654             errorTo:stdErr
   655             inDirectory:(buildDirectory / module / directory)
   656             onError:[:status| self error:'make failed'].
   657     ] ifFalse:[
   658         OperatingSystem
   659             executeCommand:(makeCommand,' exe')
   660             inputFrom:nil
   661             outputTo:stdOut
   662             errorTo:stdErr
   663             inDirectory:(buildDirectory / module / directory)
   664             onError:[:status| self error:'make failed'].
   665 
   666         (makeExeOnly ? false) ifFalse:[
   667             OperatingSystem
   668                 executeCommand:(makeCommand,' setup')
   669                 inputFrom:nil
   670                 outputTo:stdOut
   671                 errorTo:stdErr
   672                 inDirectory:(buildDirectory / module / directory)
   673                 onError:[:status| self error:'make failed'].
   674         ]
   675     ]
   676 
   677     "Modified: / 26-07-2010 / 12:25:33 / cg"
   678 !
   679 
   680 recursiveCopyDirectoryForBuild:subdir
   681     |targetDir|
   682 
   683     targetDir := buildDirectory / 'stx' / subdir.
   684     targetDir exists ifFalse:[
   685         targetDir makeDirectory.
   686     ].
   687     (mySTXTopDirectory / subdir) directoryContentsAsFilenamesDo:[:eachFile |
   688         eachFile recursiveCopyTo:(targetDir construct:eachFile baseName)
   689     ].
   690     self activityNotification:nil
   691 !
   692 
   693 setupBuildDirectory
   694     buildDirectory exists ifFalse:[
   695         buildDirectory recursiveMakeDirectory.
   696     ].
   697     (buildDirectory / 'stx') exists ifFalse:[
   698         (buildDirectory / 'stx') makeDirectory.
   699     ].
   700 
   701     self copyDirectoryForBuild:'include'.
   702     self copyDirectoryForBuild:'rules'.
   703     OperatingSystem isUNIXlike ifTrue:[
   704         self recursiveCopyDirectoryForBuild:'configurations'.
   705     ]
   706 !
   707 
   708 validateBuildDirectoryIsPresent
   709 
   710     ^ self.
   711 
   712 "/    [
   713 "/        |default directoryIsOKForMe stc |
   714 "/
   715 "/        default := (buildDirectory ?
   716 "/                          PreviousBuildDirectory)
   717 "/                          ifNil:[ UserPreferences current buildDirectory].
   718 "/
   719 "/        buildDirectory := Dialog requestDirectoryName:'Temporary Work-ROOT for build:'
   720 "/                                 default:default.
   721 "/
   722 "/        buildDirectory isEmptyOrNil ifTrue:[^ self].
   723 "/        buildDirectory := buildDirectory asFilename.
   724 "/        directoryIsOKForMe := true.
   725 "/
   726 "/        buildDirectory exists ifFalse:[
   727 "/            Dialog warn:(self classResources string:'Work directory %1 does not exist.' with:buildDirectory).
   728 "/            directoryIsOKForMe := false.
   729 "/        ] ifTrue:[
   730 "/            (buildDirectory construct:'stx') exists ifFalse:[
   731 "/                Dialog warn:(self classResources stringWithCRs:'Work directory must contain an stx subDirectory,\which contains (at least) the stc and include subdirectories.').
   732 "/                directoryIsOKForMe := false.
   733 "/            ] ifTrue:[
   734 "/                stc := (OperatingSystem isMSDOSlike) ifTrue:['stc.exe'] ifFalse:['stc'].
   735 "/                (((buildDirectory construct:'stx')construct:'stc')construct:stc) exists ifFalse:[
   736 "/                    Dialog warn:(self classResources stringWithCRs:'Work directory must contain an stc compiler in the stx/stc subDirectory.').
   737 "/                    directoryIsOKForMe := false.
   738 "/                ].
   739 "/                ((buildDirectory construct:'stx')construct:'include') exists ifFalse:[
   740 "/                    Dialog warn:(self classResources stringWithCRs:'Work directory must have had a make run before (for include files to exists).').
   741 "/                    directoryIsOKForMe := false.
   742 "/                ].
   743 "/            ]
   744 "/        ].
   745 "/        directoryIsOKForMe
   746 "/    ] whileFalse
   747 ! !
   748 
   749 !ProjectBuilder class methodsFor:'documentation'!
   750 
   751 version_CVS
   752     ^ '$Header$'
   753 ! !