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