author | Stefan Vogel <sv@exept.de> |
Mon, 29 Jul 2013 16:08:48 +0200 | |
changeset 3240 | 60e8fa24bbc6 |
parent 3173 | 5b547821eb61 |
child 3348 | b59a15a24ab3 |
permissions | -rw-r--r-- |
1669 | 1 |
" |
2 |
COPYRIGHT (c) 1989 by Claus Gittinger |
|
3 |
COPYRIGHT (c) 2006 by eXept Software AG |
|
4 |
All Rights Reserved |
|
5 |
||
6 |
This software is furnished under a license and may be used |
|
7 |
only in accordance with the terms of that license and with the |
|
8 |
inclusion of the above copyright notice. This software may not |
|
9 |
be provided or otherwise made available to, or used by, any |
|
10 |
other person. No title to or ownership of the software is |
|
11 |
hereby transferred. |
|
12 |
" |
|
13 |
"{ Package: 'stx:libcomp' }" |
|
14 |
||
15 |
Object subclass:#STCCompilerInterface |
|
3240 | 16 |
instanceVariableNames:'originator parserFlags initName theNonMetaclassToCompileFor |
17 |
classToCompileFor stFileName cFileName oFileName stcFlags cFlags |
|
18 |
stcPath ccPath requestor methodCategory executionStatus package' |
|
19 |
classVariableNames:'SequenceNumber Verbose KeepIntermediateFiles' |
|
20 |
poolDictionaries:'' |
|
21 |
category:'System-Compiler' |
|
1669 | 22 |
! |
23 |
||
24 |
!STCCompilerInterface class methodsFor:'documentation'! |
|
25 |
||
26 |
copyright |
|
27 |
" |
|
28 |
COPYRIGHT (c) 1989 by Claus Gittinger |
|
29 |
COPYRIGHT (c) 2006 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 |
! |
|
40 |
||
41 |
documentation |
|
42 |
" |
|
43 |
a refactored complex method - originally found in ByteCodeCompiler. |
|
44 |
" |
|
45 |
! ! |
|
46 |
||
47 |
!STCCompilerInterface class methodsFor:'accessing'! |
|
48 |
||
49 |
stcPathOf:command |
|
50 |
"return the path to an stc command, or nil if not found." |
|
51 |
||
52 |
|f d reqdSuffix cmd| |
|
53 |
||
54 |
"/ |
|
55 |
"/ care for executable suffix |
|
56 |
"/ |
|
57 |
cmd := command. |
|
58 |
OperatingSystem isMSDOSlike ifTrue:[ |
|
59 |
reqdSuffix := 'exe' |
|
60 |
] ifFalse:[ |
|
61 |
OperatingSystem isVMSlike ifTrue:[ |
|
62 |
reqdSuffix := 'EXE' |
|
63 |
]. |
|
64 |
]. |
|
65 |
reqdSuffix notNil ifTrue:[ |
|
66 |
(f := cmd asFilename) suffix isEmpty ifTrue:[ |
|
67 |
cmd := (f withSuffix:reqdSuffix) name |
|
68 |
] |
|
69 |
]. |
|
70 |
"/ |
|
71 |
"/ for our convenience, also check in current |
|
72 |
"/ and parent directories; even if PATH does not |
|
73 |
"/ include them ... |
|
74 |
"/ |
|
75 |
"/ look in current ... |
|
76 |
d := Filename currentDirectory. |
|
77 |
(f := d construct:cmd) isExecutable ifTrue:[ |
|
78 |
^ f pathName |
|
79 |
]. |
|
80 |
"/ look in ../stc ... |
|
81 |
d := d construct:'..'. |
|
82 |
(f := (d construct:'stc') construct:cmd) isExecutable ifTrue:[ |
|
83 |
^ f pathName |
|
84 |
]. |
|
85 |
"/ look in ../../stc ... |
|
86 |
d := d construct:'..'. |
|
87 |
(f := (d construct:'stc') construct:cmd) isExecutable ifTrue:[ |
|
88 |
^ f pathName |
|
89 |
]. |
|
90 |
||
91 |
"/ |
|
92 |
"/ ok, stc must be installed in some directory along the PATH |
|
93 |
"/ |
|
94 |
^ OperatingSystem pathOfCommand:command |
|
95 |
||
96 |
" |
|
97 |
STCCompilerInterface stcPathOf:'stc' |
|
98 |
" |
|
99 |
||
100 |
"Created: 13.9.1995 / 14:37:16 / claus" |
|
3173 | 101 |
! |
102 |
||
103 |
verbose |
|
104 |
"if on, trace command execution on the Transcript" |
|
105 |
||
106 |
^ Verbose |
|
107 |
! |
|
108 |
||
109 |
verbose:aBoolean |
|
110 |
"if on, trace command execution on the Transcript" |
|
111 |
||
112 |
Verbose := aBoolean |
|
1669 | 113 |
! ! |
114 |
||
115 |
!STCCompilerInterface class methodsFor:'class initialization'! |
|
116 |
||
117 |
initialize |
|
118 |
Verbose := false. |
|
119 |
! ! |
|
120 |
||
121 |
!STCCompilerInterface methodsFor:'accessing'! |
|
122 |
||
2335 | 123 |
cFileName:something |
124 |
cFileName := something. |
|
125 |
! |
|
126 |
||
1669 | 127 |
incrementalStcPath |
128 |
"return the path to the stc command for incremental method compilation, |
|
129 |
or nil if not found." |
|
130 |
||
131 |
|f cmd| |
|
132 |
||
133 |
(cmd := parserFlags stcPath) isEmptyOrNil ifTrue:[ |
|
134 |
(f := self class stcPathOf:'stc') notNil ifTrue:[ |
|
135 |
cmd := f |
|
136 |
] ifFalse:[ |
|
137 |
cmd := self class stcPathOf:'demostc' |
|
138 |
] |
|
139 |
]. |
|
140 |
(cmd notNil and:[cmd includes:Character space]) ifTrue:[ |
|
141 |
cmd := '"' , cmd , '"'. |
|
142 |
]. |
|
143 |
^ cmd |
|
144 |
||
145 |
"Created: 13.9.1995 / 14:36:36 / claus" |
|
146 |
"Modified: 13.9.1995 / 15:15:04 / claus" |
|
147 |
! |
|
148 |
||
149 |
originator:something |
|
150 |
originator := something. |
|
151 |
! |
|
152 |
||
153 |
parserFlags:something |
|
154 |
parserFlags := something. |
|
2335 | 155 |
! |
156 |
||
157 |
stFileName:something |
|
158 |
stFileName := something. |
|
1669 | 159 |
! ! |
160 |
||
161 |
!STCCompilerInterface methodsFor:'machine code generation'! |
|
162 |
||
1939 | 163 |
compileToMachineCode:aString forClass:aClass selector:selector inCategory:categoryArg |
164 |
notifying:requestorArg install:install skipIfSame:skipIfSame silent:silent |
|
1669 | 165 |
"this is called to compile primitive code. |
166 |
This is EXPERIMENTAL and going to be changed to raise an error, |
|
167 |
an redefined in subclasses which can do it (either by direct compilation, or by calling |
|
1939 | 168 |
the external stc do do it)." |
1669 | 169 |
|
3042 | 170 |
|handle oldMethod newMethod ok dllFileName| |
1669 | 171 |
|
172 |
install ifFalse:[ |
|
173 |
"/ cannot do it uninstalled. reason: |
|
174 |
"/ if it is loaded twice, the first version could be unloaded by |
|
175 |
"/ finalization, which would also unload the second version |
|
176 |
"/ (because the first unload would unload the second version too) |
|
177 |
^ #CannotLoad |
|
178 |
]. |
|
2704
19bedf5ff15e
changed: #compileToMachineCode:forClass:selector:inCategory:notifying:install:skipIfSame:silent:
Claus Gittinger <cg@exept.de>
parents:
2703
diff
changeset
|
179 |
parserFlags isNil ifTrue:[ |
19bedf5ff15e
changed: #compileToMachineCode:forClass:selector:inCategory:notifying:install:skipIfSame:silent:
Claus Gittinger <cg@exept.de>
parents:
2703
diff
changeset
|
180 |
parserFlags := ParserFlags new |
19bedf5ff15e
changed: #compileToMachineCode:forClass:selector:inCategory:notifying:install:skipIfSame:silent:
Claus Gittinger <cg@exept.de>
parents:
2703
diff
changeset
|
181 |
]. |
1669 | 182 |
parserFlags stcCompilation == #never ifTrue:[^ #CannotLoad]. |
1670 | 183 |
|
1939 | 184 |
classToCompileFor := aClass. |
185 |
requestor := requestorArg. |
|
186 |
methodCategory := categoryArg. |
|
1669 | 187 |
|
1939 | 188 |
self ensureModuleDirectoryExists. |
189 |
self ensureExternalToolsArePresent ifFalse:[^ #CannotLoad]. |
|
1669 | 190 |
|
1939 | 191 |
theNonMetaclassToCompileFor := classToCompileFor theNonMetaclass. |
1941 | 192 |
|
1939 | 193 |
self ensureSuperClassesAreLoadedOf:theNonMetaclassToCompileFor. |
194 |
theNonMetaclassToCompileFor privateClassesSorted do:[:aPrivateClass | |
|
1670 | 195 |
self ensureSuperClassesAreLoadedOf:aPrivateClass. |
196 |
]. |
|
197 |
||
1939 | 198 |
(classToCompileFor isNil |
199 |
or:[parserFlags allowExtensionsToPrivateClasses |
|
200 |
or:[classToCompileFor owningClass isNil]]) ifTrue:[ |
|
201 |
(requestor respondsTo:#packageToInstall) ifFalse:[ |
|
202 |
package := Class packageQuerySignal query. |
|
203 |
] ifTrue:[ |
|
204 |
package := requestor packageToInstall |
|
205 |
]. |
|
206 |
] ifFalse:[ |
|
207 |
package := classToCompileFor owningClass package |
|
1669 | 208 |
]. |
209 |
||
210 |
[ |
|
1939 | 211 |
self generateSTSource:aString. |
212 |
self setupCompilationCommandArguments. |
|
213 |
ok := self compileToC. |
|
3042 | 214 |
ok ifFalse:[ |
215 |
self reportCompilationErrorFor:stcPath. |
|
216 |
^ #Error |
|
1669 | 217 |
]. |
218 |
||
3042 | 219 |
parserFlags stcKeepSIntermediate ifTrue:[ self compileToS ]. |
220 |
"/ now compile to machine code |
|
221 |
ok := self compileToObj. |
|
1669 | 222 |
ok ifFalse:[ |
3005 | 223 |
self reportCompilationErrorFor:ccPath. |
1669 | 224 |
^ #Error |
225 |
]. |
|
226 |
||
227 |
originator activityNotification:''. |
|
228 |
OperatingSystem removeFile:'errorOutput'. |
|
229 |
||
230 |
" |
|
231 |
if required, make a shared or otherwise loadable object file for it |
|
232 |
" |
|
233 |
originator activityNotification:'linking'. |
|
2656 | 234 |
dllFileName := ObjectFileLoader createLoadableObjectFor:(oFileName asFilename withoutSuffix name). |
235 |
dllFileName isNil ifTrue:[ |
|
1669 | 236 |
"/ something went wrong |
237 |
originator parseError:('link error: ' , ObjectFileLoader lastError) position:1. |
|
238 |
^ #CannotLoad |
|
239 |
]. |
|
2656 | 240 |
dllFileName asFilename exists ifFalse:[ |
1669 | 241 |
originator parseError:'link failed - cannot create machine code' position:1. |
242 |
^ #CannotLoad |
|
243 |
]. |
|
244 |
||
1939 | 245 |
oldMethod := classToCompileFor compiledMethodAt:selector. |
246 |
oldMethod notNil ifTrue:[package := oldMethod package]. |
|
3159 | 247 |
install ifTrue:[ |
248 |
(Smalltalk |
|
249 |
changeRequest:#methodInClass |
|
250 |
with:(Array with:classToCompileFor with:selector with:oldMethod)) ifFalse:[ |
|
251 |
^ #CannotLoad |
|
252 |
]. |
|
253 |
]. |
|
1669 | 254 |
|
255 |
" |
|
256 |
load the method objectfile |
|
257 |
" |
|
258 |
originator activityNotification:'loading'. |
|
259 |
||
2656 | 260 |
handle := ObjectFileLoader loadMethodObjectFile:dllFileName. |
1669 | 261 |
handle isNil ifTrue:[ |
3173 | 262 |
KeepIntermediateFiles ~~ true ifTrue:[ OperatingSystem removeFile:dllFileName ]. |
2185
cb311d08a486
changed #compileToMachineCode:forClass:selector:inCategory:notifying:install:skipIfSame:silent:
Stefan Vogel <sv@exept.de>
parents:
2068
diff
changeset
|
263 |
"catch, so that #CannotLoad processing is done" |
3069 | 264 |
ParseError catch:[ |
2185
cb311d08a486
changed #compileToMachineCode:forClass:selector:inCategory:notifying:install:skipIfSame:silent:
Stefan Vogel <sv@exept.de>
parents:
2068
diff
changeset
|
265 |
originator parseError:'dynamic load of machine code failed' position:1. |
cb311d08a486
changed #compileToMachineCode:forClass:selector:inCategory:notifying:install:skipIfSame:silent:
Stefan Vogel <sv@exept.de>
parents:
2068
diff
changeset
|
266 |
]. |
1669 | 267 |
^ #CannotLoad |
268 |
]. |
|
269 |
||
270 |
" |
|
271 |
did it work ? |
|
272 |
" |
|
1939 | 273 |
newMethod := classToCompileFor compiledMethodAt:selector. |
1669 | 274 |
|
275 |
"/ if install is false, we have to undo the install (which is always done, when loading machine code) |
|
276 |
install ifFalse:[ |
|
277 |
oldMethod isNil ifTrue:[ |
|
1939 | 278 |
classToCompileFor removeSelector:selector |
1669 | 279 |
] ifFalse:[ |
280 |
newMethod setPackage:oldMethod package. |
|
1939 | 281 |
classToCompileFor addSelector:selector withMethod:oldMethod. |
282 |
oldMethod setPackage:package. |
|
1669 | 283 |
] |
284 |
]. |
|
285 |
||
286 |
newMethod notNil ifTrue:[ |
|
287 |
handle method ~~ newMethod ifTrue:[ |
|
288 |
'Compiler [warning]: loaded method installed itself in another class' errorPrintCR. |
|
289 |
]. |
|
290 |
||
291 |
newMethod source:aString string. |
|
1939 | 292 |
newMethod setPackage:package. |
1669 | 293 |
"/ Project notNil ifTrue:[ |
294 |
"/ newMethod package:(Project currentPackageName) |
|
295 |
"/ ]. |
|
296 |
||
1939 | 297 |
"/ classToCompileFor updateRevisionString. |
1669 | 298 |
install ifTrue:[ |
1939 | 299 |
classToCompileFor addChangeRecordForMethod:newMethod fromOld:oldMethod. |
1669 | 300 |
|
301 |
"/ kludge-sigh: must send change messages manually here (stc-loaded code does not do it) |
|
302 |
"/ see addMethod:... in ClassDescription |
|
1939 | 303 |
classToCompileFor changed:#methodDictionary with:(Array with:selector with:oldMethod). |
304 |
Smalltalk changed:#methodInClass with:(Array with:classToCompileFor with:selector with:oldMethod). |
|
2350
16caba266df4
changed: #compileToMachineCode:forClass:selector:inCategory:notifying:install:skipIfSame:silent:
Stefan Vogel <sv@exept.de>
parents:
2336
diff
changeset
|
305 |
] ifFalse:[ |
16caba266df4
changed: #compileToMachineCode:forClass:selector:inCategory:notifying:install:skipIfSame:silent:
Stefan Vogel <sv@exept.de>
parents:
2336
diff
changeset
|
306 |
oldMethod := nil. |
1669 | 307 |
]. |
308 |
||
1986 | 309 |
silent ifFalse:[ |
1941 | 310 |
Transcript showCR:(' compiled: ', aClass name,' ',selector,' - machine code') |
1669 | 311 |
]. |
312 |
ObjectMemory flushCaches. |
|
313 |
||
314 |
handle method:newMethod. |
|
315 |
||
2350
16caba266df4
changed: #compileToMachineCode:forClass:selector:inCategory:notifying:install:skipIfSame:silent:
Stefan Vogel <sv@exept.de>
parents:
2336
diff
changeset
|
316 |
"/ check for obsolete compiled method code and unload the |
16caba266df4
changed: #compileToMachineCode:forClass:selector:inCategory:notifying:install:skipIfSame:silent:
Stefan Vogel <sv@exept.de>
parents:
2336
diff
changeset
|
317 |
"/ corresponding ObjectFileHandle. |
16caba266df4
changed: #compileToMachineCode:forClass:selector:inCategory:notifying:install:skipIfSame:silent:
Stefan Vogel <sv@exept.de>
parents:
2336
diff
changeset
|
318 |
"/ The old method with its source code is usually kept in the method history. |
16caba266df4
changed: #compileToMachineCode:forClass:selector:inCategory:notifying:install:skipIfSame:silent:
Stefan Vogel <sv@exept.de>
parents:
2336
diff
changeset
|
319 |
"/ and will be recompiled on an undo |
1669 | 320 |
|
321 |
ObjectFileLoader loadedObjectHandlesDo:[:anotherHandle | |
|
322 |
anotherHandle isMethodHandle ifTrue:[ |
|
2350
16caba266df4
changed: #compileToMachineCode:forClass:selector:inCategory:notifying:install:skipIfSame:silent:
Stefan Vogel <sv@exept.de>
parents:
2336
diff
changeset
|
323 |
anotherHandle method == oldMethod ifTrue:[ |
16caba266df4
changed: #compileToMachineCode:forClass:selector:inCategory:notifying:install:skipIfSame:silent:
Stefan Vogel <sv@exept.de>
parents:
2336
diff
changeset
|
324 |
"break association betwen old method, code and handle" |
16caba266df4
changed: #compileToMachineCode:forClass:selector:inCategory:notifying:install:skipIfSame:silent:
Stefan Vogel <sv@exept.de>
parents:
2336
diff
changeset
|
325 |
anotherHandle removeConnectedObjects. |
16caba266df4
changed: #compileToMachineCode:forClass:selector:inCategory:notifying:install:skipIfSame:silent:
Stefan Vogel <sv@exept.de>
parents:
2336
diff
changeset
|
326 |
]. |
16caba266df4
changed: #compileToMachineCode:forClass:selector:inCategory:notifying:install:skipIfSame:silent:
Stefan Vogel <sv@exept.de>
parents:
2336
diff
changeset
|
327 |
anotherHandle isObsolete ifTrue:[ |
16caba266df4
changed: #compileToMachineCode:forClass:selector:inCategory:notifying:install:skipIfSame:silent:
Stefan Vogel <sv@exept.de>
parents:
2336
diff
changeset
|
328 |
anotherHandle unload. |
16caba266df4
changed: #compileToMachineCode:forClass:selector:inCategory:notifying:install:skipIfSame:silent:
Stefan Vogel <sv@exept.de>
parents:
2336
diff
changeset
|
329 |
anotherHandle removeUnusedObjectFile. |
16caba266df4
changed: #compileToMachineCode:forClass:selector:inCategory:notifying:install:skipIfSame:silent:
Stefan Vogel <sv@exept.de>
parents:
2336
diff
changeset
|
330 |
]. |
16caba266df4
changed: #compileToMachineCode:forClass:selector:inCategory:notifying:install:skipIfSame:silent:
Stefan Vogel <sv@exept.de>
parents:
2336
diff
changeset
|
331 |
]. |
1669 | 332 |
]. |
333 |
^ newMethod. |
|
334 |
]. |
|
335 |
||
3013 | 336 |
"/ OperatingSystem removeFile:moduleFileName. |
1669 | 337 |
originator parseError:'dynamic load failed' position:1. |
338 |
^ #CannotLoad |
|
339 |
] ensure:[ |
|
3173 | 340 |
KeepIntermediateFiles == true ifTrue:[ |
341 |
Transcript showCR:'keeping files' |
|
2703
2e966ec31082
changed: #compileToMachineCode:forClass:selector:inCategory:notifying:install:skipIfSame:silent:
Claus Gittinger <cg@exept.de>
parents:
2658
diff
changeset
|
342 |
] ifFalse:[ |
3173 | 343 |
parserFlags stcKeepSTIntermediate ifTrue:[ |
344 |
Transcript showCR:'keeping st file: ', stFileName asFilename pathName |
|
345 |
] ifFalse:[ |
|
346 |
OperatingSystem removeFile:stFileName. |
|
347 |
OperatingSystem removeFile:'errorOutput'. |
|
348 |
]. |
|
349 |
cFileName notNil ifTrue:[ |
|
350 |
parserFlags stcKeepCIntermediate == true ifTrue:[ |
|
351 |
Transcript showCR:'keeping c file: ', cFileName asFilename pathName |
|
352 |
] ifFalse:[ |
|
353 |
OperatingSystem removeFile:cFileName. |
|
354 |
] |
|
355 |
]. |
|
356 |
oFileName notNil ifTrue:[ |
|
357 |
parserFlags stcKeepOIntermediate == true ifTrue:[ |
|
358 |
Transcript showCR:'keeping o file: ', oFileName asFilename pathName |
|
359 |
] ifFalse:[ |
|
360 |
OperatingSystem removeFile:oFileName. |
|
361 |
]. |
|
362 |
]. |
|
363 |
"/ OperatingSystem isMSDOSlike ifTrue:[ |
|
364 |
"/ mapFileName notNil ifTrue:[ |
|
365 |
"/ OperatingSystem removeFile:mapFileName. |
|
366 |
"/ ]. |
|
367 |
"/ libFileName notNil ifTrue:[ |
|
368 |
"/ OperatingSystem removeFile:libFileName. |
|
369 |
"/ ]. |
|
370 |
"/ ]. |
|
371 |
] |
|
1669 | 372 |
]. |
373 |
||
374 |
" |
|
375 |
|m| |
|
376 |
||
377 |
Object subclass:#Test |
|
378 |
instanceVariableNames:'' |
|
379 |
classVariableNames:'' |
|
380 |
poolDictionaries:'' |
|
381 |
category:'tests'. |
|
382 |
m := ByteCodeCompiler |
|
383 |
compile:'foo ^ ''hello''' |
|
384 |
forClass:Test |
|
385 |
inCategory:'tests' |
|
386 |
notifying:nil |
|
387 |
install:false |
|
388 |
skipIfSame:false. |
|
389 |
m inspect |
|
390 |
" |
|
391 |
" |
|
392 |
|m| |
|
393 |
||
394 |
Object subclass:#Test |
|
395 |
instanceVariableNames:'' |
|
396 |
classVariableNames:'' |
|
397 |
poolDictionaries:'' |
|
398 |
category:'tests'. |
|
399 |
m := ByteCodeCompiler |
|
400 |
compileToMachineCode:'foo %{ RETURN (_MKSMALLINT(1)); %}' |
|
401 |
forClass:Test |
|
402 |
inCategory:'tests' |
|
403 |
notifying:nil |
|
404 |
install:false |
|
405 |
skipIfSame:false |
|
406 |
silent:false. |
|
407 |
m inspect |
|
408 |
" |
|
409 |
||
1939 | 410 |
"Modified: / 14-09-1995 / 22:33:04 / claus" |
411 |
"Modified: / 19-03-1999 / 08:31:42 / stefan" |
|
2704
19bedf5ff15e
changed: #compileToMachineCode:forClass:selector:inCategory:notifying:install:skipIfSame:silent:
Claus Gittinger <cg@exept.de>
parents:
2703
diff
changeset
|
412 |
"Modified: / 17-09-2011 / 10:39:25 / cg" |
1939 | 413 |
! ! |
414 |
||
415 |
!STCCompilerInterface methodsFor:'machine code generation-helpers'! |
|
416 |
||
417 |
compileToC |
|
418 |
"compile st to C using stc" |
|
419 |
||
420 |
|command errorStream ok| |
|
421 |
||
2658 | 422 |
command := (self possiblyQuotedPath:stcPath) , ' ' , stcFlags |
3170 | 423 |
, ' -defdir=', (self possiblyQuotedPath:cFileName asFilename directory pathName). |
424 |
cFileName asFilename suffix = 'c' ifFalse:[ |
|
425 |
command := command , ' -cSuffix=',cFileName asFilename suffix. |
|
426 |
]. |
|
427 |
command := command , |
|
2658 | 428 |
' -C ' , (self possiblyQuotedPath:stFileName asFilename pathName). |
3170 | 429 |
|
1939 | 430 |
errorStream := 'errorOutput' asFilename writeStream. |
431 |
||
432 |
Verbose == true ifTrue:[ |
|
433 |
'executing: ' infoPrint. command infoPrintCR. |
|
434 |
]. |
|
435 |
||
436 |
originator activityNotification:'compiling (stc)'. |
|
437 |
ok := OperatingSystem |
|
438 |
executeCommand:command |
|
439 |
inputFrom:nil |
|
440 |
outputTo:errorStream |
|
441 |
errorTo:errorStream |
|
442 |
onError:[:stat| |
|
443 |
executionStatus := stat. |
|
444 |
false |
|
445 |
]. |
|
446 |
||
447 |
errorStream close. |
|
448 |
||
449 |
cFileName asFilename exists ifTrue:[ |
|
450 |
ok ifFalse:[ |
|
451 |
'Compiler [info]: oops - system says stc failed - but c-file is there ...' infoPrintCR. |
|
452 |
ok := true |
|
453 |
] |
|
454 |
] ifFalse:[ |
|
455 |
ok ifTrue:[ |
|
456 |
'Compiler [info]: oops - system says stc ok - but no c-file is there ...' infoPrintCR. |
|
457 |
]. |
|
458 |
ok := false |
|
459 |
]. |
|
460 |
^ ok |
|
461 |
||
462 |
"Created: / 07-11-2006 / 12:11:24 / cg" |
|
2643
60d2bae2be58
comment/format in: #generateSTSource:
Claus Gittinger <cg@exept.de>
parents:
2491
diff
changeset
|
463 |
"Modified: / 08-08-2011 / 22:12:01 / cg" |
1939 | 464 |
! |
465 |
||
2336 | 466 |
compileToExe |
467 |
"compile C to exe, using cc" |
|
468 |
||
469 |
|command errorStream ok| |
|
470 |
||
471 |
errorStream := 'errorOutput' asFilename newReadWriteStream. |
|
472 |
||
2658 | 473 |
command := (self possiblyQuotedPath:ccPath) , ' ' , cFlags , ' -D__INCREMENTAL_COMPILE__ ' , (self possiblyQuotedPath:cFileName). |
2336 | 474 |
|
475 |
Verbose == true ifTrue:[ |
|
476 |
'executing: ' infoPrint. command infoPrintCR. |
|
477 |
]. |
|
478 |
originator activityNotification:'compiling (' , ccPath , ')'. |
|
479 |
ok := OperatingSystem |
|
480 |
executeCommand:command |
|
481 |
inputFrom:nil |
|
482 |
outputTo:errorStream |
|
483 |
errorTo:errorStream |
|
484 |
onError:[:stat| |
|
485 |
executionStatus := stat. |
|
486 |
false |
|
487 |
]. |
|
488 |
||
489 |
ok ifFalse:[ |
|
490 |
errorStream reset. |
|
491 |
errorStream copyToEndInto:Transcript. |
|
492 |
]. |
|
493 |
||
494 |
errorStream close. |
|
495 |
||
496 |
^ ok |
|
497 |
! |
|
498 |
||
1939 | 499 |
compileToObj |
500 |
"compile C to obj, using cc" |
|
501 |
||
3170 | 502 |
|errorStream ok command ccDefine| |
1939 | 503 |
|
2195
2996fe27c2f8
Add primitive functions when compiling
Stefan Vogel <sv@exept.de>
parents:
2185
diff
changeset
|
504 |
errorStream := 'errorOutput' asFilename newReadWriteStream. |
1939 | 505 |
|
3170 | 506 |
"/ bcc does not like -D__BORLANDC__ (needs to be set to a version, such as 0x0505 |
507 |
"/ others do not need it (is already predefined in the compiler) |
|
508 |
"/ ccDefine := ' -D',ParserFlags usedCompilerDefine. |
|
3173 | 509 |
"/ so, never redefine ccDefine |
3170 | 510 |
ccDefine := ''. |
511 |
||
3010
7970294627a3
flag settings for 64bit mingw
Claus Gittinger <cg@exept.de>
parents:
3005
diff
changeset
|
512 |
ParserFlags useBorlandC ifTrue:[ |
7970294627a3
flag settings for 64bit mingw
Claus Gittinger <cg@exept.de>
parents:
3005
diff
changeset
|
513 |
"Note: Windows/bcc32 does not understand a space between -o and filename" |
7970294627a3
flag settings for 64bit mingw
Claus Gittinger <cg@exept.de>
parents:
3005
diff
changeset
|
514 |
"/ cg: I guess, this does not work for visual-c |
3170 | 515 |
command := (self possiblyQuotedPath:ccPath) , ' ' , cFlags , ccDefine,' -D__INCREMENTAL_COMPILE__ -o', (self possiblyQuotedPath:oFileName), ' -c ' , (self possiblyQuotedPath:cFileName). |
3010
7970294627a3
flag settings for 64bit mingw
Claus Gittinger <cg@exept.de>
parents:
3005
diff
changeset
|
516 |
] ifFalse:[ |
3170 | 517 |
command := (self possiblyQuotedPath:ccPath) , ' ' , cFlags , ccDefine,' -D__INCREMENTAL_COMPILE__ -o ', (self possiblyQuotedPath:oFileName), ' -c ' , (self possiblyQuotedPath:cFileName). |
3010
7970294627a3
flag settings for 64bit mingw
Claus Gittinger <cg@exept.de>
parents:
3005
diff
changeset
|
518 |
]. |
1939 | 519 |
|
520 |
Verbose == true ifTrue:[ |
|
521 |
'executing: ' infoPrint. command infoPrintCR. |
|
522 |
]. |
|
523 |
originator activityNotification:'compiling (' , ccPath , ')'. |
|
524 |
ok := OperatingSystem |
|
525 |
executeCommand:command |
|
526 |
inputFrom:nil |
|
527 |
outputTo:errorStream |
|
528 |
errorTo:errorStream |
|
529 |
onError:[:stat| |
|
530 |
executionStatus := stat. |
|
531 |
false |
|
2195
2996fe27c2f8
Add primitive functions when compiling
Stefan Vogel <sv@exept.de>
parents:
2185
diff
changeset
|
532 |
]. |
2996fe27c2f8
Add primitive functions when compiling
Stefan Vogel <sv@exept.de>
parents:
2185
diff
changeset
|
533 |
|
2996fe27c2f8
Add primitive functions when compiling
Stefan Vogel <sv@exept.de>
parents:
2185
diff
changeset
|
534 |
ok ifFalse:[ |
2996fe27c2f8
Add primitive functions when compiling
Stefan Vogel <sv@exept.de>
parents:
2185
diff
changeset
|
535 |
errorStream reset. |
2996fe27c2f8
Add primitive functions when compiling
Stefan Vogel <sv@exept.de>
parents:
2185
diff
changeset
|
536 |
errorStream copyToEndInto:Transcript. |
2996fe27c2f8
Add primitive functions when compiling
Stefan Vogel <sv@exept.de>
parents:
2185
diff
changeset
|
537 |
]. |
1939 | 538 |
|
539 |
errorStream close. |
|
540 |
||
541 |
oFileName asFilename exists ifTrue:[ |
|
542 |
ok ifFalse:[ |
|
543 |
'Compiler [info]: system says compile failed - but o-file is there ...' infoPrintCR. |
|
544 |
ok := true |
|
545 |
] |
|
546 |
] ifFalse:[ |
|
547 |
ok ifTrue:[ |
|
548 |
'Compiler [info]: system says compile ok - but no o-file is there ...' infoPrintCR. |
|
549 |
]. |
|
550 |
ok := false |
|
551 |
]. |
|
552 |
^ ok |
|
553 |
||
554 |
"Created: / 07-11-2006 / 12:14:51 / cg" |
|
555 |
! |
|
556 |
||
2491 | 557 |
compileToS |
558 |
"compile C to assembler, using cc" |
|
559 |
||
560 |
|command errorStream ok| |
|
561 |
||
562 |
errorStream := 'errorOutput' asFilename newReadWriteStream. |
|
563 |
||
2658 | 564 |
command := (self possiblyQuotedPath:ccPath) , ' ' , cFlags , ' -D__INCREMENTAL_COMPILE__ -S ' , (self possiblyQuotedPath:cFileName). |
2491 | 565 |
|
566 |
Verbose == true ifTrue:[ |
|
567 |
'executing: ' infoPrint. command infoPrintCR. |
|
568 |
]. |
|
569 |
originator activityNotification:'compiling (' , ccPath , ')'. |
|
570 |
ok := OperatingSystem |
|
571 |
executeCommand:command |
|
572 |
inputFrom:nil |
|
573 |
outputTo:errorStream |
|
574 |
errorTo:errorStream |
|
575 |
onError:[:stat| |
|
576 |
executionStatus := stat. |
|
577 |
false |
|
578 |
]. |
|
579 |
||
580 |
ok ifFalse:[ |
|
581 |
errorStream reset. |
|
582 |
errorStream copyToEndInto:Transcript. |
|
583 |
]. |
|
584 |
||
585 |
errorStream close. |
|
586 |
^ ok |
|
587 |
! |
|
588 |
||
1939 | 589 |
ensureExternalToolsArePresent |
590 |
(stcPath := self incrementalStcPath) isNil ifTrue:[ |
|
591 |
originator parseError:'no stc compiler available - cannot create machine code' position:1. |
|
592 |
^ false |
|
593 |
]. |
|
2649 | 594 |
|
595 |
"make it absolute, so that we are immune to directory changes" |
|
596 |
stcPath := stcPath asFilename pathName. |
|
1939 | 597 |
(ccPath := parserFlags ccPath) isNil ifTrue:[ |
598 |
originator parseError:'no cc compiler available - cannot create machine code' position:1. |
|
599 |
^ false |
|
600 |
]. |
|
2649 | 601 |
"make it absolute, so that we are immune to directory changes" |
602 |
ccPath := ccPath asFilename pathName. |
|
1939 | 603 |
|
604 |
(ObjectFileLoader notNil and:[ObjectFileLoader canLoadObjectFiles]) ifFalse:[ |
|
605 |
originator parseError:'no dynamic loader configured - cannot create machine code' position:1. |
|
606 |
^ false |
|
607 |
]. |
|
608 |
^ true |
|
609 |
||
610 |
"Created: / 07-11-2006 / 12:31:48 / cg" |
|
1670 | 611 |
! |
612 |
||
613 |
ensureModuleDirectoryExists |
|
614 |
|mP t s| |
|
615 |
||
616 |
(mP := parserFlags stcModulePath asFilename) exists ifFalse:[ |
|
617 |
mP makeDirectory |
|
618 |
]. |
|
3240 | 619 |
(mP isWritableDirectory and:[mP isReadable]) ifFalse:[ |
3069 | 620 |
ParseError raiseErrorString:('No access to temporary module directory: ' , mP pathName). |
1670 | 621 |
]. |
622 |
"/ create a small README there ... |
|
623 |
||
624 |
(t := mP construct:'README') exists ifFalse:[ |
|
625 |
s := t writeStream. |
|
626 |
s |
|
627 |
nextPutAll:'This temporary ST/X directory contains machine code for |
|
628 |
accepted methods with embedded C-code |
|
629 |
(i.e. dynamic compiled code for inline-C methods). |
|
630 |
||
631 |
Files here are not automatically removed, since ST/X |
|
632 |
cannot determine if any (other) snapshot image still |
|
633 |
requires a file here. |
|
634 |
||
635 |
Please be careful when removing files here - a snapshot |
|
636 |
image which was saved with accepted embedded C-code |
|
637 |
may not be able to restart correctly if you remove a |
|
638 |
required file. |
|
639 |
Also, when you export a snapshot image for execution |
|
640 |
on another machine, make certain that the required |
|
641 |
module-files are also present there. |
|
642 |
||
643 |
You should periodically clean dead entries here. |
|
644 |
i.e. remove files, when you are certain that none |
|
645 |
of your snapshot images refers to any module here. |
|
646 |
||
647 |
See the launchers File-Modules dialog for a list of |
|
648 |
modules which are still required by your running image. |
|
649 |
||
650 |
With kind regards - your ST/X. |
|
651 |
'. |
|
652 |
s close. |
|
653 |
]. |
|
654 |
! |
|
655 |
||
656 |
ensureSuperClassesAreLoadedOf:aClass |
|
657 |
|supers| |
|
658 |
||
659 |
supers := aClass allSuperclasses. |
|
660 |
supers reverseDo:[:cls| |
|
661 |
cls isLoaded ifFalse:[ |
|
3069 | 662 |
ParseError raiseErrorString:'Cannot stc-compile (Some superclass is unloaded)'. |
1670 | 663 |
] |
664 |
]. |
|
665 |
! |
|
666 |
||
667 |
fileOutAllDefinitionsOf:aClass to:aStream rememberIn:definedClasses |
|
668 |
|defineAction| |
|
669 |
||
670 |
defineAction := |
|
671 |
[:cls| |
|
672 |
(definedClasses includes:cls) ifFalse:[ |
|
673 |
cls |
|
674 |
basicFileOutDefinitionOn:aStream |
|
675 |
withNameSpace:false withPackage:false |
|
676 |
syntaxHilighting:false. |
|
677 |
||
678 |
aStream nextPut:(aStream class chunkSeparator); cr. |
|
679 |
definedClasses add:cls. |
|
680 |
]. |
|
681 |
]. |
|
682 |
||
683 |
aClass allSuperclasses reverseDo:defineAction. |
|
684 |
defineAction value:aClass. |
|
1939 | 685 |
! |
686 |
||
687 |
generateSTSource:aString |
|
2647 | 688 |
|stream definedClasses sep className modulesDir| |
1939 | 689 |
|
690 |
"/ generate a unique name, consisting of my processID and a sequence number |
|
691 |
"/ the processId is added to allow filein of modules from different |
|
692 |
"/ lifes |
|
693 |
||
694 |
SequenceNumber := (SequenceNumber ? 0) + 1. |
|
695 |
||
696 |
initName := 'm_' , OperatingSystem getProcessId printString, '_' , SequenceNumber printString. |
|
697 |
||
2646 | 698 |
"/ Smalltalk isSmalltalkDevelopmentSystem ifTrue:[ |
699 |
"/ modulesParentDir := Filename currentDirectory. |
|
700 |
"/ ] ifFalse:[ |
|
701 |
"/ modulesParentDir := Filename tempDirectory. |
|
702 |
"/ ]. |
|
703 |
"/ modulesDir := modulesParentDir construct:'modules'. |
|
704 |
modulesDir := ParserFlags stcModulePath. |
|
2647 | 705 |
stFileName := (modulesDir asFilename construct:(initName , '.st')) name. |
2646 | 706 |
|
1939 | 707 |
[ |
708 |
stream := stFileName asFilename writeStream. |
|
709 |
] on:FileStream openErrorSignal do:[:ex| |
|
710 |
originator parseError:'cannot create temporary sourcefile for compilation'. |
|
711 |
^ #CannotLoad |
|
712 |
]. |
|
713 |
||
714 |
definedClasses := IdentitySet new. |
|
715 |
||
716 |
sep := stream class chunkSeparator. |
|
717 |
||
718 |
Class fileOutNameSpaceQuerySignal answer:true |
|
719 |
do:[ |
|
2467 | 720 |
theNonMetaclassToCompileFor realSharedPoolNames do:[:eachPoolname | |
2067
6204fefb44a3
must also file-out the definition of sharedPools
Claus Gittinger <cg@exept.de>
parents:
2026
diff
changeset
|
721 |
|pool| |
6204fefb44a3
must also file-out the definition of sharedPools
Claus Gittinger <cg@exept.de>
parents:
2026
diff
changeset
|
722 |
|
6204fefb44a3
must also file-out the definition of sharedPools
Claus Gittinger <cg@exept.de>
parents:
2026
diff
changeset
|
723 |
pool := Smalltalk at:eachPoolname. |
6204fefb44a3
must also file-out the definition of sharedPools
Claus Gittinger <cg@exept.de>
parents:
2026
diff
changeset
|
724 |
self |
6204fefb44a3
must also file-out the definition of sharedPools
Claus Gittinger <cg@exept.de>
parents:
2026
diff
changeset
|
725 |
fileOutAllDefinitionsOf:pool |
6204fefb44a3
must also file-out the definition of sharedPools
Claus Gittinger <cg@exept.de>
parents:
2026
diff
changeset
|
726 |
to:stream |
6204fefb44a3
must also file-out the definition of sharedPools
Claus Gittinger <cg@exept.de>
parents:
2026
diff
changeset
|
727 |
rememberIn:definedClasses. |
6204fefb44a3
must also file-out the definition of sharedPools
Claus Gittinger <cg@exept.de>
parents:
2026
diff
changeset
|
728 |
]. |
6204fefb44a3
must also file-out the definition of sharedPools
Claus Gittinger <cg@exept.de>
parents:
2026
diff
changeset
|
729 |
|
1939 | 730 |
self |
731 |
fileOutAllDefinitionsOf:theNonMetaclassToCompileFor |
|
732 |
to:stream |
|
733 |
rememberIn:definedClasses. |
|
734 |
||
735 |
theNonMetaclassToCompileFor privateClassesSorted do:[:aPrivateClass | |
|
736 |
self |
|
737 |
fileOutAllDefinitionsOf:aPrivateClass |
|
738 |
to:stream |
|
739 |
rememberIn:definedClasses. |
|
740 |
]. |
|
2195
2996fe27c2f8
Add primitive functions when compiling
Stefan Vogel <sv@exept.de>
parents:
2185
diff
changeset
|
741 |
"/ theNonMetaclassToCompileFor fileOutPrimitiveDefinitionsOn:stream. |
2026 | 742 |
"/ If a method uses a static primitive function... - but this doesn't work |
2195
2996fe27c2f8
Add primitive functions when compiling
Stefan Vogel <sv@exept.de>
parents:
2185
diff
changeset
|
743 |
"/ Yes it does work, but primitive functions have to be strictly static!! |
2996fe27c2f8
Add primitive functions when compiling
Stefan Vogel <sv@exept.de>
parents:
2185
diff
changeset
|
744 |
theNonMetaclassToCompileFor fileOutPrimitiveSpecsOn:stream. |
1939 | 745 |
]. |
746 |
||
2026 | 747 |
"/ stream cr. |
748 |
"/ stream nextPutLine:'"{ Package: ''' , package , ''' }"'. |
|
749 |
"/ stream cr. |
|
1939 | 750 |
|
751 |
stream nextPut:sep. |
|
752 |
className := theNonMetaclassToCompileFor name. |
|
753 |
||
754 |
stream nextPutAll:className. |
|
755 |
classToCompileFor isMeta ifTrue:[ |
|
756 |
stream nextPutAll:' class'. |
|
757 |
]. |
|
758 |
stream nextPutAll:' methodsFor:'''; nextPutAll:methodCategory; nextPutAll:''''. |
|
759 |
stream nextPut:sep; cr. |
|
760 |
||
761 |
stream nextPutLine:'"{ Line: 0 }"'; |
|
762 |
nextChunkPut:aString; |
|
763 |
space; nextPut:sep. |
|
764 |
||
765 |
stream close. |
|
766 |
||
2646 | 767 |
"Modified: / 08-08-2011 / 23:23:10 / cg" |
1939 | 768 |
! |
769 |
||
2658 | 770 |
possiblyQuotedPath:aPath |
3173 | 771 |
(aPath includes:Character space) ifTrue:[ |
2658 | 772 |
(aPath startsWith:'"') ifFalse:[ |
773 |
^ '"',aPath,'"' |
|
774 |
] |
|
775 |
]. |
|
776 |
^ aPath |
|
777 |
! |
|
778 |
||
3005 | 779 |
reportCompilationErrorFor:aCommand |
1939 | 780 |
|eMsg errorMessages lNr| |
781 |
||
782 |
(executionStatus notNil and:[executionStatus couldNotExecute]) ifTrue:[ |
|
783 |
eMsg := 'oops, no STC - cannot create machine code' |
|
784 |
] ifFalse:[ |
|
785 |
errorMessages := 'errorOutput' asFilename contents. |
|
786 |
OperatingSystem removeFile:'errorOutput'. |
|
787 |
||
788 |
errorMessages notNil ifTrue:[ |
|
789 |
errorMessages := errorMessages reject:[:line | line includesString:'Warning:']. |
|
790 |
||
791 |
errorMessages size > 20 ifTrue:[ |
|
792 |
errorMessages := errorMessages select:[:line | line asLowercase startsWith:'error']. |
|
793 |
errorMessages size > 20 ifTrue:[ |
|
794 |
errorMessages := (errorMessages copyTo:20) copyWith:'... more messages skipped' |
|
795 |
]. |
|
796 |
]. |
|
797 |
"/ errorMessages := errorMessages collect:[:line | |
|
798 |
"/ (line startsWith:(stFileName , ':')) ifTrue:[ |
|
799 |
"/ 'Line: ' , (line copyFrom:(stFileName size + 2)) |
|
800 |
"/ ] ifFalse:[ |
|
801 |
"/ line |
|
802 |
"/ ] |
|
803 |
"/ ]. |
|
804 |
]. |
|
805 |
errorMessages isNil ifTrue:[ |
|
806 |
errorMessages := #('') |
|
807 |
]. |
|
3005 | 808 |
errorMessages := (Array with:'Failed to execute: "', aCommand,'"') , errorMessages. |
1939 | 809 |
|
810 |
"/ try to extract a line number" |
|
811 |
(errorMessages contains:[:line | line includesString:'Borland']) ifTrue:[ |
|
812 |
|i i2 s| |
|
813 |
i := errorMessages findFirst:[:l | l startsWith:(cFileName,':')]. |
|
814 |
i ~~ 0 ifTrue:[ |
|
815 |
((errorMessages at:i+1) startsWith:'Error') ifTrue:[ |
|
816 |
i2 := (errorMessages at:i+1) indexOfSubCollection:(stFileName). |
|
817 |
i2 ~~ 0 ifTrue:[ |
|
818 |
s := (errorMessages at:i+1) copyFrom:(i2+stFileName size+1). |
|
819 |
s := s readStream. |
|
820 |
lNr := Integer readFrom:s. |
|
821 |
s skipSeparators. |
|
822 |
]. |
|
823 |
] |
|
824 |
]. |
|
825 |
]. |
|
826 |
||
827 |
errorMessages isEmpty ifTrue:[ |
|
828 |
eMsg := 'Error during compilation:\\Unspecified error (no output)' withCRs |
|
829 |
] ifFalse:[ |
|
830 |
eMsg := 'Error during compilation:\\' withCRs , |
|
831 |
(errorMessages asStringCollection asString). |
|
832 |
]. |
|
833 |
]. |
|
2461
89458faaeeb3
changed: #reportCompilationError
Stefan Vogel <sv@exept.de>
parents:
2350
diff
changeset
|
834 |
|
1939 | 835 |
originator activityNotification:''. |
836 |
||
3069 | 837 |
ParseError new |
2461
89458faaeeb3
changed: #reportCompilationError
Stefan Vogel <sv@exept.de>
parents:
2350
diff
changeset
|
838 |
lineNumber:lNr; |
89458faaeeb3
changed: #reportCompilationError
Stefan Vogel <sv@exept.de>
parents:
2350
diff
changeset
|
839 |
errorMessage:eMsg; |
89458faaeeb3
changed: #reportCompilationError
Stefan Vogel <sv@exept.de>
parents:
2350
diff
changeset
|
840 |
raise. |
89458faaeeb3
changed: #reportCompilationError
Stefan Vogel <sv@exept.de>
parents:
2350
diff
changeset
|
841 |
|
1939 | 842 |
"Created: / 07-11-2006 / 12:29:04 / cg" |
843 |
! |
|
844 |
||
845 |
setupCompilationCommandArguments |
|
2335 | 846 |
|stFn mapFileName libFileName def libDir incDir incDirArg defs incl opts| |
847 |
||
848 |
parserFlags isNil ifTrue:[ parserFlags := ParserFlags new]. |
|
1939 | 849 |
|
1941 | 850 |
stFn := stFileName asFilename. |
851 |
oFileName := stFn nameWithoutSuffix , (ObjectFileLoader objectFileExtension). |
|
852 |
cFileName := (stFn withSuffix:'c') name. |
|
3170 | 853 |
"/ ParserFlags useBorlandC ifTrue:[ |
854 |
"/ cFileName := (stFn withSuffix:'sc') name. |
|
855 |
"/ ]. |
|
1941 | 856 |
mapFileName := (stFn withSuffix:'map') name. |
857 |
libFileName := (stFn withSuffix:'lib') name. |
|
1939 | 858 |
oFileName asFilename delete. |
859 |
cFileName asFilename delete. |
|
860 |
||
861 |
"/ stcFlags := '-commonSymbols +sharedLibCode +newIncremental -E:errorOutput -N' , initName . |
|
2335 | 862 |
stcFlags := '+newIncremental -E:errorOutput'. |
863 |
initName notNil ifTrue:[ |
|
864 |
stcFlags := stcFlags,' -N' , initName . |
|
865 |
]. |
|
1939 | 866 |
cFlags := OperatingSystem getOSDefine. |
867 |
cFlags isNil ifTrue:[ |
|
868 |
cFlags := '' |
|
869 |
]. |
|
870 |
(def := OperatingSystem getCPUDefine) notNil ifTrue:[ |
|
871 |
cFlags := cFlags , ' ' , def |
|
872 |
]. |
|
873 |
||
2335 | 874 |
(defs := parserFlags stcCompilationDefines) notNil ifTrue:[ |
875 |
cFlags := cFlags , ' ' , defs |
|
1939 | 876 |
]. |
2335 | 877 |
(incl := parserFlags stcCompilationIncludes) notNil ifTrue:[ |
878 |
stcFlags := incl , ' ' , stcFlags. |
|
879 |
cFlags := cFlags , ' ' , incl. |
|
1939 | 880 |
|
881 |
"/ if STX_LIBDIR is defined, and not in passed argument, |
|
882 |
"/ add it here. |
|
883 |
||
884 |
libDir := OperatingSystem getEnvironment:'STX_LIBDIR'. |
|
885 |
(libDir notNil and:[libDir asFilename exists]) ifTrue:[ |
|
886 |
incDir := libDir asFilename construct:'include'. |
|
887 |
incDir exists ifTrue:[ |
|
888 |
incDirArg := '-I' , incDir pathName. |
|
2335 | 889 |
(incl asCollectionOfWords includes:incDirArg) ifFalse:[ |
1939 | 890 |
stcFlags := stcFlags , ' ' , incDirArg. |
891 |
cFlags := cFlags , ' ' , incDirArg. |
|
892 |
] |
|
893 |
] |
|
894 |
]. |
|
895 |
]. |
|
2335 | 896 |
(opts := parserFlags stcCompilationOptions) notNil ifTrue:[ |
897 |
stcFlags := opts , ' ' , stcFlags |
|
1939 | 898 |
]. |
2335 | 899 |
(opts := parserFlags ccCompilationOptions) notNil ifTrue:[ |
900 |
cFlags := cFlags , ' ' , opts |
|
1939 | 901 |
]. |
902 |
||
903 |
"Created: / 07-11-2006 / 12:24:47 / cg" |
|
1941 | 904 |
"Modified: / 07-11-2006 / 13:58:54 / cg" |
1669 | 905 |
! ! |
906 |
||
907 |
!STCCompilerInterface class methodsFor:'documentation'! |
|
908 |
||
909 |
version |
|
3240 | 910 |
^ '$Header: /cvs/stx/stx/libcomp/STCCompilerInterface.st,v 1.37 2013-07-29 14:08:48 stefan Exp $' |
2335 | 911 |
! |
912 |
||
913 |
version_CVS |
|
3240 | 914 |
^ '$Header: /cvs/stx/stx/libcomp/STCCompilerInterface.st,v 1.37 2013-07-29 14:08:48 stefan Exp $' |
1669 | 915 |
! ! |
916 |
||
3005 | 917 |
|
1669 | 918 |
STCCompilerInterface initialize! |