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