author | Claus Gittinger <cg@exept.de> |
Thu, 22 Oct 2009 23:27:57 +0200 | |
changeset 2677 | e2c24a1be97f |
parent 2673 | 100b4dd5c3c2 |
child 2678 | cca2788228ad |
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 |
]. |
|
2677
e2c24a1be97f
changed: #copySupportFilesForLinkage
Claus Gittinger <cg@exept.de>
parents:
2673
diff
changeset
|
338 |
files := files asOrderedCollection. |
e2c24a1be97f
changed: #copySupportFilesForLinkage
Claus Gittinger <cg@exept.de>
parents:
2673
diff
changeset
|
339 |
|
e2c24a1be97f
changed: #copySupportFilesForLinkage
Claus Gittinger <cg@exept.de>
parents:
2673
diff
changeset
|
340 |
OperatingSystem isMSWINDOWSlike ifTrue:[ |
e2c24a1be97f
changed: #copySupportFilesForLinkage
Claus Gittinger <cg@exept.de>
parents:
2673
diff
changeset
|
341 |
projectDefinitionClass applicationIconFileName notNil ifTrue:[ |
e2c24a1be97f
changed: #copySupportFilesForLinkage
Claus Gittinger <cg@exept.de>
parents:
2673
diff
changeset
|
342 |
files add:(projectDefinitionClass applicationIconFileName,'.ico') |
e2c24a1be97f
changed: #copySupportFilesForLinkage
Claus Gittinger <cg@exept.de>
parents:
2673
diff
changeset
|
343 |
] |
e2c24a1be97f
changed: #copySupportFilesForLinkage
Claus Gittinger <cg@exept.de>
parents:
2673
diff
changeset
|
344 |
]. |
2644 | 345 |
|
346 |
files do:[:dllRelativePath | |
|
347 |
((buildDirectory / 'stx' / dllRelativePath) exists |
|
348 |
and:[ (mySTXTopDirectory / dllRelativePath) fileSize = (buildDirectory / 'stx' / dllRelativePath) fileSize |
|
349 |
and:[ (mySTXTopDirectory / dllRelativePath) modificationTime < (buildDirectory / 'stx' / dllRelativePath) modificationTime |
|
350 |
"/ and:[ (mySTXTopDirectory / dllRelativePath) sameContentsAs:(targetBuildDir / dllRelativePath) ] |
|
351 |
]]) ifFalse:[ |
|
352 |
(buildDirectory / 'stx' / dllRelativePath) directory recursiveMakeDirectory. |
|
353 |
(mySTXTopDirectory / dllRelativePath) copyTo:(buildDirectory / 'stx' / dllRelativePath). |
|
2614 | 354 |
] |
355 |
]. |
|
2600 | 356 |
! |
357 |
||
2644 | 358 |
createHeaderFileFor:aClass in:packageTargetDir |
359 |
|instVarList classInstVarList classVarList bindings superclassFilename |
|
360 |
template file newContents oldContents| |
|
361 |
||
362 |
instVarList := StringCollection new. |
|
363 |
aClass instVarNames do:[:v | |
|
364 |
instVarList add:('OBJ %1;' bindWith:v) |
|
365 |
]. |
|
366 |
classInstVarList := StringCollection new. |
|
367 |
aClass class instVarNames do:[:v | |
|
368 |
(v includes:$_) ifTrue:[self halt]. |
|
369 |
classInstVarList add:('OBJ %1;' bindWith:v) |
|
370 |
]. |
|
371 |
classVarList := StringCollection new. |
|
372 |
aClass classVarNames do:[:v | |
|
373 |
classVarList add:('extern OBJ %1_%2;' bindWith:aClass name with:v) |
|
374 |
]. |
|
2614 | 375 |
|
2644 | 376 |
bindings := Dictionary new. |
377 |
bindings at:'ClassName' put:aClass name. |
|
378 |
aClass superclass isNil ifTrue:[ |
|
379 |
bindings at:'SuperclassName' put:'-'. |
|
380 |
bindings at:'SuperclassFileInclude' put:nil. |
|
381 |
] ifFalse:[ |
|
382 |
bindings at:'SuperclassName' put:aClass superclass name. |
|
383 |
bindings at:'SuperclassFileName' put:(superclassFilename := Smalltalk fileNameForClass:aClass superclass). |
|
384 |
bindings at:'SuperclassFileInclude' put:('#include "%1.STH"' bindWith:superclassFilename). |
|
385 |
]. |
|
386 |
bindings at:'InstVarList' put:instVarList asString. |
|
387 |
bindings at:'ClassVarList' put:classVarList asString. |
|
388 |
bindings at:'ClassInstVarList' put:classInstVarList asString. |
|
389 |
||
390 |
template := |
|
391 |
'/* This file was generated by ProjectBuilder. */ |
|
392 |
/* !!!!!!!! Do not change by hand !!!!!!!! */ |
|
393 |
||
394 |
/* Class: %(ClassName) */ |
|
395 |
/* Superclass: %(SuperclassName) */ |
|
396 |
||
397 |
%(SuperclassFileInclude) |
|
398 |
||
399 |
/* INDIRECTGLOBALS */ |
|
400 |
#ifdef _HEADER_INST_ |
|
401 |
%(InstVarList) |
|
402 |
#endif /* _HEADER_INST_ */ |
|
403 |
||
404 |
#ifdef _HEADER_CLASS_ |
|
405 |
%(ClassVarList) |
|
406 |
#endif /* _HEADER_CLASS_ */ |
|
407 |
||
408 |
#ifdef _HEADER_CLASSINST_ |
|
409 |
%(ClassInstVarList) |
|
410 |
#endif /* _HEADER_CLASSINST_ */ |
|
411 |
'. |
|
412 |
newContents := template bindWithArguments:bindings. |
|
413 |
file := packageTargetDir asFilename / ((Smalltalk fileNameForClass:aClass),'.STH'). |
|
414 |
(file exists not |
|
415 |
or:[ (oldContents := file contents) ~= newContents ]) ifTrue:[ |
|
416 |
file contents: newContents. |
|
417 |
]. |
|
2614 | 418 |
! |
419 |
||
2644 | 420 |
generateSourceFiles |
421 |
sourceCodeManager notNil ifTrue:[ |
|
422 |
"/ check out / generate files there |
|
423 |
self generateSourceFilesByCheckingOutUsing:sourceCodeManager |
|
424 |
] ifFalse:[ |
|
425 |
"/ local build |
|
426 |
"/ fileout the project |
|
427 |
self generateSourceFilesByFilingOut |
|
428 |
] |
|
2599 | 429 |
! |
430 |
||
2644 | 431 |
generateSourceFilesByCheckingOutUsing:aSourceCodeManager |
432 |
"/ will no longer be needed/supported |
|
433 |
||
434 |
|repository stxRepository module directory| |
|
435 |
||
436 |
self halt. |
|
437 |
"/ check out / generate files there |
|
438 |
repository := (aSourceCodeManager repositoryNameForModule:module) ifNil:[aSourceCodeManager repositoryName]. |
|
439 |
stxRepository := aSourceCodeManager repositoryName. |
|
2600 | 440 |
|
2644 | 441 |
(buildDirectory construct:'stx') exists ifFalse:[ |
442 |
(module ~= 'stx') ifTrue:[ |
|
443 |
OperatingSystem |
|
444 |
executeCommand:('cvs -d ',stxRepository,' co stx') |
|
445 |
inputFrom:nil |
|
446 |
outputTo:Transcript |
|
447 |
errorTo:Transcript |
|
448 |
inDirectory:buildDirectory |
|
449 |
onError:[:status| self error:'cvs update stx failed']. |
|
450 |
]. |
|
451 |
]. |
|
2635 | 452 |
|
2644 | 453 |
((buildDirectory construct:module) construct:'CVS') exists ifFalse:[ |
454 |
OperatingSystem |
|
455 |
executeCommand:('cvs -d ',repository,' co -l ',directory) |
|
456 |
inputFrom:nil |
|
457 |
outputTo:Transcript |
|
458 |
errorTo:Transcript |
|
459 |
inDirectory:buildDirectory |
|
460 |
onError:[:status| self error:'cvs update failed']. |
|
461 |
]. |
|
462 |
OperatingSystem |
|
463 |
executeCommand:'cvs upd -d' |
|
464 |
inputFrom:nil |
|
465 |
outputTo:Transcript |
|
466 |
errorTo:Transcript |
|
467 |
inDirectory:(buildDirectory construct:module) |
|
468 |
onError:[:status| self error:'cvs update failed']. |
|
469 |
self halt. |
|
2600 | 470 |
! |
471 |
||
2644 | 472 |
generateSourceFilesByFilingOut |
473 |
"/ local build |
|
474 |
"/ fileout the project |
|
475 |
||
476 |
(package module ~= 'stx') ifTrue:[ |
|
477 |
(buildDirectory / package module) makeDirectory. |
|
478 |
]. |
|
479 |
||
480 |
"/ file out the package(s) which are to be built |
|
481 |
((Array with:package)) |
|
482 |
do:[:eachPackageToFileout | |
|
483 |
|packageId packageModule packageDirectory packageTargetDir packageDef| |
|
484 |
||
485 |
packageId := eachPackageToFileout asPackageId. |
|
486 |
packageModule := packageId module. |
|
487 |
packageDirectory := packageId directory. |
|
488 |
packageTargetDir := (buildDirectory / packageModule / packageDirectory) recursiveMakeDirectory. |
|
489 |
||
490 |
packageDef := packageId projectDefinitionClass. |
|
491 |
(packageDef compiled_classNames_common , |
|
492 |
packageDef compiled_classNamesForPlatform) do:[:eachClassName | |
|
493 |
|cls fileName newSource| |
|
494 |
||
495 |
cls := Smalltalk classNamed:eachClassName. |
|
496 |
self assert:cls isLoaded. |
|
497 |
fileName := (Smalltalk fileNameForClass:cls),'.st'. |
|
498 |
fileName := packageTargetDir asFilename construct:fileName. |
|
499 |
fileName exists ifTrue:[ |
|
500 |
newSource := String streamContents:[:s | cls fileOutOn:s withTimeStamp:false]. |
|
501 |
newSource = fileName contentsAsString ifFalse:[ |
|
502 |
fileName contents:newSource |
|
503 |
]. |
|
504 |
] ifFalse:[ |
|
505 |
cls fileOutIn:packageTargetDir withTimeStamp:false |
|
506 |
]. |
|
507 |
]. |
|
2596 | 508 |
|
2644 | 509 |
"/ (Smalltalk allClassesInPackage:eachPackageToFileout) do:[:cls | |
510 |
"/ cls isPrivate ifFalse:[ |
|
511 |
"/ cls isLoaded ifFalse:[ |
|
512 |
"/ self halt. |
|
513 |
"/ cls autoload. |
|
514 |
"/ ]. |
|
515 |
"/ cls fileOutIn:packageTargetDir |
|
516 |
"/ ] |
|
517 |
"/ ]. |
|
518 |
||
519 |
projectDefinitionClass forEachFileNameAndGeneratedContentsDo:[:fileName :fileContents | |
|
520 |
((packageTargetDir / fileName) exists |
|
521 |
and:[ (packageTargetDir / fileName) contents = fileContents ]) ifFalse:[ |
|
522 |
(packageTargetDir / fileName) contents:fileContents. |
|
523 |
]. |
|
524 |
]. |
|
525 |
]. |
|
2596 | 526 |
|
2644 | 527 |
"/ generate header files in prerequisite packages... |
528 |
(projectDefinitionClass allPreRequisites) |
|
529 |
do:[:eachPackageToFileout | |
|
530 |
|packageId packageDef packageModule packageDirectory packageTargetDir| |
|
531 |
||
532 |
packageId := eachPackageToFileout asPackageId. |
|
533 |
packageModule := packageId module. |
|
534 |
packageDirectory := packageId directory. |
|
535 |
packageTargetDir := (buildDirectory / packageModule / packageDirectory) recursiveMakeDirectory. |
|
536 |
||
537 |
packageDef := packageId projectDefinitionClass. |
|
538 |
(packageDef compiled_classNames_common , |
|
539 |
packageDef compiled_classNamesForPlatform) do:[:eachClassName | |
|
540 |
|cls| |
|
541 |
||
542 |
cls := Smalltalk classNamed:eachClassName. |
|
543 |
"/ self assert:cls isLoaded. |
|
544 |
cls isLoaded ifTrue:[ |
|
545 |
self createHeaderFileFor:cls in:packageTargetDir |
|
546 |
]. |
|
547 |
]. |
|
548 |
self copyResourcesForPackage:eachPackageToFileout. |
|
549 |
]. |
|
550 |
||
551 |
"/ stx_libbasic2 preRequisitesForBuilding#(#'stx:libbasic') |
|
2596 | 552 |
! |
553 |
||
2644 | 554 |
makeWithOutputTo:stdOut errorTo:stdErr |
555 |
|module directory| |
|
556 |
||
557 |
module := package module. |
|
558 |
directory := package directory. |
|
559 |
||
560 |
projectDefinitionClass isLibraryDefinition ifTrue:[ |
|
561 |
OperatingSystem |
|
562 |
executeCommand:(ParserFlags makeCommand,' classLibRule') |
|
563 |
inputFrom:nil |
|
564 |
outputTo:stdOut |
|
565 |
errorTo:stdErr |
|
566 |
inDirectory:(buildDirectory / module / directory) |
|
567 |
onError:[:status| self error:'make failed']. |
|
568 |
] ifFalse:[ |
|
569 |
OperatingSystem |
|
570 |
executeCommand:(ParserFlags makeCommand,' exe') |
|
571 |
inputFrom:nil |
|
572 |
outputTo:stdOut |
|
573 |
errorTo:stdErr |
|
574 |
inDirectory:(buildDirectory / module / directory) |
|
575 |
onError:[:status| self error:'make failed']. |
|
576 |
||
2673 | 577 |
(makeExeOnly ? false) ifFalse:[ |
578 |
OperatingSystem |
|
579 |
executeCommand:(ParserFlags makeCommand,' setup') |
|
580 |
inputFrom:nil |
|
581 |
outputTo:stdOut |
|
582 |
errorTo:stdErr |
|
583 |
inDirectory:(buildDirectory / module / directory) |
|
584 |
onError:[:status| self error:'make failed']. |
|
585 |
] |
|
2644 | 586 |
] |
2596 | 587 |
! |
588 |
||
2644 | 589 |
setupBuildDirectory |
590 |
buildDirectory exists ifFalse:[ |
|
591 |
buildDirectory recursiveMakeDirectory. |
|
592 |
]. |
|
593 |
(buildDirectory / 'stx') exists ifFalse:[ |
|
594 |
(buildDirectory / 'stx') makeDirectory. |
|
595 |
]. |
|
596 |
||
597 |
self copyDirectoryForBuild:'include'. |
|
598 |
self copyDirectoryForBuild:'rules'. |
|
2611 | 599 |
! |
600 |
||
2644 | 601 |
validateBuildDirectoryIsPresent |
602 |
||
603 |
^ self. |
|
2596 | 604 |
|
2644 | 605 |
"/ [ |
606 |
"/ |default directoryIsOKForMe stc | |
|
607 |
"/ |
|
608 |
"/ default := (buildDirectory ? |
|
609 |
"/ PreviousBuildDirectory) |
|
610 |
"/ ifNil:[ UserPreferences current buildDirectory]. |
|
611 |
"/ |
|
612 |
"/ buildDirectory := Dialog requestDirectoryName:'Temporary Work-ROOT for build:' |
|
613 |
"/ default:default. |
|
614 |
"/ |
|
615 |
"/ buildDirectory isEmptyOrNil ifTrue:[^ self]. |
|
616 |
"/ buildDirectory := buildDirectory asFilename. |
|
617 |
"/ directoryIsOKForMe := true. |
|
618 |
"/ |
|
619 |
"/ buildDirectory exists ifFalse:[ |
|
620 |
"/ Dialog warn:(self classResources string:'Work directory %1 does not exist.' with:buildDirectory). |
|
621 |
"/ directoryIsOKForMe := false. |
|
622 |
"/ ] ifTrue:[ |
|
623 |
"/ (buildDirectory construct:'stx') exists ifFalse:[ |
|
624 |
"/ Dialog warn:(self classResources stringWithCRs:'Work directory must contain an stx subDirectory,\which contains (at least) the stc and include subdirectories.'). |
|
625 |
"/ directoryIsOKForMe := false. |
|
626 |
"/ ] ifTrue:[ |
|
627 |
"/ stc := (OperatingSystem isMSDOSlike) ifTrue:['stc.exe'] ifFalse:['stc']. |
|
628 |
"/ (((buildDirectory construct:'stx')construct:'stc')construct:stc) exists ifFalse:[ |
|
629 |
"/ Dialog warn:(self classResources stringWithCRs:'Work directory must contain an stc compiler in the stx/stc subDirectory.'). |
|
630 |
"/ directoryIsOKForMe := false. |
|
631 |
"/ ]. |
|
632 |
"/ ((buildDirectory construct:'stx')construct:'include') exists ifFalse:[ |
|
633 |
"/ Dialog warn:(self classResources stringWithCRs:'Work directory must have had a make run before (for include files to exists).'). |
|
634 |
"/ directoryIsOKForMe := false. |
|
635 |
"/ ]. |
|
636 |
"/ ] |
|
637 |
"/ ]. |
|
638 |
"/ directoryIsOKForMe |
|
639 |
"/ ] whileFalse |
|
2596 | 640 |
! ! |
641 |
||
642 |
!ProjectBuilder class methodsFor:'documentation'! |
|
643 |
||
644 |
version_CVS |
|
645 |
^ '$Header$' |
|
646 |
! ! |