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