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