ProjectBuilder.st
author Claus Gittinger <cg@exept.de>
Tue, 20 Oct 2009 21:51:54 +0200
changeset 2634 3f14301cec84
parent 2633 4a48f107431a
child 2635 8b62bd023558
permissions -rw-r--r--
added: #buildDirectory:
changed: #buildWithOutputTo:errorTo:
     1 "{ Package: 'stx:libtool2' }"
     2 
     3 Object subclass:#ProjectBuilder
     4 	instanceVariableNames:'package projectDefinitionClass sourceCodeManager buildDirectory
     5 		myWorkingDirectory mySTXTopDirectory myTopDirectory'
     6 	classVariableNames:'PreviousBuildDirectory'
     7 	poolDictionaries:''
     8 	category:'System-Support-Projects'
     9 !
    10 
    11 
    12 !ProjectBuilder class methodsFor:'accessing'!
    13 
    14 previousBuildDirectory
    15     ^ PreviousBuildDirectory
    16 !
    17 
    18 previousBuildDirectory:something
    19     PreviousBuildDirectory := something.
    20 ! !
    21 
    22 !ProjectBuilder class methodsFor:'examples'!
    23 
    24 !
    25 
    26 methodsFor:'examples'
    27 ! !
    28 
    29 !ProjectBuilder methodsFor:'accessing'!
    30 
    31 x:clients/Demos/foxCalcApplication'.
    32     builder build.
    33 
    34     UserPreferences fileBrowserClass openOnDirectory:builder packageBuildDirectory.
    35 !
    36 
    37 buildDirectory:something
    38     buildDirectory := something.
    39 !
    40 
    41 uilder build.
    42 
    43     UserPreferences fileBrowserClass openOnDirectory:builder packageBuildDirectory.
    44 !
    45 
    46 kageBuildDirectory.
    47 !
    48 
    49 packageBuildDirectory
    50     "the directoray, where the deployable binary is created (xxxSetup.exe)"
    51 
    52     ^ buildDirectory / (package asPackageId module) / (package asPackageId directory)
    53 ! !
    54 
    55 !ProjectBuilder methodsFor:'building'!
    56 
    57 (package asPackageId module) / (package asPackageId directory)
    58 !
    59 
    60 buildWithOutputTo:stdOut errorTo:stdErr
    61     "/ intermediate - this will move into a commonly used utility class
    62     "/ (where all the project code support will be collected).
    63 
    64     |module directory|
    65 
    66     projectDefinitionClass := ProjectDefinition definitionClassForPackage:package.
    67     projectDefinitionClass isNil ifTrue:[
    68         self error:('Missing ProjectDefinition class for "',package asString,'"')
    69     ].
    70 
    71     "/ ensure that everything is loaded...
    72     projectDefinitionClass loadAsAutoloaded:false.
    73     projectDefinitionClass loadExtensions.
    74     projectDefinitionClass loadAllClassesAsAutoloaded:false.
    75 
    76     module := package module.
    77     directory := package directory.
    78 
    79     buildDirectory isNil ifTrue:[
    80         buildDirectory := PreviousBuildDirectory ifNil:[ UserPreferences current buildDirectory ].
    81         buildDirectory isNil ifTrue:[
    82             buildDirectory := Filename tempDirectory construct:'stx_build'.
    83         ].
    84     ].
    85     buildDirectory := buildDirectory asFilename.
    86 
    87     "/ self validateBuildDirectoryIsPresent.
    88 
    89     PreviousBuildDirectory := buildDirectory.
    90 
    91     "/ UserPreferences current localBuild:true
    92     UserPreferences current localBuild ifFalse:[
    93         SourceCodeManager notNil ifTrue:[
    94             sourceCodeManager := SourceCodeManagerUtilities sourceCodeManagerFor:projectDefinitionClass.
    95         ]
    96     ].
    97     sourceCodeManager := nil.
    98 
    99     myTopDirectory := 
   100         Smalltalk packagePath 
   101             detect:[:aPath |
   102                 (aPath asFilename / 'stx' / 'include') exists
   103                 and: [ (aPath asFilename / 'stx' / 'rules') exists ]]
   104             ifNone:nil.       
   105     myTopDirectory isNil ifTrue:[
   106         self error:('Cannot figure out my top directory (where stx/include and stx/rules are)')
   107     ].
   108     myTopDirectory := myTopDirectory asFilename.
   109     mySTXTopDirectory := myTopDirectory / 'stx'.
   110 
   111     self setupBuildDirectory.
   112     self activityNotification:'Generating stc directory...'.
   113     self copySTCDirectoryForBuild.
   114     self activityNotification:'Generating source files...'.
   115     self generateSourceFiles.
   116     self activityNotification:'Generating dlls for linkage...'.
   117     self copyDLLsForLinkage.
   118     self activityNotification:'Generating support files for linkage...'.
   119     self copySupportFilesForLinkage.
   120     self copyStartupFilesFromSmalltalk.
   121 
   122     self activityNotification:'Executing make...'.
   123     self makeWithOutputTo:stdOut errorTo:stdErr.
   124 !
   125 
   126 ...'.
   127     self copySupportFilesForLinkage.
   128     self copyStartupFilesFromSmalltalk.
   129 
   130     self activityNotification:'Executing make...'.
   131     self makeWithOutputTo:stdOut errorTo:stdErr.
   132 !
   133 
   134 (packageTargetDir / dllRelativePath) directory recursiveMakeDirectory.
   135             (dllSourceDir / dllRelativePath) copyTo:(packageTargetDir / dllRelativePath).    
   136         ]
   137     ].
   138 !
   139 
   140 tory:relativepath
   141     "/ need rules in stx
   142     ((Smalltalk projectDirectoryForPackage:'stx') asFilename construct:relativepath)
   143         recursiveCopyTo:(buildDirectory construct:'stx').
   144 !
   145 
   146 ification:'copying ',eachFile pathName,'...'.
   147                 eachFile copyTo:(targetDir construct:eachFile baseName)
   148             ]
   149         ].
   150     ].
   151     self activityNotification:nil
   152 !
   153 
   154 tory / module / directory / 'styles' ) exists ifTrue:[
   155         (myTopDirectory / module / directory / 'styles' )
   156             recursiveCopyTo:(buildDirectory / module / directory)
   157     ].
   158 !
   159 
   160 me ]) ifTrue:[
   161             self activityNotification:'copying ',sourceFile pathName,'...'.
   162             sourceFile copyTo:targetFile
   163         ].
   164     ].
   165     self activityNotification:nil
   166 !
   167 
   168 'host.rc' 'h_win32.rc'  
   169     ) do:[:fn |
   170         (myTopDirectory / 'stx' / 'projects/smalltalk' / fn)
   171             copyTo: (buildDirectory / 'stx' / 'projects/smalltalk' / fn)
   172     ]
   173 !
   174 
   175 ry / 'stx' / dllRelativePath) directory recursiveMakeDirectory.
   176             (mySTXTopDirectory / dllRelativePath) copyTo:(buildDirectory / 'stx' / dllRelativePath).    
   177         ]
   178     ].
   179 !
   180 
   181 ename / ((Smalltalk fileNameForClass:aClass),'.STH').
   182     (file exists not
   183     or:[ (oldContents := file contents) ~= newContents ]) ifTrue:[
   184         file contents: newContents.
   185     ].
   186 !
   187 
   188 self generateSourceFilesByCheckingOutUsing:sourceCodeManager
   189     ] ifFalse:[
   190         "/ local build
   191         "/ fileout the project
   192         self generateSourceFilesByFilingOut
   193     ]
   194 !
   195 
   196 :nil
   197         outputTo:Transcript
   198         errorTo:Transcript
   199         inDirectory:(buildDirectory construct:module)
   200         onError:[:status| self error:'cvs update failed'].
   201 self halt.
   202 !
   203 
   204 or:cls in:packageTargetDir
   205             ].
   206         ].
   207         self copyResourcesForPackage:eachPackageToFileout.
   208     ].
   209 
   210 "/    stx_libbasic2 preRequisitesForBuilding#(#'stx:libbasic')
   211 !
   212 
   213 nil
   214             outputTo:stdOut
   215             errorTo:stdErr
   216             inDirectory:(buildDirectory / module / directory)
   217             onError:[:status| self error:'make failed'].
   218     ]
   219 !
   220 
   221 (buildDirectory / 'stx') exists ifFalse:[
   222         (buildDirectory / 'stx') makeDirectory.
   223     ].
   224 
   225     self copyDirectoryForBuild:'include'.
   226     self copyDirectoryForBuild:'rules'.
   227 ! !
   228 
   229 !ProjectBuilder class methodsFor:'documentation'!
   230 
   231 version_CVS
   232     ^ '$Header$'
   233 ! !