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