author | Jan Vrany <jan.vrany@fit.cvut.cz> |
Sat, 04 Jul 2015 11:52:42 +0100 | |
branch | jv |
changeset 18555 | 7cc0ec139c8d |
parent 18192 | 32a7c53ef4d0 |
parent 18525 | 6b76f94a31ae |
child 19227 | 5e949760a4e8 |
permissions | -rw-r--r-- |
17707 | 1 |
"{ Encoding: utf8 }" |
2 |
||
9944 | 3 |
" |
4 |
COPYRIGHT (c) 2006 by eXept Software AG |
|
5 |
All Rights Reserved |
|
6 |
||
7 |
This software is furnished under a license and may be used |
|
8 |
only in accordance with the terms of that license and with the |
|
9 |
inclusion of the above copyright notice. This software may not |
|
10 |
be provided or otherwise made available to, or used by, any |
|
11 |
other person. No title to or ownership of the software is |
|
12 |
hereby transferred. |
|
13 |
" |
|
14 |
"{ Package: 'stx:libbasic' }" |
|
15 |
||
17280 | 16 |
"{ NameSpace: Smalltalk }" |
17 |
||
9944 | 18 |
Object subclass:#StandaloneStartup |
19 |
instanceVariableNames:'' |
|
10772 | 20 |
classVariableNames:'Verbose CommandLineArguments' |
9944 | 21 |
poolDictionaries:'' |
22 |
category:'System-Support' |
|
23 |
! |
|
24 |
||
11102 | 25 |
StandaloneStartup class instanceVariableNames:'MutexHandle' |
26 |
||
27 |
" |
|
28 |
No other class instance variables are inherited by this class. |
|
29 |
" |
|
30 |
! |
|
31 |
||
9944 | 32 |
!StandaloneStartup class methodsFor:'documentation'! |
33 |
||
34 |
copyright |
|
35 |
" |
|
36 |
COPYRIGHT (c) 2006 by eXept Software AG |
|
37 |
All Rights Reserved |
|
38 |
||
39 |
This software is furnished under a license and may be used |
|
40 |
only in accordance with the terms of that license and with the |
|
41 |
inclusion of the above copyright notice. This software may not |
|
42 |
be provided or otherwise made available to, or used by, any |
|
43 |
other person. No title to or ownership of the software is |
|
44 |
hereby transferred. |
|
45 |
" |
|
46 |
! |
|
47 |
||
48 |
documentation |
|
49 |
" |
|
17280 | 50 |
When smalltalk is started as IDE (stx), the show starts in Smalltalk>>start. |
51 |
In contrast, when a standAlone app is linked, the show starts in the startup class's |
|
52 |
start method. |
|
53 |
This class is a subclassable template class for a standalone GUI-application's startup. |
|
9944 | 54 |
For your own stand alone programs, define a subclass of this, |
12335 | 55 |
and redefine the #main: method there. |
9944 | 56 |
(of course, the other methods can also be redefined.) |
57 |
||
58 |
[author:] |
|
59 |
Claus Gittinger |
|
60 |
||
61 |
[start with:] |
|
62 |
<yourNamehere>Startup start |
|
10886 | 63 |
|
64 |
[see also:] |
|
65 |
Smalltalk |
|
66 |
GetOpt |
|
67 |
ReadEvalPrintLoop |
|
9944 | 68 |
" |
11102 | 69 |
! |
70 |
||
71 |
howToDealWithMultipleApplicationInstances |
|
72 |
" |
|
73 |
please read the comment in the corresponding ApplicationModel class-documentation method. |
|
74 |
" |
|
11352 | 75 |
! |
76 |
||
77 |
whichMethodsToRedefine |
|
78 |
" |
|
79 |
main:argv |
|
80 |
thats the actual program. |
|
81 |
||
82 |
suppressRCFileReading |
|
83 |
false here; redefine to return true, to disable the rc-file reading. |
|
84 |
you loose the chance of configuration, but lock the user out from any access to any smalltalk |
|
85 |
(if you have a user-phobia) |
|
86 |
||
87 |
allowDebugOption |
|
11361
36d809458749
defaults for allowDebug and allowScripting
Michael Beyl <mb@exept.de>
parents:
11360
diff
changeset
|
88 |
false here; redefine to return true, to enable the --debug startup option. |
36d809458749
defaults for allowDebug and allowScripting
Michael Beyl <mb@exept.de>
parents:
11360
diff
changeset
|
89 |
if disabled, you loose the chance of debugging, but lock the user out from any access to any smalltalk |
11352 | 90 |
|
91 |
allowScriptingOption |
|
11361
36d809458749
defaults for allowDebug and allowScripting
Michael Beyl <mb@exept.de>
parents:
11360
diff
changeset
|
92 |
false here; redefine to return true, to enable the --scripting startup option. |
36d809458749
defaults for allowDebug and allowScripting
Michael Beyl <mb@exept.de>
parents:
11360
diff
changeset
|
93 |
if disabled, you loose the chance of remote control, but lock the user out from any access to any smalltalk |
11352 | 94 |
|
95 |
" |
|
9944 | 96 |
! ! |
97 |
||
98 |
!StandaloneStartup class methodsFor:'initialization'! |
|
99 |
||
100 |
initialize |
|
11360 | 101 |
"/ Verbose := true. |
9944 | 102 |
Verbose := false. |
103 |
! ! |
|
104 |
||
13375 | 105 |
!StandaloneStartup class methodsFor:'debugging support'! |
106 |
||
107 |
dumpCoverageInformation |
|
108 |
"if the --coverage argument was given, dump that information now. |
|
109 |
This is invoked via an exit block, when smalltalk terminates" |
|
110 |
||
13377 | 111 |
"/ count instrumented vs. non-instrumented classes |
112 |
|nClasses nMethods |
|
113 |
locOverall locExecuted locUnexecuted locInstrumented locUninstrumented |
|
114 |
locCovered locUncovered |
|
115 |
nInstrumentedClasses nUninstrumentedClasses nPartiallyInstrumentedClasses |
|
116 |
nInstrumentedMethods nUninstrumentedMethods |
|
117 |
nClassesCompletelyCovered nClassesPartiallyCovered nClassesUncovered |
|
118 |
nMethodsCompletelyCovered nMethodsPartiallyCovered nMethodsUncovered| |
|
119 |
||
120 |
nInstrumentedClasses := nUninstrumentedClasses := nPartiallyInstrumentedClasses := 0. |
|
121 |
nInstrumentedMethods := nUninstrumentedMethods := 0. |
|
122 |
nClasses := nMethods := 0. |
|
123 |
locOverall := locCovered := locUncovered := 0. |
|
124 |
locInstrumented := locUninstrumented := 0. |
|
125 |
locExecuted := locUnexecuted := 0. |
|
126 |
nClassesCompletelyCovered := nClassesPartiallyCovered := nClassesUncovered := 0. |
|
127 |
nMethodsCompletelyCovered := nMethodsPartiallyCovered := nMethodsUncovered := 0. |
|
128 |
||
129 |
Smalltalk allClassesDo:[:eachClass | |
|
130 |
|nInstrumentedMethodsInClass nUninstrumentedMethodsInClass |
|
131 |
nMethodsCompletelyCoveredInClass nMethodsPartiallyCoveredInClass nMethodsUncoveredInClass |
|
132 |
locInstrumentedMethodsInClass locUninstrumentedMethodsInClass |
|
133 |
locExecutedInClass locUnexecutedInClass locPartiallyExecutedInClass| |
|
134 |
||
135 |
nMethodsCompletelyCoveredInClass := nMethodsPartiallyCoveredInClass := nMethodsUncoveredInClass := 0. |
|
136 |
nInstrumentedMethodsInClass := nUninstrumentedMethodsInClass := 0. |
|
137 |
locInstrumentedMethodsInClass := locUninstrumentedMethodsInClass := 0. |
|
138 |
eachClass instAndClassMethodsDo:[:mthd | |
|
139 |
|locMethod| |
|
140 |
||
141 |
nMethods := nMethods + 1. |
|
142 |
locMethod := 0. "/ mthd source asCollectionOfLines size. |
|
143 |
||
144 |
mthd isInstrumented ifTrue:[ |
|
145 |
nInstrumentedMethodsInClass := nInstrumentedMethodsInClass + 1. |
|
146 |
locInstrumentedMethodsInClass := locInstrumentedMethodsInClass + locMethod. |
|
147 |
mthd hasBeenCalled ifTrue:[ |
|
148 |
mthd haveAllBlocksBeenExecuted ifTrue:[ |
|
149 |
"/ fully covered |
|
150 |
nMethodsCompletelyCoveredInClass := nMethodsCompletelyCoveredInClass + 1 |
|
151 |
] ifFalse:[ |
|
152 |
"/ partially covered |
|
153 |
nMethodsPartiallyCoveredInClass := nMethodsPartiallyCoveredInClass + 1 |
|
154 |
] |
|
155 |
] ifFalse:[ |
|
156 |
"/ completely uncovered |
|
157 |
nMethodsUncoveredInClass := nMethodsUncoveredInClass + 1 |
|
158 |
]. |
|
159 |
] ifFalse:[ |
|
160 |
nUninstrumentedMethodsInClass := nUninstrumentedMethodsInClass + 1. |
|
161 |
locUninstrumentedMethodsInClass := locUninstrumentedMethodsInClass + locMethod. |
|
162 |
]. |
|
163 |
]. |
|
164 |
||
165 |
nInstrumentedMethods := nInstrumentedMethods + nInstrumentedMethodsInClass. |
|
166 |
nUninstrumentedMethods := nUninstrumentedMethods + nUninstrumentedMethodsInClass. |
|
167 |
||
168 |
nMethodsCompletelyCovered := nMethodsCompletelyCovered + nMethodsCompletelyCoveredInClass. |
|
169 |
nMethodsUncovered := nMethodsUncovered + nMethodsUncoveredInClass. |
|
170 |
nMethodsPartiallyCovered := nMethodsPartiallyCovered + nMethodsPartiallyCoveredInClass. |
|
171 |
||
172 |
nClasses := nClasses + 1. |
|
173 |
nInstrumentedMethodsInClass == 0 ifTrue:[ |
|
174 |
nUninstrumentedMethodsInClass == 0 ifTrue:[ |
|
175 |
"/ empty class - do not count |
|
176 |
] ifFalse:[ |
|
177 |
"/ completely uninstrumented |
|
178 |
nUninstrumentedClasses := nUninstrumentedClasses + 1. |
|
179 |
]. |
|
180 |
] ifFalse:[ |
|
181 |
nUninstrumentedMethodsInClass == 0 ifTrue:[ |
|
182 |
"/ completely instrumented |
|
183 |
nInstrumentedClasses := nInstrumentedClasses + 1. |
|
184 |
] ifFalse:[ |
|
185 |
"/ part/part |
|
186 |
nPartiallyInstrumentedClasses := nPartiallyInstrumentedClasses + 1. |
|
187 |
]. |
|
188 |
]. |
|
189 |
||
190 |
nMethodsCompletelyCoveredInClass > 0 ifTrue:[ |
|
191 |
nClassesCompletelyCovered := nClassesCompletelyCovered + 1. |
|
192 |
] ifFalse:[ |
|
193 |
nMethodsPartiallyCoveredInClass > 0 ifTrue:[ |
|
194 |
nClassesPartiallyCovered := nClassesPartiallyCovered + 1. |
|
195 |
] ifFalse:[ |
|
196 |
nClassesUncovered := nClassesUncovered + 1. |
|
197 |
]. |
|
198 |
]. |
|
199 |
]. |
|
200 |
||
201 |
Stderr nextPutLine:'Coverage info:'. |
|
202 |
Stderr nextPutLine:(' Classes, overall: %1' bindWith:nClasses). |
|
203 |
Stderr nextPutLine:(' Classes, instrumented: %1 (%2%%)' bindWith:nInstrumentedClasses with:((nInstrumentedClasses / nClasses * 100) asFixedPoint:1)). |
|
204 |
Stderr nextPutLine:(' Classes, uninstrumented: %1 (%2%%)' bindWith:nUninstrumentedClasses with:((nUninstrumentedClasses / nClasses * 100) asFixedPoint:1)). |
|
205 |
Stderr nextPutLine:(' Classes, partially instrumented: %1 (%2%%)' bindWith:nPartiallyInstrumentedClasses with:((nPartiallyInstrumentedClasses / nClasses * 100) asFixedPoint:1)). |
|
206 |
Stderr nextPutLine:(' Classes, covered: %1 (%2%%)' bindWith:nClassesCompletelyCovered with:((nClassesCompletelyCovered / nClasses * 100) asFixedPoint:1)). |
|
207 |
Stderr nextPutLine:(' Classes, partially covered: %1 (%2%%)' bindWith:nClassesPartiallyCovered with:((nClassesPartiallyCovered / nClasses * 100) asFixedPoint:1)). |
|
208 |
Stderr nextPutLine:(' Classes, uncovered: %1 (%2%%)' bindWith:nClassesUncovered with:((nClassesUncovered / nClasses * 100) asFixedPoint:1)). |
|
209 |
Stderr nextPutLine:(' Methods, overall: %1' bindWith:nMethods). |
|
210 |
Stderr nextPutLine:(' Methods, instrumented: %1 (%2%%)' bindWith:nInstrumentedMethods with:((nInstrumentedMethods / nMethods * 100) asFixedPoint:1)). |
|
211 |
Stderr nextPutLine:(' Methods, uninstrumented: %1 (%2%%)' bindWith:nUninstrumentedMethods with:((nUninstrumentedMethods / nMethods * 100) asFixedPoint:1)). |
|
212 |
Stderr nextPutLine:(' Methods, covered: %1 (%2%%)' bindWith:nMethodsCompletelyCovered with:((nMethodsCompletelyCovered / nMethods * 100) asFixedPoint:1)). |
|
213 |
Stderr nextPutLine:(' Methods, partially covered: %1 (%2%%)' bindWith:nMethodsPartiallyCovered with:((nMethodsPartiallyCovered / nMethods * 100) asFixedPoint:1)). |
|
214 |
Stderr nextPutLine:(' Methods, uncovered: %1 (%2%%)' bindWith:nMethodsUncovered with:((nMethodsUncovered / nMethods * 100) asFixedPoint:1)). |
|
215 |
||
216 |
" |
|
217 |
self dumpCoverageInformation |
|
218 |
" |
|
13375 | 219 |
|
220 |
"Created: / 24-05-2011 / 17:08:46 / cg" |
|
13377 | 221 |
"Modified: / 25-05-2011 / 00:10:51 / cg" |
13375 | 222 |
! |
223 |
||
224 |
handleCoverageMeasurementOptionsFromArguments:argv |
|
225 |
"handle the coverage measurement command line argument: |
|
226 |
--coverage |
|
227 |
[+/-]package: <package-pattern> ... do / do not measure in package (regex match) |
|
228 |
[+/-]class: <class-pattern> ... do / do not measure in class (regex match, including nameSpace) |
|
229 |
[+/-]method: <className>#<methodName> ... do / do not measure in method |
|
230 |
||
231 |
adds instrumentation code to all selected methods. |
|
232 |
" |
|
233 |
||
234 |
|idx nextArg done doAdd addNames addMethodNames |
|
13377 | 235 |
anyItem nMethodsInstrumented checkClass checkMethod coverageAction |
13375 | 236 |
includedPackageNames excludedPackageNames |
237 |
includedClassNames excludedClassNames |
|
238 |
includedMethodNames excludedMethodNames| |
|
239 |
||
240 |
" |
|
13376 | 241 |
self handleCoverageMeasurementOptionsFromArguments:#('foo' '--coverage' '+package:' 'expeccoNET:*' '-class:' 'ExpeccoNET::ML' 'ExpeccoNET::LicenseString' ) |
13375 | 242 |
self handleCoverageMeasurementOptionsFromArguments:#('foo' '--coverage' '+package:' 'stx:*') |
243 |
self handleCoverageMeasurementOptionsFromArguments:#('foo' '--coverage' '+package:' 'stx:libtool*') |
|
244 |
self handleCoverageMeasurementOptionsFromArguments:#('foo' '--coverage' '+class:' 'Tools::*' '-class:' 'Tools::StringSearchTool' ) |
|
245 |
self handleCoverageMeasurementOptionsFromArguments:#('foo' '--coverage' '+class:' 'Tools::*Browser*' ) |
|
246 |
self handleCoverageMeasurementOptionsFromArguments:#('foo' '--coverage' '+method:' 'String#at:put:' 'String#at:') |
|
247 |
" |
|
248 |
includedPackageNames := Set new. |
|
249 |
excludedPackageNames := Set new. |
|
250 |
includedClassNames := Set new. |
|
251 |
excludedClassNames := Set new. |
|
252 |
includedMethodNames := Dictionary new. |
|
253 |
excludedMethodNames := Dictionary new. |
|
254 |
||
255 |
idx := argv indexOfAny:#('--coverage'). |
|
256 |
idx == 0 ifTrue:[^ self ]. |
|
257 |
||
258 |
addNames := [:collection | |
|
259 |
[ |
|
260 |
nextArg := argv at:idx ifAbsent:nil. |
|
261 |
nextArg notNil |
|
262 |
and:[ ((nextArg startsWith:'+') or:[(nextArg startsWith:'-')]) not |
|
263 |
and:[ (nextArg endsWith:':') not ]] |
|
264 |
] whileTrue:[ |
|
265 |
collection add:nextArg. |
|
266 |
anyItem := true. |
|
267 |
idx := idx + 1. |
|
268 |
]. |
|
269 |
]. |
|
270 |
||
271 |
addMethodNames := [:collection | |
|
272 |
|idx2 className selector| |
|
273 |
||
274 |
[ |
|
275 |
nextArg := argv at:idx ifAbsent:nil. |
|
276 |
nextArg notNil |
|
277 |
and:[ ((nextArg startsWith:'+') or:[(nextArg startsWith:'-')]) not] |
|
278 |
] whileTrue:[ |
|
279 |
idx2 := nextArg indexOf:$#. |
|
280 |
className := nextArg copyTo:idx2-1. |
|
281 |
selector := nextArg copyFrom:idx2+1. |
|
282 |
(collection at:className ifAbsentPut:[Set new]) add:selector. |
|
283 |
anyItem := true. |
|
284 |
idx := idx + 1. |
|
285 |
]. |
|
286 |
]. |
|
287 |
||
288 |
idx := idx + 1. |
|
289 |
done := false. |
|
290 |
||
291 |
[ |
|
292 |
nextArg := argv at:idx ifAbsent:nil. |
|
293 |
done not |
|
294 |
and:[ nextArg notNil |
|
295 |
and:[ ((nextArg startsWith:'+') or:[(nextArg startsWith:'-')]) ]] |
|
296 |
] whileTrue:[ |
|
297 |
idx := idx + 1. |
|
298 |
doAdd := nextArg first == $+. |
|
299 |
nextArg := nextArg copyFrom:2. |
|
300 |
nextArg = 'package:' ifTrue:[ |
|
301 |
addNames value:(doAdd ifTrue:includedPackageNames ifFalse:excludedPackageNames). |
|
302 |
] ifFalse:[ |
|
303 |
nextArg = 'class:' ifTrue:[ |
|
304 |
addNames value:(doAdd ifTrue:includedClassNames ifFalse:excludedClassNames). |
|
305 |
] ifFalse:[ |
|
306 |
nextArg = 'method:' ifTrue:[ |
|
307 |
addMethodNames value:(doAdd ifTrue:includedMethodNames ifFalse:excludedMethodNames). |
|
308 |
] ifFalse:[ |
|
309 |
done := true |
|
310 |
] |
|
311 |
]. |
|
312 |
]. |
|
313 |
]. |
|
314 |
||
315 |
anyItem ifFalse:[ ^ self ]. |
|
13377 | 316 |
nMethodsInstrumented := 0. |
13375 | 317 |
|
318 |
coverageAction := [:aMethod | |
|
319 |
((aMethod sends:#subclassResponsibility) not |
|
320 |
and:[ aMethod hasPrimitiveCode not ]) ifTrue:[ |
|
321 |
Transcript show:'instrumenting '; showCR:aMethod. |
|
322 |
aMethod mclass recompile:aMethod selector usingCompilerClass:InstrumentingCompiler. |
|
13377 | 323 |
nMethodsInstrumented := nMethodsInstrumented + 1. |
13375 | 324 |
] ifFalse:[ |
325 |
Transcript show:'skipped '; showCR:aMethod. |
|
326 |
]. |
|
327 |
]. |
|
328 |
||
329 |
checkMethod := [:someMethod | |
|
330 |
((excludedMethodNames at:someMethod mclass name ifAbsent:#()) includes:someMethod selector) ifFalse:[ |
|
331 |
coverageAction value:someMethod |
|
332 |
]. |
|
333 |
]. |
|
334 |
||
335 |
checkClass := [:someClass | |
|
336 |
someClass instAndClassSelectorsAndMethodsDo:[:sel :mthd | |
|
337 |
checkMethod value:mthd |
|
338 |
] |
|
339 |
]. |
|
340 |
||
341 |
Smalltalk allClassesDo:[:eachClass | |
|
342 |
(includedPackageNames contains:[:somePackagePattern| somePackagePattern match:(eachClass package)]) ifTrue:[ |
|
343 |
(excludedPackageNames contains:[:somePackagePattern| somePackagePattern match:(eachClass package)]) ifFalse:[ |
|
344 |
(excludedClassNames contains:[:someClassPattern| someClassPattern match:(eachClass name)]) ifFalse:[ |
|
345 |
checkClass value:eachClass |
|
346 |
] |
|
347 |
] |
|
348 |
] ifFalse:[ |
|
349 |
(includedClassNames contains:[:someClassPattern| someClassPattern match:(eachClass name)]) ifTrue:[ |
|
350 |
(excludedClassNames contains:[:someClassPattern| someClassPattern match:(eachClass name)]) ifFalse:[ |
|
351 |
checkClass value:eachClass |
|
352 |
] |
|
353 |
] ifFalse:[ |
|
354 |
(Array with:eachClass theMetaclass with:eachClass) do:[:clsOrMeta | |
|
355 |
|selectors| |
|
356 |
||
357 |
selectors := includedMethodNames at:clsOrMeta name ifAbsent:nil. |
|
358 |
selectors notEmptyOrNil ifTrue:[ |
|
359 |
selectors do:[:eachSelector | |
|
360 |
coverageAction value:(clsOrMeta compiledMethodAt:eachSelector asSymbol). |
|
361 |
]. |
|
362 |
]. |
|
363 |
]. |
|
364 |
]. |
|
365 |
]. |
|
366 |
]. |
|
367 |
||
13377 | 368 |
nMethodsInstrumented ifTrue:[ |
369 |
Transcript show:('%1 methods instrumented' bindWith:nMethodsInstrumented). |
|
13375 | 370 |
Smalltalk addExitBlock:[ self dumpCoverageInformation ]. |
371 |
]. |
|
372 |
||
373 |
"Created: / 24-05-2011 / 16:30:54 / cg" |
|
13377 | 374 |
"Modified: / 24-05-2011 / 18:16:29 / cg" |
13375 | 375 |
! ! |
376 |
||
11361
36d809458749
defaults for allowDebug and allowScripting
Michael Beyl <mb@exept.de>
parents:
11360
diff
changeset
|
377 |
!StandaloneStartup class methodsFor:'defaults'! |
36d809458749
defaults for allowDebug and allowScripting
Michael Beyl <mb@exept.de>
parents:
11360
diff
changeset
|
378 |
|
13375 | 379 |
allowCoverageMeasurementOption |
380 |
"enable/disable the --measureCoverage startup options. |
|
381 |
The default is false, so standAlone apps do not support coverage measurements by default. |
|
382 |
Can be redefined in subclasses to enable it |
|
383 |
(but will need the libcomp and possibly the programming/oom packages to be present)" |
|
384 |
||
13378
ed35cb03c4ed
changed: #allowCoverageMeasurementOption
Claus Gittinger <cg@exept.de>
parents:
13377
diff
changeset
|
385 |
^ Smalltalk isStandAloneApp not |
13375 | 386 |
|
387 |
"Created: / 24-05-2011 / 16:16:15 / cg" |
|
13378
ed35cb03c4ed
changed: #allowCoverageMeasurementOption
Claus Gittinger <cg@exept.de>
parents:
13377
diff
changeset
|
388 |
"Modified: / 25-05-2011 / 00:21:18 / cg" |
13375 | 389 |
! |
390 |
||
11361
36d809458749
defaults for allowDebug and allowScripting
Michael Beyl <mb@exept.de>
parents:
11360
diff
changeset
|
391 |
allowDebugOption |
36d809458749
defaults for allowDebug and allowScripting
Michael Beyl <mb@exept.de>
parents:
11360
diff
changeset
|
392 |
"enable/disable the --debug startup option. |
11363 | 393 |
Can be redefined in subclasses to enable it" |
11361
36d809458749
defaults for allowDebug and allowScripting
Michael Beyl <mb@exept.de>
parents:
11360
diff
changeset
|
394 |
|
36d809458749
defaults for allowDebug and allowScripting
Michael Beyl <mb@exept.de>
parents:
11360
diff
changeset
|
395 |
^ false |
36d809458749
defaults for allowDebug and allowScripting
Michael Beyl <mb@exept.de>
parents:
11360
diff
changeset
|
396 |
! |
36d809458749
defaults for allowDebug and allowScripting
Michael Beyl <mb@exept.de>
parents:
11360
diff
changeset
|
397 |
|
36d809458749
defaults for allowDebug and allowScripting
Michael Beyl <mb@exept.de>
parents:
11360
diff
changeset
|
398 |
allowScriptingOption |
36d809458749
defaults for allowDebug and allowScripting
Michael Beyl <mb@exept.de>
parents:
11360
diff
changeset
|
399 |
"enable/disable the --scripting startup option. |
11363 | 400 |
Can be redefined in subclasses to enable it" |
11361
36d809458749
defaults for allowDebug and allowScripting
Michael Beyl <mb@exept.de>
parents:
11360
diff
changeset
|
401 |
|
36d809458749
defaults for allowDebug and allowScripting
Michael Beyl <mb@exept.de>
parents:
11360
diff
changeset
|
402 |
^ false |
36d809458749
defaults for allowDebug and allowScripting
Michael Beyl <mb@exept.de>
parents:
11360
diff
changeset
|
403 |
! |
36d809458749
defaults for allowDebug and allowScripting
Michael Beyl <mb@exept.de>
parents:
11360
diff
changeset
|
404 |
|
36d809458749
defaults for allowDebug and allowScripting
Michael Beyl <mb@exept.de>
parents:
11360
diff
changeset
|
405 |
suppressRCFileReading |
36d809458749
defaults for allowDebug and allowScripting
Michael Beyl <mb@exept.de>
parents:
11360
diff
changeset
|
406 |
"enable/disable the rc-file reading (and also the --rcFileName option). |
36d809458749
defaults for allowDebug and allowScripting
Michael Beyl <mb@exept.de>
parents:
11360
diff
changeset
|
407 |
If suppressed, there is no chance to interfere with the startup. |
36d809458749
defaults for allowDebug and allowScripting
Michael Beyl <mb@exept.de>
parents:
11360
diff
changeset
|
408 |
Can be redefined in subclasses to disable it" |
36d809458749
defaults for allowDebug and allowScripting
Michael Beyl <mb@exept.de>
parents:
11360
diff
changeset
|
409 |
|
36d809458749
defaults for allowDebug and allowScripting
Michael Beyl <mb@exept.de>
parents:
11360
diff
changeset
|
410 |
^ false |
36d809458749
defaults for allowDebug and allowScripting
Michael Beyl <mb@exept.de>
parents:
11360
diff
changeset
|
411 |
! ! |
36d809458749
defaults for allowDebug and allowScripting
Michael Beyl <mb@exept.de>
parents:
11360
diff
changeset
|
412 |
|
9944 | 413 |
!StandaloneStartup class methodsFor:'helpers'! |
414 |
||
11423 | 415 |
printInfo:msg |
416 |
Transcript |
|
417 |
show:('%1 [info]: ' bindWith:(self applicationName)); |
|
418 |
showCR:msg |
|
419 |
! |
|
420 |
||
9944 | 421 |
redirectStandardStreams |
422 |
Stdout := Stderr. |
|
423 |
Transcript := Stderr. |
|
424 |
! |
|
425 |
||
13269 | 426 |
verbose |
427 |
^ Verbose == true |
|
428 |
||
429 |
"Created: / 01-02-2011 / 15:52:47 / cg" |
|
430 |
! |
|
431 |
||
9944 | 432 |
verboseInfo:msg |
18180 | 433 |
Verbose == true ifTrue:[ |
434 |
self printInfo:msg |
|
435 |
] |
|
9944 | 436 |
|
437 |
"Modified: / 19-09-2006 / 16:30:27 / cg" |
|
438 |
! ! |
|
439 |
||
17707 | 440 |
|
11102 | 441 |
!StandaloneStartup class methodsFor:'multiple applications support'! |
442 |
||
443 |
applicationRegistryPath |
|
444 |
"the key under which this application stores its process ID in the registry |
|
445 |
as a collection of path-components. |
|
446 |
i.e. if #('foo' 'bar' 'baz') is returned here, the current applications ID will be stored |
|
447 |
in HKEY_CURRENT_USER\Software\foo\bar\baz\CurrentID. |
|
448 |
(would also be used as a relative path for a temporary lock file under unix). |
|
449 |
Used to detect if another instance of this application is already running." |
|
450 |
||
451 |
self subclassResponsibility |
|
452 |
! |
|
453 |
||
454 |
applicationUUID |
|
455 |
"answer an application-specific unique uuid. |
|
456 |
This is used as the name of some exclusive OS-resource, which is used to find out, |
|
457 |
if another instance of this application is already running. |
|
13595
c0db78969b83
comment/format in: #applicationUUID
Claus Gittinger <cg@exept.de>
parents:
13580
diff
changeset
|
458 |
Under win32, a mutex is used; under unix, an exclusive file in the tempDir could be used. |
c0db78969b83
comment/format in: #applicationUUID
Claus Gittinger <cg@exept.de>
parents:
13580
diff
changeset
|
459 |
If redefined, please return a real UUID (i.e. UUID fromString:'.....') and not a string or |
c0db78969b83
comment/format in: #applicationUUID
Claus Gittinger <cg@exept.de>
parents:
13580
diff
changeset
|
460 |
similar possibly conflicting identifier. |
c0db78969b83
comment/format in: #applicationUUID
Claus Gittinger <cg@exept.de>
parents:
13580
diff
changeset
|
461 |
You can paste a fresh worldwide unique id via the editor's more-misc-paste UUID menuFunction." |
11102 | 462 |
|
463 |
self subclassResponsibility |
|
13595
c0db78969b83
comment/format in: #applicationUUID
Claus Gittinger <cg@exept.de>
parents:
13580
diff
changeset
|
464 |
|
c0db78969b83
comment/format in: #applicationUUID
Claus Gittinger <cg@exept.de>
parents:
13580
diff
changeset
|
465 |
"Modified (comment): / 19-08-2011 / 01:54:39 / cg" |
11102 | 466 |
! |
467 |
||
12998
c967aa65e09a
Move multiple app support and delayed DLL stuff to StandaloneStartup
Stefan Vogel <sv@exept.de>
parents:
12996
diff
changeset
|
468 |
shouldReuseRunningApplication |
c967aa65e09a
Move multiple app support and delayed DLL stuff to StandaloneStartup
Stefan Vogel <sv@exept.de>
parents:
12996
diff
changeset
|
469 |
"answer true, if an already running application instance should be re-used" |
11102 | 470 |
|
12998
c967aa65e09a
Move multiple app support and delayed DLL stuff to StandaloneStartup
Stefan Vogel <sv@exept.de>
parents:
12996
diff
changeset
|
471 |
^ false |
11102 | 472 |
! ! |
473 |
||
474 |
!StandaloneStartup class methodsFor:'multiple applications support-helpers'! |
|
475 |
||
476 |
applicationRegistryEntry |
|
477 |
"retrieve the registry entry in which (if present), any currently running application |
|
478 |
has left its process ID" |
|
479 |
||
480 |
|path relPathName applicationEntry softwareEntry| |
|
481 |
||
14321
783b5c28f912
changed: #applicationRegistryEntry
Stefan Vogel <sv@exept.de>
parents:
14048
diff
changeset
|
482 |
OperatingSystem isMSWINDOWSlike ifFalse:[^ nil]. |
783b5c28f912
changed: #applicationRegistryEntry
Stefan Vogel <sv@exept.de>
parents:
14048
diff
changeset
|
483 |
|
11102 | 484 |
path := self applicationRegistryPath. |
485 |
relPathName := path asStringWith:$\. |
|
486 |
applicationEntry := Win32OperatingSystem registryEntry key:'HKEY_CURRENT_USER\Software\',relPathName. |
|
487 |
applicationEntry isNil ifTrue:[ |
|
488 |
softwareEntry := Win32OperatingSystem registryEntry key:'HKEY_CURRENT_USER\Software'. |
|
489 |
softwareEntry isNil ifTrue:[ |
|
490 |
Transcript showCR: 'Failed to get Software entry in registry'. |
|
491 |
^ nil. |
|
492 |
]. |
|
11103 | 493 |
|
11102 | 494 |
path do:[:subKey | |
495 |
|subEntry| |
|
496 |
||
11103 | 497 |
subEntry := softwareEntry createSubKeyNamed:subKey. |
11102 | 498 |
subEntry isNil ifTrue:[ |
499 |
Transcript showCR: 'Failed to create ',subKey,' entry in registry'. |
|
500 |
^ nil. |
|
501 |
]. |
|
502 |
softwareEntry := subEntry. |
|
503 |
]. |
|
504 |
applicationEntry := softwareEntry. |
|
505 |
]. |
|
506 |
^ applicationEntry |
|
507 |
! |
|
508 |
||
12998
c967aa65e09a
Move multiple app support and delayed DLL stuff to StandaloneStartup
Stefan Vogel <sv@exept.de>
parents:
12996
diff
changeset
|
509 |
checkForAndExitIfAnotherApplicationInstanceIsRunning |
c967aa65e09a
Move multiple app support and delayed DLL stuff to StandaloneStartup
Stefan Vogel <sv@exept.de>
parents:
12996
diff
changeset
|
510 |
"if another instance of this application is running, |
c967aa65e09a
Move multiple app support and delayed DLL stuff to StandaloneStartup
Stefan Vogel <sv@exept.de>
parents:
12996
diff
changeset
|
511 |
send it an openFile command for my file-argument, and exit. |
c967aa65e09a
Move multiple app support and delayed DLL stuff to StandaloneStartup
Stefan Vogel <sv@exept.de>
parents:
12996
diff
changeset
|
512 |
(i.e. to let the already running application open up another window)." |
c967aa65e09a
Move multiple app support and delayed DLL stuff to StandaloneStartup
Stefan Vogel <sv@exept.de>
parents:
12996
diff
changeset
|
513 |
|
c967aa65e09a
Move multiple app support and delayed DLL stuff to StandaloneStartup
Stefan Vogel <sv@exept.de>
parents:
12996
diff
changeset
|
514 |
|shouldExit| |
c967aa65e09a
Move multiple app support and delayed DLL stuff to StandaloneStartup
Stefan Vogel <sv@exept.de>
parents:
12996
diff
changeset
|
515 |
|
13280 | 516 |
self verboseInfo:('check for another app'). |
12998
c967aa65e09a
Move multiple app support and delayed DLL stuff to StandaloneStartup
Stefan Vogel <sv@exept.de>
parents:
12996
diff
changeset
|
517 |
self isAnotherApplicationInstanceRunning ifTrue:[ |
13280 | 518 |
self verboseInfo:('other app is running'). |
12998
c967aa65e09a
Move multiple app support and delayed DLL stuff to StandaloneStartup
Stefan Vogel <sv@exept.de>
parents:
12996
diff
changeset
|
519 |
shouldExit := self processStartupOfASecondInstance. |
c967aa65e09a
Move multiple app support and delayed DLL stuff to StandaloneStartup
Stefan Vogel <sv@exept.de>
parents:
12996
diff
changeset
|
520 |
shouldExit ifTrue:[ |
13280 | 521 |
self verboseInfo:('yes; go away'). |
12998
c967aa65e09a
Move multiple app support and delayed DLL stuff to StandaloneStartup
Stefan Vogel <sv@exept.de>
parents:
12996
diff
changeset
|
522 |
self releaseApplicationMutex. |
c967aa65e09a
Move multiple app support and delayed DLL stuff to StandaloneStartup
Stefan Vogel <sv@exept.de>
parents:
12996
diff
changeset
|
523 |
Smalltalk isStandAloneApp ifTrue:[ |
c967aa65e09a
Move multiple app support and delayed DLL stuff to StandaloneStartup
Stefan Vogel <sv@exept.de>
parents:
12996
diff
changeset
|
524 |
Smalltalk exit. |
c967aa65e09a
Move multiple app support and delayed DLL stuff to StandaloneStartup
Stefan Vogel <sv@exept.de>
parents:
12996
diff
changeset
|
525 |
] |
c967aa65e09a
Move multiple app support and delayed DLL stuff to StandaloneStartup
Stefan Vogel <sv@exept.de>
parents:
12996
diff
changeset
|
526 |
]. |
c967aa65e09a
Move multiple app support and delayed DLL stuff to StandaloneStartup
Stefan Vogel <sv@exept.de>
parents:
12996
diff
changeset
|
527 |
]. |
c967aa65e09a
Move multiple app support and delayed DLL stuff to StandaloneStartup
Stefan Vogel <sv@exept.de>
parents:
12996
diff
changeset
|
528 |
|
13280 | 529 |
"Modified: / 04-02-2011 / 00:04:31 / cg" |
12998
c967aa65e09a
Move multiple app support and delayed DLL stuff to StandaloneStartup
Stefan Vogel <sv@exept.de>
parents:
12996
diff
changeset
|
530 |
! |
c967aa65e09a
Move multiple app support and delayed DLL stuff to StandaloneStartup
Stefan Vogel <sv@exept.de>
parents:
12996
diff
changeset
|
531 |
|
11107 | 532 |
confirmOpenNewApplicationInstance |
533 |
||
534 |
^ Dialog confirm: ('Continue opening a new instance of %1 or exit?' bindWith:self applicationName) |
|
535 |
title: ('%1 is already open!!' bindWith:self applicationName) |
|
536 |
yesLabel: 'Continue' |
|
537 |
noLabel: 'Exit' |
|
538 |
! |
|
539 |
||
11102 | 540 |
currentIDKeyInRegistry |
541 |
^ 'CurrentID' |
|
542 |
! |
|
543 |
||
544 |
getCurrentIDFromRegistry |
|
545 |
||
546 |
|applicationEntry| |
|
547 |
||
548 |
applicationEntry := self applicationRegistryEntry. |
|
549 |
applicationEntry isNil ifTrue:[^ nil.]. |
|
550 |
^ applicationEntry valueNamed: self currentIDKeyInRegistry |
|
551 |
||
552 |
" |
|
553 |
|hWnd externalAddress| |
|
554 |
hWnd := DapasXStartup getCurrentIDFromRegistry. |
|
555 |
hWnd isEmptyOrNil ifTrue:[^ self halt.]. |
|
556 |
hWnd := hWnd asInteger. |
|
557 |
externalAddress := ExternalAddress newAddress: hWnd. |
|
558 |
Display raiseWindow:externalAddress. |
|
559 |
Display setForegroundWindow:externalAddress |
|
560 |
" |
|
561 |
! |
|
562 |
||
563 |
getIDOfRunningApplicationFromRegistryEntry |
|
564 |
|applicationEntry| |
|
565 |
||
566 |
applicationEntry := self applicationRegistryEntry. |
|
567 |
applicationEntry isNil ifTrue:[^ nil.]. |
|
568 |
^ applicationEntry valueNamed: self currentIDKeyInRegistry |
|
569 |
! |
|
570 |
||
571 |
isAnotherApplicationInstanceRunning |
|
13083
66a8fb472eb5
comment/format in: #isAnotherApplicationInstanceRunning
Claus Gittinger <cg@exept.de>
parents:
12999
diff
changeset
|
572 |
"answer true, if another instance of myself is currently running. |
11102 | 573 |
For now, it only works under win32, because it uses the underlying mutex mechanism." |
574 |
||
11106 | 575 |
| lastErrorCode alreadyExists handleAndLastErrorCode | |
11102 | 576 |
|
577 |
OperatingSystem isMSDOSlike ifTrue:[ |
|
13280 | 578 |
self verboseInfo:('create mutex...'). |
11102 | 579 |
handleAndLastErrorCode := OperatingSystem createMutexNamed: (self applicationUUID printString). |
580 |
MutexHandle := handleAndLastErrorCode first. |
|
581 |
lastErrorCode := handleAndLastErrorCode second. |
|
582 |
"/ self assert: lastErrorCode == 0. |
|
583 |
alreadyExists := |
|
584 |
MutexHandle isNil |
|
585 |
or:[lastErrorCode == 183 "ERROR_ALREADY_EXISTS" |
|
586 |
or:[lastErrorCode == 5 "ERROR_ACCESS_DENIED"]]. |
|
587 |
||
13280 | 588 |
self verboseInfo:('alreadyExists = ',alreadyExists printString). |
11102 | 589 |
alreadyExists ifFalse:[OperatingSystem waitForSingleObject: MutexHandle]. |
590 |
^ alreadyExists |
|
591 |
]. |
|
592 |
||
593 |
^ false. |
|
13083
66a8fb472eb5
comment/format in: #isAnotherApplicationInstanceRunning
Claus Gittinger <cg@exept.de>
parents:
12999
diff
changeset
|
594 |
|
13280 | 595 |
"Modified: / 04-02-2011 / 00:05:51 / cg" |
11102 | 596 |
! |
597 |
||
598 |
processStartupOfASecondInstance |
|
599 |
"This is executed when I have been started as a second instance of an already running application. |
|
600 |
If I can get the currentID (i.e. windowID) of the first one and there is a command line argument with a file, |
|
12935
49210cf2d978
comment/format in: #processStartupOfASecondInstance
Claus Gittinger <cg@exept.de>
parents:
12933
diff
changeset
|
601 |
send a message to the main window of the already running application, to ask it for another window. |
11102 | 602 |
If the currentID is unknown, ask if the user wants to open a new instance of the application anyway. |
603 |
Return true if the first instance has been notified, and this second instance should exit." |
|
604 |
||
11107 | 605 |
|currentIDStringFromRegistry currentIDFromRegistry fileArg commands aWindowId setForegroundWindowSucceeded| |
11102 | 606 |
|
12998
c967aa65e09a
Move multiple app support and delayed DLL stuff to StandaloneStartup
Stefan Vogel <sv@exept.de>
parents:
12996
diff
changeset
|
607 |
commands := CommandLineArguments. |
11102 | 608 |
|
609 |
currentIDStringFromRegistry := self getCurrentIDFromRegistry. |
|
610 |
||
611 |
"If the currentID is not found and there are arguments from the command line, |
|
612 |
we should wait in case of starting the first instance of the application |
|
613 |
with a multiple selection of files." |
|
614 |
(currentIDStringFromRegistry isEmptyOrNil and:[commands notEmptyOrNil]) ifTrue:[ |
|
615 |
Delay waitForSeconds: 2. |
|
616 |
]. |
|
617 |
||
618 |
currentIDStringFromRegistry := self getCurrentIDFromRegistry. |
|
619 |
currentIDStringFromRegistry isEmptyOrNil ifTrue:[ |
|
11107 | 620 |
^ self confirmOpenNewApplicationInstance not. |
11102 | 621 |
]. |
622 |
||
11107 | 623 |
currentIDFromRegistry := Integer readFrom:currentIDStringFromRegistry onError: 0. |
11102 | 624 |
|
625 |
"/ bring the other application to the foreground |
|
626 |
aWindowId := ExternalAddress newAddress: currentIDFromRegistry. |
|
11107 | 627 |
setForegroundWindowSucceeded := Display primSetForegroundWindow: aWindowId. |
11379 | 628 |
"/ setForegroundWindowSucceeded ifFalse:[^ self confirmOpenNewApplicationInstance not]. |
11102 | 629 |
|
630 |
"Autostart for associated extension" |
|
631 |
commands notEmpty ifTrue:[ |
|
632 |
fileArg := commands last asFilename. |
|
633 |
fileArg exists ifTrue:[ |
|
634 |
self sendOpenPathCommand:(fileArg pathName) toWindowId: aWindowId. |
|
635 |
]. |
|
636 |
]. |
|
637 |
^ true |
|
12935
49210cf2d978
comment/format in: #processStartupOfASecondInstance
Claus Gittinger <cg@exept.de>
parents:
12933
diff
changeset
|
638 |
|
49210cf2d978
comment/format in: #processStartupOfASecondInstance
Claus Gittinger <cg@exept.de>
parents:
12933
diff
changeset
|
639 |
"Modified: / 08-07-2010 / 00:47:44 / cg" |
11102 | 640 |
! |
641 |
||
642 |
releaseApplicationMutex |
|
643 |
||
12933
4e196c41604d
changed: #releaseApplicationMutex set MutexHandle to nil
ca
parents:
12626
diff
changeset
|
644 |
(MutexHandle notNil and:[OperatingSystem isMSDOSlike]) ifTrue:[ |
4e196c41604d
changed: #releaseApplicationMutex set MutexHandle to nil
ca
parents:
12626
diff
changeset
|
645 |
OperatingSystem releaseMutex: MutexHandle. |
4e196c41604d
changed: #releaseApplicationMutex set MutexHandle to nil
ca
parents:
12626
diff
changeset
|
646 |
OperatingSystem primCloseHandle: MutexHandle. |
4e196c41604d
changed: #releaseApplicationMutex set MutexHandle to nil
ca
parents:
12626
diff
changeset
|
647 |
|
4e196c41604d
changed: #releaseApplicationMutex set MutexHandle to nil
ca
parents:
12626
diff
changeset
|
648 |
MutexHandle := nil. |
11102 | 649 |
]. |
650 |
! |
|
651 |
||
652 |
sendCommand:message toWindowId:aWindowId |
|
653 |
"use the event send mechanism to forward a command to the already running application" |
|
654 |
||
655 |
Display |
|
656 |
sendCopyDataString: message |
|
657 |
toWindowId: aWindowId. |
|
658 |
! |
|
659 |
||
660 |
sendOpenPathCommand:pathName toWindowId:aWindowId |
|
661 |
"use the event send mechanism to forward an open-Path command to the already running application" |
|
662 |
||
663 |
self sendCommand:('openPath:', pathName) toWindowId:aWindowId. |
|
664 |
! |
|
665 |
||
666 |
writeCurrentIDIntoRegistry: currentID |
|
667 |
||
11104 | 668 |
|applicationEntry currentIDEntry| |
11102 | 669 |
|
11104 | 670 |
applicationEntry := self applicationRegistryEntry. |
671 |
applicationEntry isNil ifTrue:[^ false.]. |
|
11102 | 672 |
|
11104 | 673 |
currentIDEntry := applicationEntry createSubKeyNamed:(self currentIDKeyInRegistry). |
11102 | 674 |
currentIDEntry isNil ifTrue:[ |
675 |
Transcript showCR: 'Failed to create CurrentID entry in registry'. |
|
676 |
^ false. |
|
677 |
]. |
|
678 |
||
11104 | 679 |
^ applicationEntry valueNamed:(self currentIDKeyInRegistry) put:(currentID printString). |
11102 | 680 |
|
681 |
" |
|
682 |
| currentID returnedCurrentID | |
|
683 |
currentID := 999. |
|
684 |
DapasXStartup writeCurrentIDIntoRegistry: currentID. |
|
685 |
returnedCurrentID := DapasXStartup getCurrentIDFromRegistry. |
|
686 |
self assert: currentID = returnedCurrentID asNumber. |
|
687 |
" |
|
688 |
! ! |
|
689 |
||
9944 | 690 |
!StandaloneStartup class methodsFor:'queries'! |
691 |
||
692 |
applicationName |
|
11352 | 693 |
"used in verbose messages - can/should be redefined in subclasses" |
9944 | 694 |
|
695 |
|nm| |
|
696 |
||
697 |
nm := self nameWithoutPrefix. |
|
698 |
(nm endsWith:'Startup') ifTrue:[ |
|
15162
f17158d75a0e
Changed usage of deprecated #copyWithoutLast: to #copyButLast:
Stefan Vogel <sv@exept.de>
parents:
14977
diff
changeset
|
699 |
^ nm copyButLast:('Startup' size). |
9944 | 700 |
]. |
701 |
(nm endsWith:'Start') ifTrue:[ |
|
15162
f17158d75a0e
Changed usage of deprecated #copyWithoutLast: to #copyButLast:
Stefan Vogel <sv@exept.de>
parents:
14977
diff
changeset
|
702 |
^ nm copyButLast:('Start' size). |
9944 | 703 |
]. |
704 |
^ nm |
|
705 |
||
706 |
"Created: / 19-09-2006 / 16:26:44 / cg" |
|
707 |
! |
|
708 |
||
14544 | 709 |
commandLineArguments |
710 |
^ CommandLineArguments |
|
711 |
! |
|
712 |
||
10040
59d0c20b139f
protocol for startability via browser slightly changed
Claus Gittinger <cg@exept.de>
parents:
9944
diff
changeset
|
713 |
isBrowserStartable |
59d0c20b139f
protocol for startability via browser slightly changed
Claus Gittinger <cg@exept.de>
parents:
9944
diff
changeset
|
714 |
"do not allow clicking on me in the browser" |
59d0c20b139f
protocol for startability via browser slightly changed
Claus Gittinger <cg@exept.de>
parents:
9944
diff
changeset
|
715 |
|
59d0c20b139f
protocol for startability via browser slightly changed
Claus Gittinger <cg@exept.de>
parents:
9944
diff
changeset
|
716 |
^ false |
59d0c20b139f
protocol for startability via browser slightly changed
Claus Gittinger <cg@exept.de>
parents:
9944
diff
changeset
|
717 |
|
59d0c20b139f
protocol for startability via browser slightly changed
Claus Gittinger <cg@exept.de>
parents:
9944
diff
changeset
|
718 |
"Created: / 06-10-2006 / 11:33:13 / cg" |
59d0c20b139f
protocol for startability via browser slightly changed
Claus Gittinger <cg@exept.de>
parents:
9944
diff
changeset
|
719 |
! |
59d0c20b139f
protocol for startability via browser slightly changed
Claus Gittinger <cg@exept.de>
parents:
9944
diff
changeset
|
720 |
|
12626
f85aaddaea1d
added: keepSplashWindowOpen
Claus Gittinger <cg@exept.de>
parents:
12523
diff
changeset
|
721 |
keepSplashWindowOpen |
f85aaddaea1d
added: keepSplashWindowOpen
Claus Gittinger <cg@exept.de>
parents:
12523
diff
changeset
|
722 |
"if true is returned here, the splashWindow is not closed and will be still open |
f85aaddaea1d
added: keepSplashWindowOpen
Claus Gittinger <cg@exept.de>
parents:
12523
diff
changeset
|
723 |
when the main: method is invoked. This allows for plugin-loads etc. to be shown in the |
f85aaddaea1d
added: keepSplashWindowOpen
Claus Gittinger <cg@exept.de>
parents:
12523
diff
changeset
|
724 |
splash screen. However, my subclass's main: has to make sure that the splashScreen is closed. |
f85aaddaea1d
added: keepSplashWindowOpen
Claus Gittinger <cg@exept.de>
parents:
12523
diff
changeset
|
725 |
(calling hideSplashWindow) |
f85aaddaea1d
added: keepSplashWindowOpen
Claus Gittinger <cg@exept.de>
parents:
12523
diff
changeset
|
726 |
The default is false here which means that the splashWindow will be already closed when the |
f85aaddaea1d
added: keepSplashWindowOpen
Claus Gittinger <cg@exept.de>
parents:
12523
diff
changeset
|
727 |
subclasses main: is invoked." |
f85aaddaea1d
added: keepSplashWindowOpen
Claus Gittinger <cg@exept.de>
parents:
12523
diff
changeset
|
728 |
|
f85aaddaea1d
added: keepSplashWindowOpen
Claus Gittinger <cg@exept.de>
parents:
12523
diff
changeset
|
729 |
^ false |
f85aaddaea1d
added: keepSplashWindowOpen
Claus Gittinger <cg@exept.de>
parents:
12523
diff
changeset
|
730 |
! |
f85aaddaea1d
added: keepSplashWindowOpen
Claus Gittinger <cg@exept.de>
parents:
12523
diff
changeset
|
731 |
|
15818 | 732 |
patchesDirectory |
733 |
"answer a directory containing patches. |
|
734 |
The directory needs not to be present." |
|
735 |
||
736 |
^ OperatingSystem pathOfSTXExecutable asFilename directory construct:'patches'. |
|
737 |
! |
|
738 |
||
9944 | 739 |
startupFilename |
11352 | 740 |
"used in verbose messages - can/should be redefined in subclasses" |
9944 | 741 |
|
742 |
^ self applicationName asLowercase,'Start.rc' |
|
743 |
||
744 |
" |
|
11352 | 745 |
ExpeccoStartup startupFilename -> 'expecco.rc' |
9944 | 746 |
" |
747 |
||
748 |
"Created: / 19-09-2006 / 16:38:28 / cg" |
|
749 |
! ! |
|
750 |
||
751 |
!StandaloneStartup class methodsFor:'startup'! |
|
752 |
||
13375 | 753 |
handleRCFileOptionsFromArguments:argv |
754 |
"handle rc-file command line arguments: |
|
755 |
--rcFileName ......... define a startup rc-file |
|
756 |
" |
|
757 |
||
758 |
|idx nextArg rcFilename| |
|
759 |
||
760 |
idx := argv indexOf:'--rcFileName'. |
|
761 |
idx ~~ 0 ifTrue:[ |
|
762 |
nextArg := argv at:(idx + 1) ifAbsent:nil. |
|
763 |
(nextArg notNil and:[ (nextArg startsWith:'-') not ]) ifTrue:[ |
|
764 |
rcFilename := nextArg. |
|
765 |
argv removeAtIndex:idx+1; removeAtIndex:idx. |
|
766 |
] |
|
767 |
]. |
|
768 |
||
769 |
rcFilename isNil ifTrue:[ |
|
770 |
rcFilename := self startupFilename. |
|
771 |
]. |
|
772 |
rcFilename asFilename exists ifTrue:[ |
|
773 |
self verboseInfo:('reading ',rcFilename,'...'). |
|
774 |
rcFilename isAbsolute ifFalse:[ |
|
775 |
rcFilename := OperatingSystem pathOfSTXExecutable asFilename directory constructString:rcFilename. |
|
776 |
]. |
|
777 |
Smalltalk secureFileIn:rcFilename |
|
778 |
]. |
|
779 |
||
780 |
"Created: / 24-05-2011 / 16:13:34 / cg" |
|
781 |
! |
|
782 |
||
783 |
handleScriptingOptionsFromArguments:argv |
|
784 |
"handle scripting command line argument: |
|
785 |
--scripting portNr ... start a scripting server |
|
786 |
--allowHost host ..... add host to the allowed scripting hosts |
|
787 |
" |
|
788 |
||
789 |
|scripting idx nextArg portNr allowedScriptingHosts| |
|
790 |
||
791 |
scripting := false. |
|
792 |
||
13376 | 793 |
idx := argv indexOfAny:#('--scripting'). |
794 |
idx ~~ 0 ifTrue:[ |
|
795 |
nextArg := argv at:(idx + 1) ifAbsent:nil. |
|
796 |
(nextArg notNil and:[ (nextArg startsWith:'-') not ]) ifTrue:[ |
|
797 |
portNr := nextArg asInteger. |
|
798 |
argv removeAtIndex:idx+1. |
|
13375 | 799 |
]. |
13376 | 800 |
argv removeAtIndex:idx. |
13375 | 801 |
|
13376 | 802 |
scripting := true |
803 |
]. |
|
804 |
||
805 |
allowedScriptingHosts := OrderedCollection new. |
|
13375 | 806 |
|
13376 | 807 |
idx := argv indexOfAny:#('--allowHost'). |
808 |
[idx ~~ 0] whileTrue:[ |
|
809 |
nextArg := argv at:(idx + 1) ifAbsent:nil. |
|
810 |
nextArg isNil ifTrue:[ |
|
811 |
self usage. |
|
812 |
AbortOperationRequest raise. |
|
813 |
]. |
|
814 |
allowedScriptingHosts add:nextArg. |
|
13375 | 815 |
idx := argv indexOfAny:#('--allowHost'). |
816 |
]. |
|
817 |
||
818 |
scripting ifTrue:[ |
|
819 |
self verboseInfo:('scripting on'). |
|
16131 | 820 |
STXScriptingServer isNil ifTrue:[ |
16237 | 821 |
[ |
822 |
Smalltalk loadPackage:'stx:goodies/simpleServices'. |
|
823 |
] on:PackageLoadError do:[:ex| |
|
824 |
self verboseInfo:('missing STXScriptingServer package (stx:goodies/simpleServices)'). |
|
825 |
^ self. |
|
826 |
] |
|
16131 | 827 |
]. |
13375 | 828 |
STXScriptingServer notNil ifTrue:[ |
829 |
allowedScriptingHosts do:[:eachHost | STXScriptingServer allowHost:eachHost ]. |
|
830 |
||
831 |
"/ scripting on port/stdin_out/8008 |
|
832 |
self verboseInfo:('start scripting'). |
|
833 |
STXScriptingServer startAt:portNr |
|
834 |
] ifFalse:[ |
|
835 |
self verboseInfo:('missing STXScriptingServer class'). |
|
836 |
]. |
|
837 |
]. |
|
838 |
||
839 |
"Created: / 24-05-2011 / 16:12:02 / cg" |
|
13376 | 840 |
"Modified: / 24-05-2011 / 17:40:26 / cg" |
13375 | 841 |
! |
842 |
||
11055
e600e19e2e7f
loadPatch extracted to be redefinable.
Claus Gittinger <cg@exept.de>
parents:
10956
diff
changeset
|
843 |
loadPatch:fileName |
11056
e2c4a6e948b6
loadPatch extracted to be redefinable.
Claus Gittinger <cg@exept.de>
parents:
11055
diff
changeset
|
844 |
self verboseInfo:('loading patch: ',fileName baseName). |
15899 | 845 |
[ |
16307 | 846 |
Smalltalk silentFileIn:fileName. |
15899 | 847 |
] on:InvalidPatchError do:[:ex| |
848 |
self verboseInfo:('invalid patch: %1 error: %2' |
|
849 |
bindWith:fileName baseName with:ex messageText). |
|
850 |
^ false. |
|
851 |
]. |
|
852 |
^ true |
|
11055
e600e19e2e7f
loadPatch extracted to be redefinable.
Claus Gittinger <cg@exept.de>
parents:
10956
diff
changeset
|
853 |
! |
e600e19e2e7f
loadPatch extracted to be redefinable.
Claus Gittinger <cg@exept.de>
parents:
10956
diff
changeset
|
854 |
|
9944 | 855 |
loadPatches |
13796 | 856 |
"load all patches in the application's patches dir" |
857 |
||
15504 | 858 |
self possiblyCheckForNewPatchesOnServer. |
13796 | 859 |
self loadPatchesMatching:nil. |
860 |
! |
|
861 |
||
862 |
loadPatchesMatching:aGlobString |
|
15502 | 863 |
"load the patches in the application's patches dir. |
13796 | 864 |
If aGlobString ist not empty or nil, only patches matching the glob |
865 |
pattern are loaded. E.g. '[0-9]*.chg'" |
|
866 |
||
15894 | 867 |
|patchesDir prevMode patchesToLoad| |
9944 | 868 |
|
18525
6b76f94a31ae
allow for patchesDirectory to return a string
Claus Gittinger <cg@exept.de>
parents:
18180
diff
changeset
|
869 |
patchesDir := self patchesDirectory asFilename. |
15818 | 870 |
patchesDir isDirectory ifTrue:[ |
11764
89c0c60feb24
Discard source code of patches that are loaded at startup
Stefan Vogel <sv@exept.de>
parents:
11753
diff
changeset
|
871 |
prevMode := ClassCategoryReader sourceMode. |
89c0c60feb24
Discard source code of patches that are loaded at startup
Stefan Vogel <sv@exept.de>
parents:
11753
diff
changeset
|
872 |
ClassCategoryReader sourceMode:#discard. |
89c0c60feb24
Discard source code of patches that are loaded at startup
Stefan Vogel <sv@exept.de>
parents:
11753
diff
changeset
|
873 |
[ |
15894 | 874 |
patchesToLoad := patchesDir directoryContentsAsFilenames. |
15818 | 875 |
patchesToLoad := patchesToLoad select:[:eachFilenameString| |
876 |
eachFilenameString asFilename isRegularFile |
|
877 |
]. |
|
13796 | 878 |
aGlobString notEmptyOrNil ifTrue:[ |
15894 | 879 |
patchesToLoad := patchesToLoad select:[:eachFilename| |
880 |
aGlobString match:eachFilename baseName caseSensitive:false |
|
13796 | 881 |
]. |
882 |
]. |
|
15894 | 883 |
(patchesToLoad sort:[:a :b | a baseName < b baseName]) do:[:patchFile | |
884 |
self loadPatch:patchFile. |
|
11764
89c0c60feb24
Discard source code of patches that are loaded at startup
Stefan Vogel <sv@exept.de>
parents:
11753
diff
changeset
|
885 |
]. |
89c0c60feb24
Discard source code of patches that are loaded at startup
Stefan Vogel <sv@exept.de>
parents:
11753
diff
changeset
|
886 |
] ensure:[ |
89c0c60feb24
Discard source code of patches that are loaded at startup
Stefan Vogel <sv@exept.de>
parents:
11753
diff
changeset
|
887 |
ClassCategoryReader sourceMode:prevMode. |
9944 | 888 |
]. |
889 |
]. |
|
890 |
||
891 |
"Modified: / 19-09-2006 / 16:30:58 / cg" |
|
15827 | 892 |
"Modified: / 25-11-2013 / 12:27:33 / sr" |
9944 | 893 |
! |
894 |
||
12998
c967aa65e09a
Move multiple app support and delayed DLL stuff to StandaloneStartup
Stefan Vogel <sv@exept.de>
parents:
12996
diff
changeset
|
895 |
loadRemainingClassLibraries |
c967aa65e09a
Move multiple app support and delayed DLL stuff to StandaloneStartup
Stefan Vogel <sv@exept.de>
parents:
12996
diff
changeset
|
896 |
"To speedup startup, we did not load all dll's (only a subset of non-GUI dll's is present). |
c967aa65e09a
Move multiple app support and delayed DLL stuff to StandaloneStartup
Stefan Vogel <sv@exept.de>
parents:
12996
diff
changeset
|
897 |
Now, load all skipped libs (the ones marked with '*') from modules.stx." |
c967aa65e09a
Move multiple app support and delayed DLL stuff to StandaloneStartup
Stefan Vogel <sv@exept.de>
parents:
12996
diff
changeset
|
898 |
|
c967aa65e09a
Move multiple app support and delayed DLL stuff to StandaloneStartup
Stefan Vogel <sv@exept.de>
parents:
12996
diff
changeset
|
899 |
|modulesFile dllDirectory dlls| |
c967aa65e09a
Move multiple app support and delayed DLL stuff to StandaloneStartup
Stefan Vogel <sv@exept.de>
parents:
12996
diff
changeset
|
900 |
|
c967aa65e09a
Move multiple app support and delayed DLL stuff to StandaloneStartup
Stefan Vogel <sv@exept.de>
parents:
12996
diff
changeset
|
901 |
OperatingSystem isMSWINDOWSlike ifFalse:[^ self ]. |
c967aa65e09a
Move multiple app support and delayed DLL stuff to StandaloneStartup
Stefan Vogel <sv@exept.de>
parents:
12996
diff
changeset
|
902 |
|
c967aa65e09a
Move multiple app support and delayed DLL stuff to StandaloneStartup
Stefan Vogel <sv@exept.de>
parents:
12996
diff
changeset
|
903 |
self verboseInfo:'loadRemainingClassLibraries'. |
c967aa65e09a
Move multiple app support and delayed DLL stuff to StandaloneStartup
Stefan Vogel <sv@exept.de>
parents:
12996
diff
changeset
|
904 |
modulesFile := self stxModulesFilename. |
c967aa65e09a
Move multiple app support and delayed DLL stuff to StandaloneStartup
Stefan Vogel <sv@exept.de>
parents:
12996
diff
changeset
|
905 |
dllDirectory := modulesFile directory. |
c967aa65e09a
Move multiple app support and delayed DLL stuff to StandaloneStartup
Stefan Vogel <sv@exept.de>
parents:
12996
diff
changeset
|
906 |
|
c967aa65e09a
Move multiple app support and delayed DLL stuff to StandaloneStartup
Stefan Vogel <sv@exept.de>
parents:
12996
diff
changeset
|
907 |
dlls := OrderedCollection new. |
c967aa65e09a
Move multiple app support and delayed DLL stuff to StandaloneStartup
Stefan Vogel <sv@exept.de>
parents:
12996
diff
changeset
|
908 |
|
c967aa65e09a
Move multiple app support and delayed DLL stuff to StandaloneStartup
Stefan Vogel <sv@exept.de>
parents:
12996
diff
changeset
|
909 |
modulesFile readingLinesDo:[:eachModulesLine| |
c967aa65e09a
Move multiple app support and delayed DLL stuff to StandaloneStartup
Stefan Vogel <sv@exept.de>
parents:
12996
diff
changeset
|
910 |
|basename dllFile| |
c967aa65e09a
Move multiple app support and delayed DLL stuff to StandaloneStartup
Stefan Vogel <sv@exept.de>
parents:
12996
diff
changeset
|
911 |
|
c967aa65e09a
Move multiple app support and delayed DLL stuff to StandaloneStartup
Stefan Vogel <sv@exept.de>
parents:
12996
diff
changeset
|
912 |
basename := eachModulesLine withoutSeparators. |
c967aa65e09a
Move multiple app support and delayed DLL stuff to StandaloneStartup
Stefan Vogel <sv@exept.de>
parents:
12996
diff
changeset
|
913 |
|
c967aa65e09a
Move multiple app support and delayed DLL stuff to StandaloneStartup
Stefan Vogel <sv@exept.de>
parents:
12996
diff
changeset
|
914 |
(basename notEmpty and:[basename first == $*]) ifTrue:[ |
c967aa65e09a
Move multiple app support and delayed DLL stuff to StandaloneStartup
Stefan Vogel <sv@exept.de>
parents:
12996
diff
changeset
|
915 |
basename := (basename copyFrom:2) withoutSeparators, '.dll'. |
c967aa65e09a
Move multiple app support and delayed DLL stuff to StandaloneStartup
Stefan Vogel <sv@exept.de>
parents:
12996
diff
changeset
|
916 |
dllFile := dllDirectory construct:basename. |
c967aa65e09a
Move multiple app support and delayed DLL stuff to StandaloneStartup
Stefan Vogel <sv@exept.de>
parents:
12996
diff
changeset
|
917 |
|
c967aa65e09a
Move multiple app support and delayed DLL stuff to StandaloneStartup
Stefan Vogel <sv@exept.de>
parents:
12996
diff
changeset
|
918 |
dllFile exists ifTrue:[ |
c967aa65e09a
Move multiple app support and delayed DLL stuff to StandaloneStartup
Stefan Vogel <sv@exept.de>
parents:
12996
diff
changeset
|
919 |
"/ self verboseInfo:('loading: ', basename). |
13580
e5383cbbf032
changed: #loadRemainingClassLibraries
Claus Gittinger <cg@exept.de>
parents:
13378
diff
changeset
|
920 |
"/ Smalltalk showSplashMessage:('loading ', basename). |
12998
c967aa65e09a
Move multiple app support and delayed DLL stuff to StandaloneStartup
Stefan Vogel <sv@exept.de>
parents:
12996
diff
changeset
|
921 |
dlls add:dllFile. |
c967aa65e09a
Move multiple app support and delayed DLL stuff to StandaloneStartup
Stefan Vogel <sv@exept.de>
parents:
12996
diff
changeset
|
922 |
] ifFalse:[ |
c967aa65e09a
Move multiple app support and delayed DLL stuff to StandaloneStartup
Stefan Vogel <sv@exept.de>
parents:
12996
diff
changeset
|
923 |
self verboseInfo:( '**** cannot resolve: ', basename). |
c967aa65e09a
Move multiple app support and delayed DLL stuff to StandaloneStartup
Stefan Vogel <sv@exept.de>
parents:
12996
diff
changeset
|
924 |
]. |
c967aa65e09a
Move multiple app support and delayed DLL stuff to StandaloneStartup
Stefan Vogel <sv@exept.de>
parents:
12996
diff
changeset
|
925 |
]. |
c967aa65e09a
Move multiple app support and delayed DLL stuff to StandaloneStartup
Stefan Vogel <sv@exept.de>
parents:
12996
diff
changeset
|
926 |
]. |
c967aa65e09a
Move multiple app support and delayed DLL stuff to StandaloneStartup
Stefan Vogel <sv@exept.de>
parents:
12996
diff
changeset
|
927 |
|
c967aa65e09a
Move multiple app support and delayed DLL stuff to StandaloneStartup
Stefan Vogel <sv@exept.de>
parents:
12996
diff
changeset
|
928 |
dlls notEmpty ifTrue:[ |
c967aa65e09a
Move multiple app support and delayed DLL stuff to StandaloneStartup
Stefan Vogel <sv@exept.de>
parents:
12996
diff
changeset
|
929 |
ObjectFileLoader loadObjectFiles:dlls. |
13322
8a1d5d6205cc
changed: #loadRemainingClassLibraries
Stefan Vogel <sv@exept.de>
parents:
13280
diff
changeset
|
930 |
ProjectDefinition initializeAllProjectDefinitions. |
8a1d5d6205cc
changed: #loadRemainingClassLibraries
Stefan Vogel <sv@exept.de>
parents:
13280
diff
changeset
|
931 |
|
12998
c967aa65e09a
Move multiple app support and delayed DLL stuff to StandaloneStartup
Stefan Vogel <sv@exept.de>
parents:
12996
diff
changeset
|
932 |
Display notNil ifTrue:[ |
c967aa65e09a
Move multiple app support and delayed DLL stuff to StandaloneStartup
Stefan Vogel <sv@exept.de>
parents:
12996
diff
changeset
|
933 |
"New view classes may have been loaded - have to update their styles" |
c967aa65e09a
Move multiple app support and delayed DLL stuff to StandaloneStartup
Stefan Vogel <sv@exept.de>
parents:
12996
diff
changeset
|
934 |
self verboseInfo:'update style caches of loaded dlls'. |
12999
a5ab22c6470c
changed: #loadRemainingClassLibraries
Stefan Vogel <sv@exept.de>
parents:
12998
diff
changeset
|
935 |
SimpleView readStyleSheetAndUpdateAllStyleCaches. |
12998
c967aa65e09a
Move multiple app support and delayed DLL stuff to StandaloneStartup
Stefan Vogel <sv@exept.de>
parents:
12996
diff
changeset
|
936 |
]. |
c967aa65e09a
Move multiple app support and delayed DLL stuff to StandaloneStartup
Stefan Vogel <sv@exept.de>
parents:
12996
diff
changeset
|
937 |
]. |
13580
e5383cbbf032
changed: #loadRemainingClassLibraries
Claus Gittinger <cg@exept.de>
parents:
13378
diff
changeset
|
938 |
|
e5383cbbf032
changed: #loadRemainingClassLibraries
Claus Gittinger <cg@exept.de>
parents:
13378
diff
changeset
|
939 |
"Modified: / 11-08-2011 / 17:23:55 / cg" |
12998
c967aa65e09a
Move multiple app support and delayed DLL stuff to StandaloneStartup
Stefan Vogel <sv@exept.de>
parents:
12996
diff
changeset
|
940 |
! |
c967aa65e09a
Move multiple app support and delayed DLL stuff to StandaloneStartup
Stefan Vogel <sv@exept.de>
parents:
12996
diff
changeset
|
941 |
|
15503 | 942 |
possiblyCheckForNewPatchesOnServer |
943 |
"to be redefined in concrete applications: check fo patches on a server" |
|
944 |
||
945 |
"/ intentionally left blank |
|
946 |
! |
|
947 |
||
15830 | 948 |
removeDebugger |
949 |
Smalltalk at:#Debugger put:nil. |
|
950 |
! |
|
951 |
||
952 |
removeInspector |
|
953 |
Smalltalk at:#Inspector put:nil. |
|
954 |
! |
|
955 |
||
956 |
removeLauncher |
|
957 |
NewLauncher notNil ifTrue:[ |
|
958 |
NewLauncher allPrivateClasses do:[:cls | |
|
959 |
Smalltalk at:(cls name) put:nil. |
|
960 |
]. |
|
961 |
Smalltalk at:#NewLauncher put:nil. |
|
962 |
]. |
|
963 |
! |
|
964 |
||
9944 | 965 |
setupSmalltalkFromArguments:argv |
11352 | 966 |
"handle common command line arguments: |
967 |
--help ............... print usage and exit |
|
968 |
--verbose (-V) ....... be verbose during startup |
|
969 |
--debug .............. enable debugger & inspector |
|
970 |
--rcFileName ......... define a startup rc-file |
|
11435 | 971 |
--scripting portNr ... start a scripting server |
972 |
--allowHost host ..... add host to the allowed scripting hosts |
|
11352 | 973 |
" |
974 |
||
16235 | 975 |
|idx debugging baseDir| |
9944 | 976 |
|
977 |
"/ Smalltalk beHeadless:true. |
|
978 |
"/ OperatingSystem disableSignal:(OperatingSystem sigHUP). |
|
979 |
"/ Smalltalk infoPrinting:true. |
|
980 |
||
981 |
(argv includes:'--help') ifTrue:[ |
|
982 |
self usage. |
|
983 |
AbortOperationRequest raise. |
|
984 |
]. |
|
985 |
||
986 |
idx := argv indexOfAny:#('--verbose' '-V'). |
|
987 |
idx ~~ 0 ifTrue:[ |
|
988 |
argv removeAtIndex:idx. |
|
989 |
Verbose := true. |
|
990 |
]. |
|
10773 | 991 |
self verboseInfo:('args: ',argv asArray printString). |
9944 | 992 |
|
11352 | 993 |
debugging := false. |
994 |
(self allowDebugOption) ifTrue:[ |
|
13126
8cbc00290e5b
changed: #setupSmalltalkFromArguments:
Claus Gittinger <cg@exept.de>
parents:
13089
diff
changeset
|
995 |
idx := argv indexOf:'--debug'. |
11352 | 996 |
idx ~~ 0 ifTrue:[ |
11357 | 997 |
self verboseInfo:('debug on'). |
11352 | 998 |
argv removeAtIndex:idx. |
999 |
debugging := true |
|
1000 |
]. |
|
1001 |
]. |
|
1002 |
debugging ifTrue:[ |
|
9944 | 1003 |
self setupToolsForDebug. |
1004 |
] ifFalse:[ |
|
1005 |
self setupToolsForNoDebug. |
|
1006 |
]. |
|
16236 | 1007 |
baseDir := OperatingSystem pathOfSTXExecutable asFilename directory. |
1008 |
baseDir baseName = 'application' ifTrue:[ |
|
1009 |
".../work/exept/expecco/application/expecco -> .../work/" |
|
1010 |
baseDir := baseDir directory directory directory. |
|
1011 |
Smalltalk packagePath |
|
1012 |
add:(baseDir pathName). |
|
1013 |
] ifFalse:[ |
|
1014 |
"/opt/expecco/bin/expecco -> /opt/expecco/" |
|
1015 |
baseDir := baseDir directory. |
|
1016 |
Smalltalk packagePath |
|
1017 |
add:(baseDir constructString:'packages'). |
|
1018 |
]. |
|
9944 | 1019 |
|
13375 | 1020 |
(self suppressRCFileReading) ifFalse:[ |
1021 |
self handleRCFileOptionsFromArguments:argv. |
|
9944 | 1022 |
]. |
11352 | 1023 |
(self allowScriptingOption) ifTrue:[ |
13375 | 1024 |
self handleScriptingOptionsFromArguments:argv. |
9944 | 1025 |
]. |
13375 | 1026 |
(self allowCoverageMeasurementOption) ifTrue:[ |
1027 |
self handleCoverageMeasurementOptionsFromArguments:argv. |
|
9944 | 1028 |
]. |
11352 | 1029 |
|
9944 | 1030 |
^ true |
1031 |
||
13375 | 1032 |
"Modified: / 24-05-2011 / 16:14:45 / cg" |
9944 | 1033 |
! |
1034 |
||
11355 | 1035 |
setupToolsForDebug |
1036 |
Debugger := DebugView ? MiniDebugger. |
|
1037 |
Inspector := InspectorView ? MiniInspector. |
|
11736 | 1038 |
Verbose ifTrue:[ 'debug enabled - CTRL-C brings you into a debugger.' errorPrintCR ]. |
1039 |
"/ self verboseInfo:('debug enabled - CTRL-C brings you into a debugger.'). |
|
9944 | 1040 |
|
1041 |
"Created: / 19-09-2006 / 16:40:32 / cg" |
|
1042 |
! |
|
1043 |
||
11355 | 1044 |
setupToolsForNoDebug |
1045 |
Smalltalk isStandAloneApp ifTrue:[ |
|
15830 | 1046 |
self removeDebugger. |
1047 |
self removeInspector. |
|
1048 |
||
11736 | 1049 |
Verbose ifTrue:[ 'debug disabled.' errorPrintCR ]. |
11355 | 1050 |
self redirectStandardStreams. |
10773 | 1051 |
]. |
9944 | 1052 |
|
1053 |
"Created: / 19-09-2006 / 16:40:47 / cg" |
|
10773 | 1054 |
"Modified: / 31-10-2007 / 16:18:40 / cg" |
9944 | 1055 |
! |
1056 |
||
11355 | 1057 |
start |
12992 | 1058 |
GenericException handle:[:ex | |
1059 |
self verboseInfo:('Error during startup:'). |
|
1060 |
self verboseInfo:(ex description). |
|
12996 | 1061 |
Verbose == true ifTrue:[ex suspendedContext fullPrintAllLevels:10]. |
12992 | 1062 |
ex reject. |
1063 |
] do:[ |
|
12998
c967aa65e09a
Move multiple app support and delayed DLL stuff to StandaloneStartup
Stefan Vogel <sv@exept.de>
parents:
12996
diff
changeset
|
1064 |
|idx| |
13127 | 1065 |
|
13130 | 1066 |
Smalltalk showSplashMessage:('start'). |
12998
c967aa65e09a
Move multiple app support and delayed DLL stuff to StandaloneStartup
Stefan Vogel <sv@exept.de>
parents:
12996
diff
changeset
|
1067 |
self verboseInfo:('starting...'). |
12992 | 1068 |
CommandLineArguments := (self additionalArgumentsFromRegistry) |
1069 |
, Smalltalk commandLineArguments. |
|
9944 | 1070 |
|
12992 | 1071 |
self verboseInfo:('args: ', CommandLineArguments asStringCollection asString). |
1072 |
||
13089 | 1073 |
"--newAppInstance - do not reuse an existing application instance, |
12998
c967aa65e09a
Move multiple app support and delayed DLL stuff to StandaloneStartup
Stefan Vogel <sv@exept.de>
parents:
12996
diff
changeset
|
1074 |
but run in a separate process" |
13089 | 1075 |
idx := CommandLineArguments indexOfAny:#('--newAppInstance'). |
12998
c967aa65e09a
Move multiple app support and delayed DLL stuff to StandaloneStartup
Stefan Vogel <sv@exept.de>
parents:
12996
diff
changeset
|
1076 |
idx == 0 ifTrue:[ |
c967aa65e09a
Move multiple app support and delayed DLL stuff to StandaloneStartup
Stefan Vogel <sv@exept.de>
parents:
12996
diff
changeset
|
1077 |
self shouldReuseRunningApplication ifTrue:[ |
13280 | 1078 |
self verboseInfo:('should reuse app'). |
12998
c967aa65e09a
Move multiple app support and delayed DLL stuff to StandaloneStartup
Stefan Vogel <sv@exept.de>
parents:
12996
diff
changeset
|
1079 |
"Multiple Application support: |
c967aa65e09a
Move multiple app support and delayed DLL stuff to StandaloneStartup
Stefan Vogel <sv@exept.de>
parents:
12996
diff
changeset
|
1080 |
if another expecco is running, ask it to open another window for me. |
c967aa65e09a
Move multiple app support and delayed DLL stuff to StandaloneStartup
Stefan Vogel <sv@exept.de>
parents:
12996
diff
changeset
|
1081 |
If that is the case, the following function will not return, but instead exit." |
c967aa65e09a
Move multiple app support and delayed DLL stuff to StandaloneStartup
Stefan Vogel <sv@exept.de>
parents:
12996
diff
changeset
|
1082 |
self checkForAndExitIfAnotherApplicationInstanceIsRunning. |
c967aa65e09a
Move multiple app support and delayed DLL stuff to StandaloneStartup
Stefan Vogel <sv@exept.de>
parents:
12996
diff
changeset
|
1083 |
]. |
c967aa65e09a
Move multiple app support and delayed DLL stuff to StandaloneStartup
Stefan Vogel <sv@exept.de>
parents:
12996
diff
changeset
|
1084 |
] ifFalse:[ |
c967aa65e09a
Move multiple app support and delayed DLL stuff to StandaloneStartup
Stefan Vogel <sv@exept.de>
parents:
12996
diff
changeset
|
1085 |
CommandLineArguments removeAtIndex:idx. |
c967aa65e09a
Move multiple app support and delayed DLL stuff to StandaloneStartup
Stefan Vogel <sv@exept.de>
parents:
12996
diff
changeset
|
1086 |
]. |
c967aa65e09a
Move multiple app support and delayed DLL stuff to StandaloneStartup
Stefan Vogel <sv@exept.de>
parents:
12996
diff
changeset
|
1087 |
|
c967aa65e09a
Move multiple app support and delayed DLL stuff to StandaloneStartup
Stefan Vogel <sv@exept.de>
parents:
12996
diff
changeset
|
1088 |
"/ Arrive here, if no other application is running. |
c967aa65e09a
Move multiple app support and delayed DLL stuff to StandaloneStartup
Stefan Vogel <sv@exept.de>
parents:
12996
diff
changeset
|
1089 |
"/ to speedup startup, we did not load all dll's (only a subset of non-GUI dll's is present). |
c967aa65e09a
Move multiple app support and delayed DLL stuff to StandaloneStartup
Stefan Vogel <sv@exept.de>
parents:
12996
diff
changeset
|
1090 |
"/ now, load all skipped libs from modules.stx. |
c967aa65e09a
Move multiple app support and delayed DLL stuff to StandaloneStartup
Stefan Vogel <sv@exept.de>
parents:
12996
diff
changeset
|
1091 |
self loadRemainingClassLibraries. |
c967aa65e09a
Move multiple app support and delayed DLL stuff to StandaloneStartup
Stefan Vogel <sv@exept.de>
parents:
12996
diff
changeset
|
1092 |
|
12992 | 1093 |
Smalltalk isStandAloneApp ifTrue:[ |
1094 |
self loadPatches. |
|
1095 |
self verboseInfo:('setup Smalltalk'). |
|
1096 |
]. |
|
1097 |
self setupSmalltalkFromArguments:CommandLineArguments. |
|
1098 |
self main |
|
9944 | 1099 |
]. |
1100 |
||
13280 | 1101 |
"Modified: / 04-02-2011 / 00:03:47 / cg" |
9944 | 1102 |
! |
1103 |
||
11807
f9e3c45c53c8
Moved #startStartBlockProcess from ExpeccoStandaloneStartup
Stefan Vogel <sv@exept.de>
parents:
11806
diff
changeset
|
1104 |
startStartBlockProcess |
f9e3c45c53c8
Moved #startStartBlockProcess from ExpeccoStandaloneStartup
Stefan Vogel <sv@exept.de>
parents:
11806
diff
changeset
|
1105 |
Smalltalk startStartBlockProcess |
f9e3c45c53c8
Moved #startStartBlockProcess from ExpeccoStandaloneStartup
Stefan Vogel <sv@exept.de>
parents:
11806
diff
changeset
|
1106 |
! |
f9e3c45c53c8
Moved #startStartBlockProcess from ExpeccoStandaloneStartup
Stefan Vogel <sv@exept.de>
parents:
11806
diff
changeset
|
1107 |
|
12998
c967aa65e09a
Move multiple app support and delayed DLL stuff to StandaloneStartup
Stefan Vogel <sv@exept.de>
parents:
12996
diff
changeset
|
1108 |
stxModulesFilename |
c967aa65e09a
Move multiple app support and delayed DLL stuff to StandaloneStartup
Stefan Vogel <sv@exept.de>
parents:
12996
diff
changeset
|
1109 |
"answer the Filename of modules.stx" |
c967aa65e09a
Move multiple app support and delayed DLL stuff to StandaloneStartup
Stefan Vogel <sv@exept.de>
parents:
12996
diff
changeset
|
1110 |
|
c967aa65e09a
Move multiple app support and delayed DLL stuff to StandaloneStartup
Stefan Vogel <sv@exept.de>
parents:
12996
diff
changeset
|
1111 |
|file| |
c967aa65e09a
Move multiple app support and delayed DLL stuff to StandaloneStartup
Stefan Vogel <sv@exept.de>
parents:
12996
diff
changeset
|
1112 |
|
c967aa65e09a
Move multiple app support and delayed DLL stuff to StandaloneStartup
Stefan Vogel <sv@exept.de>
parents:
12996
diff
changeset
|
1113 |
file := 'modules.stx' asFilename. |
c967aa65e09a
Move multiple app support and delayed DLL stuff to StandaloneStartup
Stefan Vogel <sv@exept.de>
parents:
12996
diff
changeset
|
1114 |
file exists ifTrue:[^ file]. |
c967aa65e09a
Move multiple app support and delayed DLL stuff to StandaloneStartup
Stefan Vogel <sv@exept.de>
parents:
12996
diff
changeset
|
1115 |
|
c967aa65e09a
Move multiple app support and delayed DLL stuff to StandaloneStartup
Stefan Vogel <sv@exept.de>
parents:
12996
diff
changeset
|
1116 |
file := OperatingSystem pathOfSTXExecutable asFilename directory construct:'modules.stx'. |
c967aa65e09a
Move multiple app support and delayed DLL stuff to StandaloneStartup
Stefan Vogel <sv@exept.de>
parents:
12996
diff
changeset
|
1117 |
file exists ifTrue:[^ file]. |
c967aa65e09a
Move multiple app support and delayed DLL stuff to StandaloneStartup
Stefan Vogel <sv@exept.de>
parents:
12996
diff
changeset
|
1118 |
|
c967aa65e09a
Move multiple app support and delayed DLL stuff to StandaloneStartup
Stefan Vogel <sv@exept.de>
parents:
12996
diff
changeset
|
1119 |
self error:'cannot find: modules.stx'. |
c967aa65e09a
Move multiple app support and delayed DLL stuff to StandaloneStartup
Stefan Vogel <sv@exept.de>
parents:
12996
diff
changeset
|
1120 |
! |
c967aa65e09a
Move multiple app support and delayed DLL stuff to StandaloneStartup
Stefan Vogel <sv@exept.de>
parents:
12996
diff
changeset
|
1121 |
|
11355 | 1122 |
usage |
13089 | 1123 |
Stderr nextPutLine:'usage: ',self applicationName,' [options...]'. |
1124 |
Stderr nextPutLine:' --help .................. output this message'. |
|
1125 |
Stderr nextPutLine:' --verbose ............... verbose startup'. |
|
17707 | 1126 |
self isHeadless ifFalse:[ |
1127 |
Stderr nextPutLine:' --noBanner .............. no splash screen'. |
|
1128 |
]. |
|
1129 |
OperatingSystem isMSWINDOWSlike ifTrue:[ |
|
1130 |
Stderr nextPutLine:' --newAppInstance ........ start as its own application process (do not reuse a running instance)'. |
|
1131 |
]. |
|
11352 | 1132 |
self allowScriptingOption ifTrue:[ |
13089 | 1133 |
Stderr nextPutLine:' --scripting portNr ...... enable scripting via port (or stdin/stdOut, if 0)'. |
11352 | 1134 |
]. |
1135 |
self allowDebugOption ifTrue:[ |
|
13089 | 1136 |
Stderr nextPutLine:' --debug ................. enable Debugger'. |
11352 | 1137 |
]. |
13375 | 1138 |
self allowCoverageMeasurementOption ifTrue:[ |
1139 |
Stderr nextPutLine:' --coverage .............. turn on coverage measurement'. |
|
1140 |
Stderr nextPutLine:' [+/-]package: pattern ... - include/exclude packages'. |
|
1141 |
Stderr nextPutLine:' [+/-]class: pattern ... - include/exclude classes'. |
|
1142 |
Stderr nextPutLine:' [+/-]method: cls#sel ... - include/exclude methods'. |
|
1143 |
]. |
|
11352 | 1144 |
self suppressRCFileReading ifFalse:[ |
13089 | 1145 |
Stderr nextPutLine:' --rcFileName file ....... execute code from file on startup (default: ',self startupFilename,')'. |
11352 | 1146 |
]. |
9944 | 1147 |
|
1148 |
"Created: / 19-09-2006 / 16:37:55 / cg" |
|
13375 | 1149 |
"Modified: / 24-05-2011 / 17:23:18 / cg" |
9944 | 1150 |
! ! |
1151 |
||
1152 |
!StandaloneStartup class methodsFor:'startup-to be redefined'! |
|
1153 |
||
12991
f9c0f556ea86
added: #additionalArgumentsFromRegistry
Claus Gittinger <cg@exept.de>
parents:
12988
diff
changeset
|
1154 |
additionalArgumentsFromRegistry |
f9c0f556ea86
added: #additionalArgumentsFromRegistry
Claus Gittinger <cg@exept.de>
parents:
12988
diff
changeset
|
1155 |
"can be redefined to fetch and return additional arguments from the registry |
f9c0f556ea86
added: #additionalArgumentsFromRegistry
Claus Gittinger <cg@exept.de>
parents:
12988
diff
changeset
|
1156 |
(or other .ini file). These are added to the beginning of the command line arguments." |
f9c0f556ea86
added: #additionalArgumentsFromRegistry
Claus Gittinger <cg@exept.de>
parents:
12988
diff
changeset
|
1157 |
|
f9c0f556ea86
added: #additionalArgumentsFromRegistry
Claus Gittinger <cg@exept.de>
parents:
12988
diff
changeset
|
1158 |
^ #() |
f9c0f556ea86
added: #additionalArgumentsFromRegistry
Claus Gittinger <cg@exept.de>
parents:
12988
diff
changeset
|
1159 |
|
f9c0f556ea86
added: #additionalArgumentsFromRegistry
Claus Gittinger <cg@exept.de>
parents:
12988
diff
changeset
|
1160 |
"Created: / 04-08-2010 / 12:20:27 / cg" |
f9c0f556ea86
added: #additionalArgumentsFromRegistry
Claus Gittinger <cg@exept.de>
parents:
12988
diff
changeset
|
1161 |
! |
f9c0f556ea86
added: #additionalArgumentsFromRegistry
Claus Gittinger <cg@exept.de>
parents:
12988
diff
changeset
|
1162 |
|
11806
6508528f9499
Define #isHeadless with default value (false)
Stefan Vogel <sv@exept.de>
parents:
11764
diff
changeset
|
1163 |
isHeadless |
6508528f9499
Define #isHeadless with default value (false)
Stefan Vogel <sv@exept.de>
parents:
11764
diff
changeset
|
1164 |
"this is invoked early by Smalltalk>>mainStartup, to ask if I like to |
6508528f9499
Define #isHeadless with default value (false)
Stefan Vogel <sv@exept.de>
parents:
11764
diff
changeset
|
1165 |
have a Display or if I am a non-GUI headless application. |
6508528f9499
Define #isHeadless with default value (false)
Stefan Vogel <sv@exept.de>
parents:
11764
diff
changeset
|
1166 |
|
6508528f9499
Define #isHeadless with default value (false)
Stefan Vogel <sv@exept.de>
parents:
11764
diff
changeset
|
1167 |
Redefine in subclass, if your application is a non-GUI application" |
6508528f9499
Define #isHeadless with default value (false)
Stefan Vogel <sv@exept.de>
parents:
11764
diff
changeset
|
1168 |
|
6508528f9499
Define #isHeadless with default value (false)
Stefan Vogel <sv@exept.de>
parents:
11764
diff
changeset
|
1169 |
^ false |
6508528f9499
Define #isHeadless with default value (false)
Stefan Vogel <sv@exept.de>
parents:
11764
diff
changeset
|
1170 |
! |
6508528f9499
Define #isHeadless with default value (false)
Stefan Vogel <sv@exept.de>
parents:
11764
diff
changeset
|
1171 |
|
11355 | 1172 |
main |
1173 |
self verboseInfo:('entering main'). |
|
1174 |
||
1175 |
self main:CommandLineArguments. |
|
1176 |
||
1177 |
" |
|
1178 |
self main |
|
1179 |
self main:#('--info') |
|
1180 |
" |
|
1181 |
||
1182 |
"Modified: / 31-10-2007 / 16:03:22 / cg" |
|
10636 | 1183 |
! |
1184 |
||
11355 | 1185 |
main:argv |
1186 |
self subclassResponsibility. |
|
1187 |
||
1188 |
"/ a typical main: looks like (in a subclass): |
|
1189 |
||
1190 |
"/ |app fileArg| |
|
1191 |
"/ |
|
1192 |
"/ self verboseInfo:('starting application'). |
|
14977 | 1193 |
"/ |
1194 |
"/ self startStartBlockProcess. |
|
1195 |
"/ Smalltalk openDisplay. |
|
9944 | 1196 |
"/ app := <someGUIApplicationModelClass> open. |
1197 |
"/ |
|
1198 |
"/ self verboseInfo:('looking for args in ',argv). |
|
1199 |
"/ argv notEmptyOrNil ifTrue:[ |
|
1200 |
"/ fileArg := argv last asFilename. |
|
1201 |
"/ self verboseInfo:('fileArg is ',fileArg name). |
|
1202 |
"/ fileArg exists ifTrue:[ |
|
1203 |
"/ self verboseInfo:('file exists'). |
|
1204 |
"/ |
|
1205 |
"/ ( #('foo' 'bar' 'baz' ) includes:fileArg suffix) ifTrue:[ |
|
1206 |
"/ self verboseInfo:('loading'). |
|
1207 |
"/ |
|
1208 |
"/ Error handle:[:ex | |
|
1209 |
"/ self verboseInfo:'error while loading'. |
|
1210 |
"/ ex suspendedContext fullPrintAll. |
|
1211 |
"/ ] do:[ |
|
1212 |
"/ app menuLoadFromFile:fileArg |
|
1213 |
"/ ]. |
|
1214 |
"/ ]. |
|
1215 |
"/ ]. |
|
1216 |
"/ ]. |
|
1217 |
||
1218 |
"Created: / 19-09-2006 / 16:48:29 / cg" |
|
1219 |
! ! |
|
1220 |
||
1221 |
!StandaloneStartup class methodsFor:'documentation'! |
|
1222 |
||
1223 |
version |
|
18525
6b76f94a31ae
allow for patchesDirectory to return a string
Claus Gittinger <cg@exept.de>
parents:
18180
diff
changeset
|
1224 |
^ '$Header$' |
12335 | 1225 |
! |
1226 |
||
1227 |
version_CVS |
|
18525
6b76f94a31ae
allow for patchesDirectory to return a string
Claus Gittinger <cg@exept.de>
parents:
18180
diff
changeset
|
1228 |
^ '$Header$' |
9944 | 1229 |
! ! |
1230 |
||
14977 | 1231 |
|
9944 | 1232 |
StandaloneStartup initialize! |