author | Claus Gittinger <cg@exept.de> |
Thu, 22 Oct 2009 23:17:23 +0200 | |
changeset 2675 | 7bd7413e3cb3 |
parent 2673 | 100b4dd5c3c2 |
child 2677 | e2c24a1be97f |
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 |
8 |
makeExeOnly' |
|
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. |
|
2596 | 73 |
! ! |
74 |
||
75 |
!ProjectBuilder methodsFor:'building'! |
|
76 |
||
2644 | 77 |
build |
78 |
"/ intermediate - this will move into a commonly used utility class |
|
2635 | 79 |
"/ (where all the project code support will be collected). |
80 |
||
2647 | 81 |
|makeOutput| |
82 |
||
83 |
makeOutput := TextStream on:(Text new:10000). |
|
84 |
self buildWithColorizedOutputTo:makeOutput. |
|
85 |
||
86 |
TextView openWith:makeOutput contents. |
|
87 |
! |
|
88 |
||
89 |
buildWithColorizedOutputTo:makeOutput |
|
90 |
"/ intermediate - this will move into a commonly used utility class |
|
91 |
"/ (where all the project code support will be collected). |
|
92 |
||
93 |
|stdOut stdErr lock| |
|
2635 | 94 |
|
2644 | 95 |
lock := Semaphore forMutualExclusion. |
2647 | 96 |
|
2644 | 97 |
stdErr := ActorStream new |
98 |
nextPutBlock:[:char | |
|
99 |
lock critical:[ |
|
100 |
makeOutput emphasis:{#backgroundColor->Color red. #color->Color white.}. |
|
101 |
makeOutput nextPut:char. |
|
102 |
makeOutput emphasis:nil. |
|
103 |
] |
|
104 |
]; |
|
105 |
nextPutAllBlock:[:char | |
|
106 |
lock critical:[ |
|
107 |
makeOutput emphasis:{#backgroundColor->Color red. #color->Color white.}. |
|
108 |
makeOutput nextPutAll:char. |
|
109 |
makeOutput emphasis:nil. |
|
110 |
] |
|
111 |
]. |
|
112 |
stdOut := ActorStream new |
|
113 |
nextPutBlock:[:char | |
|
114 |
lock critical:[ |
|
115 |
makeOutput nextPut:char. |
|
116 |
] |
|
117 |
]; |
|
118 |
nextPutAllBlock:[:char | |
|
119 |
lock critical:[ |
|
120 |
makeOutput nextPutAll:char. |
|
121 |
] |
|
122 |
]. |
|
2635 | 123 |
|
2644 | 124 |
self buildWithOutputTo:stdOut errorTo:stdErr. |
2611 | 125 |
! |
126 |
||
127 |
buildWithOutputTo:stdOut errorTo:stdErr |
|
128 |
"/ intermediate - this will move into a commonly used utility class |
|
129 |
"/ (where all the project code support will be collected). |
|
130 |
||
2596 | 131 |
|module directory| |
132 |
||
133 |
projectDefinitionClass := ProjectDefinition definitionClassForPackage:package. |
|
134 |
projectDefinitionClass isNil ifTrue:[ |
|
135 |
self error:('Missing ProjectDefinition class for "',package asString,'"') |
|
136 |
]. |
|
137 |
||
138 |
"/ ensure that everything is loaded... |
|
139 |
projectDefinitionClass loadAsAutoloaded:false. |
|
140 |
projectDefinitionClass loadExtensions. |
|
141 |
projectDefinitionClass loadAllClassesAsAutoloaded:false. |
|
142 |
||
143 |
module := package module. |
|
144 |
directory := package directory. |
|
145 |
||
146 |
buildDirectory isNil ifTrue:[ |
|
2634 | 147 |
buildDirectory := PreviousBuildDirectory ifNil:[ UserPreferences current buildDirectory ]. |
148 |
buildDirectory isNil ifTrue:[ |
|
149 |
buildDirectory := Filename tempDirectory construct:'stx_build'. |
|
150 |
]. |
|
2596 | 151 |
]. |
152 |
buildDirectory := buildDirectory asFilename. |
|
153 |
||
154 |
"/ self validateBuildDirectoryIsPresent. |
|
155 |
||
156 |
PreviousBuildDirectory := buildDirectory. |
|
157 |
||
158 |
"/ UserPreferences current localBuild:true |
|
159 |
UserPreferences current localBuild ifFalse:[ |
|
160 |
SourceCodeManager notNil ifTrue:[ |
|
161 |
sourceCodeManager := SourceCodeManagerUtilities sourceCodeManagerFor:projectDefinitionClass. |
|
162 |
] |
|
163 |
]. |
|
164 |
sourceCodeManager := nil. |
|
165 |
||
2598 | 166 |
myTopDirectory := |
2596 | 167 |
Smalltalk packagePath |
168 |
detect:[:aPath | |
|
169 |
(aPath asFilename / 'stx' / 'include') exists |
|
170 |
and: [ (aPath asFilename / 'stx' / 'rules') exists ]] |
|
171 |
ifNone:nil. |
|
2598 | 172 |
myTopDirectory isNil ifTrue:[ |
173 |
self error:('Cannot figure out my top directory (where stx/include and stx/rules are)') |
|
2596 | 174 |
]. |
2598 | 175 |
myTopDirectory := myTopDirectory asFilename. |
176 |
mySTXTopDirectory := myTopDirectory / 'stx'. |
|
2613
b8d38caaa884
changed: #buildWithOutputTo:errorTo:
Claus Gittinger <cg@exept.de>
parents:
2612
diff
changeset
|
177 |
|
2596 | 178 |
self setupBuildDirectory. |
2628 | 179 |
self activityNotification:'Generating stc directory...'. |
2599 | 180 |
self copySTCDirectoryForBuild. |
2628 | 181 |
self activityNotification:'Generating source files...'. |
2596 | 182 |
self generateSourceFiles. |
2672
a1cda5d8943d
changed: #buildWithOutputTo:errorTo:
Claus Gittinger <cg@exept.de>
parents:
2647
diff
changeset
|
183 |
self activityNotification:'Copying dlls for linkage...'. |
2600 | 184 |
self copyDLLsForLinkage. |
2672
a1cda5d8943d
changed: #buildWithOutputTo:errorTo:
Claus Gittinger <cg@exept.de>
parents:
2647
diff
changeset
|
185 |
self activityNotification:'Copying support files for linkage...'. |
2600 | 186 |
self copySupportFilesForLinkage. |
187 |
self copyStartupFilesFromSmalltalk. |
|
2596 | 188 |
|
2628 | 189 |
self activityNotification:'Executing make...'. |
2611 | 190 |
self makeWithOutputTo:stdOut errorTo:stdErr. |
2596 | 191 |
! |
192 |
||
2644 | 193 |
copyDLLsForLinkage |
194 |
|targetBuildDir| |
|
195 |
||
196 |
targetBuildDir := buildDirectory / package module / package directory. |
|
197 |
||
198 |
(projectDefinitionClass allPreRequisites) |
|
199 |
do:[:eachPackageToFileout | |
|
200 |
|packageId packageDef packageModule packageDirectory packageTargetDir |
|
201 |
dllSource dllSourceDir libraryName dllRelativePath| |
|
202 |
||
203 |
packageId := eachPackageToFileout asPackageId. |
|
204 |
packageModule := packageId module. |
|
205 |
packageDirectory := packageId directory. |
|
206 |
packageTargetDir := (buildDirectory / packageModule / packageDirectory) recursiveMakeDirectory. |
|
207 |
||
208 |
packageDef := packageId projectDefinitionClass. |
|
209 |
libraryName := packageDef libraryName. |
|
210 |
||
211 |
"/ mhmh - take them from my tree or from the projects/smalltalk execution directory ?? |
|
212 |
dllSourceDir := myTopDirectory / packageModule / packageDirectory. |
|
213 |
OperatingSystem isMSWINDOWSlike ifTrue:[ |
|
214 |
"/ dllRelativePath := 'objvc','/',(libraryName,'.dll'). |
|
215 |
"/ (dllSourceDir / dllRelativePath) exists |
|
216 |
false ifFalse:[ |
|
217 |
dllRelativePath := 'objbc','/',(libraryName,'.dll'). |
|
218 |
] |
|
219 |
] ifFalse:[ |
|
220 |
dllRelativePath := libraryName,'.so'. |
|
221 |
]. |
|
222 |
((packageTargetDir / dllRelativePath) exists |
|
223 |
and:[ (dllSourceDir / dllRelativePath) fileSize = (packageTargetDir / dllRelativePath) fileSize |
|
224 |
and:[ (dllSourceDir / dllRelativePath) modificationTime < (packageTargetDir / dllRelativePath) modificationTime |
|
225 |
"/ and:[ (dllSourceDir / dllRelativePath) sameContentsAs:(packageTargetDir / dllRelativePath) ] |
|
226 |
]]) ifFalse:[ |
|
227 |
(packageTargetDir / dllRelativePath) directory recursiveMakeDirectory. |
|
228 |
(dllSourceDir / dllRelativePath) copyTo:(packageTargetDir / dllRelativePath). |
|
229 |
] |
|
230 |
]. |
|
231 |
! |
|
232 |
||
233 |
copyDirectory:relativepath |
|
234 |
"/ need rules in stx |
|
235 |
((Smalltalk projectDirectoryForPackage:'stx') asFilename construct:relativepath) |
|
236 |
recursiveCopyTo:(buildDirectory construct:'stx'). |
|
237 |
! |
|
238 |
||
239 |
copyDirectoryForBuild:subdir |
|
240 |
|targetDir targetFile| |
|
241 |
||
242 |
targetDir := buildDirectory / 'stx' / subdir. |
|
243 |
targetDir exists ifFalse:[ |
|
244 |
targetDir makeDirectory. |
|
245 |
]. |
|
246 |
(mySTXTopDirectory / subdir) directoryContentsAsFilenamesDo:[:eachFile | |
|
247 |
eachFile isDirectory ifFalse:[ |
|
248 |
targetFile := targetDir / eachFile baseName. |
|
249 |
(targetFile exists not |
|
250 |
or:[ targetFile modificationTime < eachFile modificationTime ]) ifTrue:[ |
|
251 |
self activityNotification:'copying ',eachFile pathName,'...'. |
|
252 |
eachFile copyTo:(targetDir construct:eachFile baseName) |
|
253 |
] |
|
254 |
]. |
|
255 |
]. |
|
256 |
self activityNotification:nil |
|
257 |
! |
|
258 |
||
259 |
copyResourcesForPackage:aPackage |
|
260 |
|module directory| |
|
261 |
||
262 |
module := aPackage asPackageId module. |
|
263 |
directory := aPackage asPackageId directory. |
|
264 |
||
265 |
(myTopDirectory / module / directory / 'resources' ) exists ifTrue:[ |
|
266 |
(myTopDirectory / module / directory / 'resources' ) |
|
267 |
recursiveCopyTo:(buildDirectory / module / directory) |
|
268 |
]. |
|
269 |
(myTopDirectory / module / directory / 'styles' ) exists ifTrue:[ |
|
270 |
(myTopDirectory / module / directory / 'styles' ) |
|
271 |
recursiveCopyTo:(buildDirectory / module / directory) |
|
272 |
]. |
|
273 |
! |
|
274 |
||
275 |
copySTCDirectoryForBuild |
|
276 |
|targetDir stc files| |
|
277 |
||
278 |
targetDir := buildDirectory / 'stx' / 'stc'. |
|
279 |
targetDir exists ifFalse:[ targetDir makeDirectory ]. |
|
280 |
||
281 |
stc := OperatingSystem isMSWINDOWSlike |
|
282 |
ifTrue:[ 'stc.exe' ] |
|
283 |
ifFalse:[ 'stc' ]. |
|
284 |
||
285 |
files := #( ) copyWith:stc. |
|
286 |
||
287 |
files do:[:eachFile | |
|
288 |
|sourceFile targetFile| |
|
289 |
||
290 |
sourceFile := mySTXTopDirectory / 'stc' / eachFile. |
|
291 |
targetFile := targetDir / eachFile. |
|
292 |
(targetFile exists not |
|
293 |
or:[ targetFile modificationTime < sourceFile modificationTime ]) ifTrue:[ |
|
294 |
self activityNotification:'copying ',sourceFile pathName,'...'. |
|
295 |
sourceFile copyTo:targetFile |
|
296 |
]. |
|
297 |
]. |
|
298 |
self activityNotification:nil |
|
299 |
! |
|
300 |
||
301 |
copyStartupFilesFromSmalltalk |
|
302 |
(buildDirectory / 'stx' / 'projects/smalltalk' ) exists ifFalse:[ |
|
303 |
(buildDirectory / 'stx' / 'projects/smalltalk' ) recursiveMakeDirectory. |
|
304 |
]. |
|
305 |
||
306 |
#( 'keyboard.rc' 'keyboardMacros.rc' 'display.rc' 'd_win32.rc' |
|
307 |
'host.rc' 'h_win32.rc' |
|
308 |
) do:[:fn | |
|
309 |
(myTopDirectory / 'stx' / 'projects/smalltalk' / fn) |
|
310 |
copyTo: (buildDirectory / 'stx' / 'projects/smalltalk' / fn) |
|
311 |
] |
|
312 |
! |
|
313 |
||
314 |
copySupportFilesForLinkage |
|
315 |
|files| |
|
316 |
||
317 |
OperatingSystem isMSWINDOWSlike ifTrue:[ |
|
318 |
files := #( |
|
319 |
'support/win32/borland/cs3245.dll' |
|
320 |
'support/win32/X11.dll' |
|
321 |
'support/win32/Xext.dll' |
|
322 |
'librun/librun.dll' |
|
323 |
'libbc/librun.lib' |
|
324 |
'libbc/cs32i.lib' |
|
325 |
'librun/genDate.exe' |
|
326 |
'librun/main.c' |
|
2673 | 327 |
'projects/smalltalk/stx_16x16.ico' |
328 |
'projects/smalltalk/stx_32x32.ico' |
|
329 |
'projects/smalltalk/stx_splash.bmp' |
|
2644 | 330 |
). |
331 |
] ifFalse:[ |
|
332 |
files := #( |
|
333 |
'librun/genDate' |
|
334 |
'librun/main.c' |
|
335 |
'librun/librun.so' |
|
336 |
) |
|
337 |
]. |
|
338 |
||
339 |
files do:[:dllRelativePath | |
|
340 |
((buildDirectory / 'stx' / dllRelativePath) exists |
|
341 |
and:[ (mySTXTopDirectory / dllRelativePath) fileSize = (buildDirectory / 'stx' / dllRelativePath) fileSize |
|
342 |
and:[ (mySTXTopDirectory / dllRelativePath) modificationTime < (buildDirectory / 'stx' / dllRelativePath) modificationTime |
|
343 |
"/ and:[ (mySTXTopDirectory / dllRelativePath) sameContentsAs:(targetBuildDir / dllRelativePath) ] |
|
344 |
]]) ifFalse:[ |
|
345 |
(buildDirectory / 'stx' / dllRelativePath) directory recursiveMakeDirectory. |
|
346 |
(mySTXTopDirectory / dllRelativePath) copyTo:(buildDirectory / 'stx' / dllRelativePath). |
|
2614 | 347 |
] |
348 |
]. |
|
2600 | 349 |
! |
350 |
||
2644 | 351 |
createHeaderFileFor:aClass in:packageTargetDir |
352 |
|instVarList classInstVarList classVarList bindings superclassFilename |
|
353 |
template file newContents oldContents| |
|
354 |
||
355 |
instVarList := StringCollection new. |
|
356 |
aClass instVarNames do:[:v | |
|
357 |
instVarList add:('OBJ %1;' bindWith:v) |
|
358 |
]. |
|
359 |
classInstVarList := StringCollection new. |
|
360 |
aClass class instVarNames do:[:v | |
|
361 |
(v includes:$_) ifTrue:[self halt]. |
|
362 |
classInstVarList add:('OBJ %1;' bindWith:v) |
|
363 |
]. |
|
364 |
classVarList := StringCollection new. |
|
365 |
aClass classVarNames do:[:v | |
|
366 |
classVarList add:('extern OBJ %1_%2;' bindWith:aClass name with:v) |
|
367 |
]. |
|
2614 | 368 |
|
2644 | 369 |
bindings := Dictionary new. |
370 |
bindings at:'ClassName' put:aClass name. |
|
371 |
aClass superclass isNil ifTrue:[ |
|
372 |
bindings at:'SuperclassName' put:'-'. |
|
373 |
bindings at:'SuperclassFileInclude' put:nil. |
|
374 |
] ifFalse:[ |
|
375 |
bindings at:'SuperclassName' put:aClass superclass name. |
|
376 |
bindings at:'SuperclassFileName' put:(superclassFilename := Smalltalk fileNameForClass:aClass superclass). |
|
377 |
bindings at:'SuperclassFileInclude' put:('#include "%1.STH"' bindWith:superclassFilename). |
|
378 |
]. |
|
379 |
bindings at:'InstVarList' put:instVarList asString. |
|
380 |
bindings at:'ClassVarList' put:classVarList asString. |
|
381 |
bindings at:'ClassInstVarList' put:classInstVarList asString. |
|
382 |
||
383 |
template := |
|
384 |
'/* This file was generated by ProjectBuilder. */ |
|
385 |
/* !!!!!!!! Do not change by hand !!!!!!!! */ |
|
386 |
||
387 |
/* Class: %(ClassName) */ |
|
388 |
/* Superclass: %(SuperclassName) */ |
|
389 |
||
390 |
%(SuperclassFileInclude) |
|
391 |
||
392 |
/* INDIRECTGLOBALS */ |
|
393 |
#ifdef _HEADER_INST_ |
|
394 |
%(InstVarList) |
|
395 |
#endif /* _HEADER_INST_ */ |
|
396 |
||
397 |
#ifdef _HEADER_CLASS_ |
|
398 |
%(ClassVarList) |
|
399 |
#endif /* _HEADER_CLASS_ */ |
|
400 |
||
401 |
#ifdef _HEADER_CLASSINST_ |
|
402 |
%(ClassInstVarList) |
|
403 |
#endif /* _HEADER_CLASSINST_ */ |
|
404 |
'. |
|
405 |
newContents := template bindWithArguments:bindings. |
|
406 |
file := packageTargetDir asFilename / ((Smalltalk fileNameForClass:aClass),'.STH'). |
|
407 |
(file exists not |
|
408 |
or:[ (oldContents := file contents) ~= newContents ]) ifTrue:[ |
|
409 |
file contents: newContents. |
|
410 |
]. |
|
2614 | 411 |
! |
412 |
||
2644 | 413 |
generateSourceFiles |
414 |
sourceCodeManager notNil ifTrue:[ |
|
415 |
"/ check out / generate files there |
|
416 |
self generateSourceFilesByCheckingOutUsing:sourceCodeManager |
|
417 |
] ifFalse:[ |
|
418 |
"/ local build |
|
419 |
"/ fileout the project |
|
420 |
self generateSourceFilesByFilingOut |
|
421 |
] |
|
2599 | 422 |
! |
423 |
||
2644 | 424 |
generateSourceFilesByCheckingOutUsing:aSourceCodeManager |
425 |
"/ will no longer be needed/supported |
|
426 |
||
427 |
|repository stxRepository module directory| |
|
428 |
||
429 |
self halt. |
|
430 |
"/ check out / generate files there |
|
431 |
repository := (aSourceCodeManager repositoryNameForModule:module) ifNil:[aSourceCodeManager repositoryName]. |
|
432 |
stxRepository := aSourceCodeManager repositoryName. |
|
2600 | 433 |
|
2644 | 434 |
(buildDirectory construct:'stx') exists ifFalse:[ |
435 |
(module ~= 'stx') ifTrue:[ |
|
436 |
OperatingSystem |
|
437 |
executeCommand:('cvs -d ',stxRepository,' co stx') |
|
438 |
inputFrom:nil |
|
439 |
outputTo:Transcript |
|
440 |
errorTo:Transcript |
|
441 |
inDirectory:buildDirectory |
|
442 |
onError:[:status| self error:'cvs update stx failed']. |
|
443 |
]. |
|
444 |
]. |
|
2635 | 445 |
|
2644 | 446 |
((buildDirectory construct:module) construct:'CVS') exists ifFalse:[ |
447 |
OperatingSystem |
|
448 |
executeCommand:('cvs -d ',repository,' co -l ',directory) |
|
449 |
inputFrom:nil |
|
450 |
outputTo:Transcript |
|
451 |
errorTo:Transcript |
|
452 |
inDirectory:buildDirectory |
|
453 |
onError:[:status| self error:'cvs update failed']. |
|
454 |
]. |
|
455 |
OperatingSystem |
|
456 |
executeCommand:'cvs upd -d' |
|
457 |
inputFrom:nil |
|
458 |
outputTo:Transcript |
|
459 |
errorTo:Transcript |
|
460 |
inDirectory:(buildDirectory construct:module) |
|
461 |
onError:[:status| self error:'cvs update failed']. |
|
462 |
self halt. |
|
2600 | 463 |
! |
464 |
||
2644 | 465 |
generateSourceFilesByFilingOut |
466 |
"/ local build |
|
467 |
"/ fileout the project |
|
468 |
||
469 |
(package module ~= 'stx') ifTrue:[ |
|
470 |
(buildDirectory / package module) makeDirectory. |
|
471 |
]. |
|
472 |
||
473 |
"/ file out the package(s) which are to be built |
|
474 |
((Array with:package)) |
|
475 |
do:[:eachPackageToFileout | |
|
476 |
|packageId packageModule packageDirectory packageTargetDir packageDef| |
|
477 |
||
478 |
packageId := eachPackageToFileout asPackageId. |
|
479 |
packageModule := packageId module. |
|
480 |
packageDirectory := packageId directory. |
|
481 |
packageTargetDir := (buildDirectory / packageModule / packageDirectory) recursiveMakeDirectory. |
|
482 |
||
483 |
packageDef := packageId projectDefinitionClass. |
|
484 |
(packageDef compiled_classNames_common , |
|
485 |
packageDef compiled_classNamesForPlatform) do:[:eachClassName | |
|
486 |
|cls fileName newSource| |
|
487 |
||
488 |
cls := Smalltalk classNamed:eachClassName. |
|
489 |
self assert:cls isLoaded. |
|
490 |
fileName := (Smalltalk fileNameForClass:cls),'.st'. |
|
491 |
fileName := packageTargetDir asFilename construct:fileName. |
|
492 |
fileName exists ifTrue:[ |
|
493 |
newSource := String streamContents:[:s | cls fileOutOn:s withTimeStamp:false]. |
|
494 |
newSource = fileName contentsAsString ifFalse:[ |
|
495 |
fileName contents:newSource |
|
496 |
]. |
|
497 |
] ifFalse:[ |
|
498 |
cls fileOutIn:packageTargetDir withTimeStamp:false |
|
499 |
]. |
|
500 |
]. |
|
2596 | 501 |
|
2644 | 502 |
"/ (Smalltalk allClassesInPackage:eachPackageToFileout) do:[:cls | |
503 |
"/ cls isPrivate ifFalse:[ |
|
504 |
"/ cls isLoaded ifFalse:[ |
|
505 |
"/ self halt. |
|
506 |
"/ cls autoload. |
|
507 |
"/ ]. |
|
508 |
"/ cls fileOutIn:packageTargetDir |
|
509 |
"/ ] |
|
510 |
"/ ]. |
|
511 |
||
512 |
projectDefinitionClass forEachFileNameAndGeneratedContentsDo:[:fileName :fileContents | |
|
513 |
((packageTargetDir / fileName) exists |
|
514 |
and:[ (packageTargetDir / fileName) contents = fileContents ]) ifFalse:[ |
|
515 |
(packageTargetDir / fileName) contents:fileContents. |
|
516 |
]. |
|
517 |
]. |
|
518 |
]. |
|
2596 | 519 |
|
2644 | 520 |
"/ generate header files in prerequisite packages... |
521 |
(projectDefinitionClass allPreRequisites) |
|
522 |
do:[:eachPackageToFileout | |
|
523 |
|packageId packageDef packageModule packageDirectory packageTargetDir| |
|
524 |
||
525 |
packageId := eachPackageToFileout asPackageId. |
|
526 |
packageModule := packageId module. |
|
527 |
packageDirectory := packageId directory. |
|
528 |
packageTargetDir := (buildDirectory / packageModule / packageDirectory) recursiveMakeDirectory. |
|
529 |
||
530 |
packageDef := packageId projectDefinitionClass. |
|
531 |
(packageDef compiled_classNames_common , |
|
532 |
packageDef compiled_classNamesForPlatform) do:[:eachClassName | |
|
533 |
|cls| |
|
534 |
||
535 |
cls := Smalltalk classNamed:eachClassName. |
|
536 |
"/ self assert:cls isLoaded. |
|
537 |
cls isLoaded ifTrue:[ |
|
538 |
self createHeaderFileFor:cls in:packageTargetDir |
|
539 |
]. |
|
540 |
]. |
|
541 |
self copyResourcesForPackage:eachPackageToFileout. |
|
542 |
]. |
|
543 |
||
544 |
"/ stx_libbasic2 preRequisitesForBuilding#(#'stx:libbasic') |
|
2596 | 545 |
! |
546 |
||
2644 | 547 |
makeWithOutputTo:stdOut errorTo:stdErr |
548 |
|module directory| |
|
549 |
||
550 |
module := package module. |
|
551 |
directory := package directory. |
|
552 |
||
553 |
projectDefinitionClass isLibraryDefinition ifTrue:[ |
|
554 |
OperatingSystem |
|
555 |
executeCommand:(ParserFlags makeCommand,' classLibRule') |
|
556 |
inputFrom:nil |
|
557 |
outputTo:stdOut |
|
558 |
errorTo:stdErr |
|
559 |
inDirectory:(buildDirectory / module / directory) |
|
560 |
onError:[:status| self error:'make failed']. |
|
561 |
] ifFalse:[ |
|
562 |
OperatingSystem |
|
563 |
executeCommand:(ParserFlags makeCommand,' exe') |
|
564 |
inputFrom:nil |
|
565 |
outputTo:stdOut |
|
566 |
errorTo:stdErr |
|
567 |
inDirectory:(buildDirectory / module / directory) |
|
568 |
onError:[:status| self error:'make failed']. |
|
569 |
||
2673 | 570 |
(makeExeOnly ? false) ifFalse:[ |
571 |
OperatingSystem |
|
572 |
executeCommand:(ParserFlags makeCommand,' setup') |
|
573 |
inputFrom:nil |
|
574 |
outputTo:stdOut |
|
575 |
errorTo:stdErr |
|
576 |
inDirectory:(buildDirectory / module / directory) |
|
577 |
onError:[:status| self error:'make failed']. |
|
578 |
] |
|
2644 | 579 |
] |
2596 | 580 |
! |
581 |
||
2644 | 582 |
setupBuildDirectory |
583 |
buildDirectory exists ifFalse:[ |
|
584 |
buildDirectory recursiveMakeDirectory. |
|
585 |
]. |
|
586 |
(buildDirectory / 'stx') exists ifFalse:[ |
|
587 |
(buildDirectory / 'stx') makeDirectory. |
|
588 |
]. |
|
589 |
||
590 |
self copyDirectoryForBuild:'include'. |
|
591 |
self copyDirectoryForBuild:'rules'. |
|
2611 | 592 |
! |
593 |
||
2644 | 594 |
validateBuildDirectoryIsPresent |
595 |
||
596 |
^ self. |
|
2596 | 597 |
|
2644 | 598 |
"/ [ |
599 |
"/ |default directoryIsOKForMe stc | |
|
600 |
"/ |
|
601 |
"/ default := (buildDirectory ? |
|
602 |
"/ PreviousBuildDirectory) |
|
603 |
"/ ifNil:[ UserPreferences current buildDirectory]. |
|
604 |
"/ |
|
605 |
"/ buildDirectory := Dialog requestDirectoryName:'Temporary Work-ROOT for build:' |
|
606 |
"/ default:default. |
|
607 |
"/ |
|
608 |
"/ buildDirectory isEmptyOrNil ifTrue:[^ self]. |
|
609 |
"/ buildDirectory := buildDirectory asFilename. |
|
610 |
"/ directoryIsOKForMe := true. |
|
611 |
"/ |
|
612 |
"/ buildDirectory exists ifFalse:[ |
|
613 |
"/ Dialog warn:(self classResources string:'Work directory %1 does not exist.' with:buildDirectory). |
|
614 |
"/ directoryIsOKForMe := false. |
|
615 |
"/ ] ifTrue:[ |
|
616 |
"/ (buildDirectory construct:'stx') exists ifFalse:[ |
|
617 |
"/ Dialog warn:(self classResources stringWithCRs:'Work directory must contain an stx subDirectory,\which contains (at least) the stc and include subdirectories.'). |
|
618 |
"/ directoryIsOKForMe := false. |
|
619 |
"/ ] ifTrue:[ |
|
620 |
"/ stc := (OperatingSystem isMSDOSlike) ifTrue:['stc.exe'] ifFalse:['stc']. |
|
621 |
"/ (((buildDirectory construct:'stx')construct:'stc')construct:stc) exists ifFalse:[ |
|
622 |
"/ Dialog warn:(self classResources stringWithCRs:'Work directory must contain an stc compiler in the stx/stc subDirectory.'). |
|
623 |
"/ directoryIsOKForMe := false. |
|
624 |
"/ ]. |
|
625 |
"/ ((buildDirectory construct:'stx')construct:'include') exists ifFalse:[ |
|
626 |
"/ Dialog warn:(self classResources stringWithCRs:'Work directory must have had a make run before (for include files to exists).'). |
|
627 |
"/ directoryIsOKForMe := false. |
|
628 |
"/ ]. |
|
629 |
"/ ] |
|
630 |
"/ ]. |
|
631 |
"/ directoryIsOKForMe |
|
632 |
"/ ] whileFalse |
|
2596 | 633 |
! ! |
634 |
||
635 |
!ProjectBuilder class methodsFor:'documentation'! |
|
636 |
||
637 |
version_CVS |
|
638 |
^ '$Header$' |
|
639 |
! ! |