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