ProjectBuilder.st
changeset 2635 8b62bd023558
parent 2634 3f14301cec84
child 2644 428bb83dd360
equal deleted inserted replaced
2634:3f14301cec84 2635:8b62bd023558
     1 "{ Package: 'stx:libtool2' }"
     1 "{ Package: 'stx:libtool2' }"
       
     2 
       
     3 "{ NameSpace: Tools }"
     2 
     4 
     3 Object subclass:#ProjectBuilder
     5 Object subclass:#ProjectBuilder
     4 	instanceVariableNames:'package projectDefinitionClass sourceCodeManager buildDirectory
     6 	instanceVariableNames:'package projectDefinitionClass sourceCodeManager buildDirectory
     5 		myWorkingDirectory mySTXTopDirectory myTopDirectory'
     7 		myWorkingDirectory mySTXTopDirectory myTopDirectory'
     6 	classVariableNames:'PreviousBuildDirectory'
     8 	classVariableNames:'PreviousBuildDirectory'
    26 methodsFor:'examples'
    28 methodsFor:'examples'
    27 ! !
    29 ! !
    28 
    30 
    29 !ProjectBuilder methodsFor:'accessing'!
    31 !ProjectBuilder methodsFor:'accessing'!
    30 
    32 
    31 x:clients/Demos/foxCalcApplication'.
    33 ileBrowserClass openOnDirectory:builder packageBuildDirectory.
    32     builder build.
       
    33 
       
    34     UserPreferences fileBrowserClass openOnDirectory:builder packageBuildDirectory.
       
    35 !
    34 !
    36 
    35 
    37 buildDirectory:something
    36 buildDirectory:something
    38     buildDirectory := something.
    37     buildDirectory := something.
    39 !
    38 !
    40 
    39 
    41 uilder build.
       
    42 
       
    43     UserPreferences fileBrowserClass openOnDirectory:builder packageBuildDirectory.
       
    44 !
       
    45 
       
    46 kageBuildDirectory.
    40 kageBuildDirectory.
    47 !
    41 !
    48 
    42 
    49 packageBuildDirectory
    43 he directoray, where the deployable binary is created (xxxSetup.exe)"
    50     "the directoray, where the deployable binary is created (xxxSetup.exe)"
       
    51 
    44 
    52     ^ buildDirectory / (package asPackageId module) / (package asPackageId directory)
    45     ^ buildDirectory / (package asPackageId module) / (package asPackageId directory)
       
    46 !
       
    47 
       
    48 'building'
    53 ! !
    49 ! !
    54 
    50 
    55 !ProjectBuilder methodsFor:'building'!
    51 !ProjectBuilder methodsFor:'building'!
    56 
    52 
    57 (package asPackageId module) / (package asPackageId directory)
    53 "/ intermediate - this will move into a commonly used utility class
    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).
    54     "/ (where all the project code support will be collected).
    63 
    55 
    64     |module directory|
    56     |module directory|
    65 
    57 
    66     projectDefinitionClass := ProjectDefinition definitionClassForPackage:package.
    58     projectDefinitionClass := ProjectDefinition definitionClassForPackage:package.
   121 
   113 
   122     self activityNotification:'Executing make...'.
   114     self activityNotification:'Executing make...'.
   123     self makeWithOutputTo:stdOut errorTo:stdErr.
   115     self makeWithOutputTo:stdOut errorTo:stdErr.
   124 !
   116 !
   125 
   117 
   126 ...'.
   118 buildWithOutputTo:stdOut errorTo:stdErr
       
   119     "/ intermediate - this will move into a commonly used utility class
       
   120     "/ (where all the project code support will be collected).
       
   121 
       
   122     |module directory|
       
   123 
       
   124     projectDefinitionClass := ProjectDefinition definitionClassForPackage:package.
       
   125     projectDefinitionClass isNil ifTrue:[
       
   126         self error:('Missing ProjectDefinition class for "',package asString,'"')
       
   127     ].
       
   128 
       
   129     "/ ensure that everything is loaded...
       
   130     projectDefinitionClass loadAsAutoloaded:false.
       
   131     projectDefinitionClass loadExtensions.
       
   132     projectDefinitionClass loadAllClassesAsAutoloaded:false.
       
   133 
       
   134     module := package module.
       
   135     directory := package directory.
       
   136 
       
   137     buildDirectory isNil ifTrue:[
       
   138         buildDirectory := PreviousBuildDirectory ifNil:[ UserPreferences current buildDirectory ].
       
   139         buildDirectory isNil ifTrue:[
       
   140             buildDirectory := Filename tempDirectory construct:'stx_build'.
       
   141         ].
       
   142     ].
       
   143     buildDirectory := buildDirectory asFilename.
       
   144 
       
   145     "/ self validateBuildDirectoryIsPresent.
       
   146 
       
   147     PreviousBuildDirectory := buildDirectory.
       
   148 
       
   149     "/ UserPreferences current localBuild:true
       
   150     UserPreferences current localBuild ifFalse:[
       
   151         SourceCodeManager notNil ifTrue:[
       
   152             sourceCodeManager := SourceCodeManagerUtilities sourceCodeManagerFor:projectDefinitionClass.
       
   153         ]
       
   154     ].
       
   155     sourceCodeManager := nil.
       
   156 
       
   157     myTopDirectory := 
       
   158         Smalltalk packagePath 
       
   159             detect:[:aPath |
       
   160                 (aPath asFilename / 'stx' / 'include') exists
       
   161                 and: [ (aPath asFilename / 'stx' / 'rules') exists ]]
       
   162             ifNone:nil.       
       
   163     myTopDirectory isNil ifTrue:[
       
   164         self error:('Cannot figure out my top directory (where stx/include and stx/rules are)')
       
   165     ].
       
   166     myTopDirectory := myTopDirectory asFilename.
       
   167     mySTXTopDirectory := myTopDirectory / 'stx'.
       
   168 
       
   169     self setupBuildDirectory.
       
   170     self activityNotification:'Generating stc directory...'.
       
   171     self copySTCDirectoryForBuild.
       
   172     self activityNotification:'Generating source files...'.
       
   173     self generateSourceFiles.
       
   174     self activityNotification:'Generating dlls for linkage...'.
       
   175     self copyDLLsForLinkage.
       
   176     self activityNotification:'Generating support files for linkage...'.
   127     self copySupportFilesForLinkage.
   177     self copySupportFilesForLinkage.
   128     self copyStartupFilesFromSmalltalk.
   178     self copyStartupFilesFromSmalltalk.
   129 
   179 
   130     self activityNotification:'Executing make...'.
   180     self activityNotification:'Executing make...'.
   131     self makeWithOutputTo:stdOut errorTo:stdErr.
   181     self makeWithOutputTo:stdOut errorTo:stdErr.
   132 !
   182 !
   133 
   183 
   134 (packageTargetDir / dllRelativePath) directory recursiveMakeDirectory.
   184 lRelativePath).    
   135             (dllSourceDir / dllRelativePath) copyTo:(packageTargetDir / dllRelativePath).    
       
   136         ]
   185         ]
   137     ].
   186     ].
   138 !
   187 !
   139 
   188 
   140 tory:relativepath
   189 !
   141     "/ need rules in stx
   190 
   142     ((Smalltalk projectDirectoryForPackage:'stx') asFilename construct:relativepath)
   191 !
   143         recursiveCopyTo:(buildDirectory construct:'stx').
   192 
   144 !
   193 !
   145 
   194 
   146 ification:'copying ',eachFile pathName,'...'.
   195 !
   147                 eachFile copyTo:(targetDir construct:eachFile baseName)
   196 
   148             ]
   197 !
   149         ].
   198 
   150     ].
   199 !
   151     self activityNotification:nil
   200 
   152 !
   201 !
   153 
   202 
   154 tory / module / directory / 'styles' ) exists ifTrue:[
   203 !
   155         (myTopDirectory / module / directory / 'styles' )
   204 
   156             recursiveCopyTo:(buildDirectory / module / directory)
   205 !
   157     ].
   206 
   158 !
   207 !
   159 
   208 
   160 me ]) ifTrue:[
   209 !
   161             self activityNotification:'copying ',sourceFile pathName,'...'.
   210 
   162             sourceFile copyTo:targetFile
   211 !
   163         ].
   212 
   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 ! !
   213 ! !
   228 
   214 
   229 !ProjectBuilder class methodsFor:'documentation'!
   215 !ProjectBuilder class methodsFor:'documentation'!
   230 
   216 
   231 version_CVS
   217 version_CVS