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