2169 StandAlone := aBoolean |
2168 StandAlone := aBoolean |
2170 ! ! |
2169 ! ! |
2171 |
2170 |
2172 !Smalltalk class methodsFor:'private-system management-packages'! |
2171 !Smalltalk class methodsFor:'private-system management-packages'! |
2173 |
2172 |
2174 loadExtensionsForPackage:aPackageId |
2173 basicLoadPackage:aPackageString fromDirectory:packageDirOrStringOrNil asAutoloaded:doLoadAsAutoloaded |
2175 | extensionsLoaded | |
|
2176 |
|
2177 extensionsLoaded := false. |
|
2178 ProgrammingLanguage allDo:[:lang| |
|
2179 extensionsLoaded := extensionsLoaded | (self loadExtensionsForPackage:aPackageId language: lang) |
|
2180 ]. |
|
2181 ^ extensionsLoaded |
|
2182 |
|
2183 "Modified: / 18-02-2007 / 11:03:26 / cg" |
|
2184 "Modified: / 02-01-2010 / 10:43:02 / Jan Vrany <jan.vrany@fit.cvut.cz>" |
|
2185 "Modified (format): / 04-09-2011 / 09:19:24 / cg" |
|
2186 ! |
|
2187 |
|
2188 loadExtensionsForPackage:aPackageId language: language |
|
2189 |mgr packageDirName inStream projectDefinition extensionsFilename mod dir |
|
2190 extensionsRevisionString extensionsRevisionInfo| |
|
2191 |
|
2192 language supportsExtensionMethods ifFalse:[^false]. |
|
2193 |
|
2194 packageDirName := aPackageId copyReplaceAll:$: with:$/. |
|
2195 packageDirName := self getPackageFileName:packageDirName. |
|
2196 |
|
2197 (packageDirName notNil and:[Class tryLocalSourceFirst]) ifTrue:[ |
|
2198 (self loadExtensionsFromDirectory:packageDirName language: language) ifTrue:[ |
|
2199 ^ true. |
|
2200 ]. |
|
2201 packageDirName := nil. "do not try again" |
|
2202 ]. |
|
2203 |
|
2204 " |
|
2205 if there is a sourceCodeManager, ask it first for the extensions |
|
2206 " |
|
2207 (Smalltalk at:#AbstractSourceCodeManager) notNil ifTrue:[ |
|
2208 mgr := AbstractSourceCodeManager managerForPackage: aPackageId |
|
2209 ]. |
|
2210 mgr notNil ifTrue:[ |
|
2211 extensionsFilename := 'extensions.' , language sourceFileSuffix. |
|
2212 |
|
2213 projectDefinition := ProjectDefinition definitionClassForPackage:aPackageId. |
|
2214 projectDefinition notNil ifTrue:[ |
|
2215 mod := aPackageId asPackageId module. |
|
2216 dir := aPackageId asPackageId directory. |
|
2217 extensionsRevisionString := projectDefinition perform:(mgr nameOfVersionMethodForExtensions) ifNotUnderstood:nil. |
|
2218 extensionsRevisionString notNil ifTrue:[ |
|
2219 extensionsRevisionInfo := mgr revisionInfoFromString:extensionsRevisionString inClass:nil. |
|
2220 extensionsRevisionInfo notNil ifTrue:[ |
|
2221 extensionsRevisionInfo fileName = extensionsFilename ifFalse:[ |
|
2222 "JV@2011-10-23: following condition is never satisfied for |
|
2223 filed-in packages. The whole scheme of extensionVersion_XXX |
|
2224 works ONLY for compiled packages as it depends on fact, that |
|
2225 extension Init() routine is called AFTER all classes are inited, |
|
2226 therefore the extensionVersion_XXX methods from extensions.st |
|
2227 overwrites methods coming from package definition class. All this |
|
2228 is so tricky and error prone, that we have to come up with better |
|
2229 solution!!" |
|
2230 packageDirName notNil ifTrue:[ |
|
2231 ^ self loadExtensionsFromDirectory:packageDirName language: language |
|
2232 ] ifFalse:[ |
|
2233 ^ false |
|
2234 ] |
|
2235 ] |
|
2236 ] |
|
2237 ]. |
|
2238 SourceCodeManagerError handle:[:ex | |
|
2239 ] do:[ |
|
2240 inStream := mgr streamForExtensionFile:extensionsFilename package:aPackageId directory:dir module:mod cache:true. |
|
2241 ]. |
|
2242 ]. |
|
2243 inStream isNil ifTrue:[ |
|
2244 SourceCodeManagerError handle:[:ex | |
|
2245 ] do:[ |
|
2246 inStream := mgr getMostRecentSourceStreamForFile:extensionsFilename inPackage:aPackageId. |
|
2247 ]. |
|
2248 ]. |
|
2249 inStream notNil ifTrue:[ |
|
2250 Class withoutUpdatingChangeSetDo:[ |
|
2251 inStream fileIn. |
|
2252 ]. |
|
2253 inStream close. |
|
2254 VerboseLoading ifTrue:[ |
|
2255 Transcript showCR:('loaded extensions for ',aPackageId,' from repository'). |
|
2256 ]. |
|
2257 ^ true |
|
2258 ] |
|
2259 ]. |
|
2260 |
|
2261 packageDirName notNil ifTrue:[ |
|
2262 ^ self loadExtensionsFromDirectory:packageDirName language: language |
|
2263 ]. |
|
2264 ^ false |
|
2265 |
|
2266 "Created: / 02-01-2010 / 10:41:47 / Jan Vrany <jan.vrany@fit.cvut.cz>" |
|
2267 "Modified: / 19-03-2011 / 10:03:56 / Jan Vrany <jan.vrany@fit.cvut.cz>" |
|
2268 "Modified: / 04-11-2011 / 13:41:29 / cg" |
|
2269 "Modified: / 23-10-2011 / 19:35:18 / Jan Vrany <jan.vrany@fit.cvut.cz>" |
|
2270 ! |
|
2271 |
|
2272 loadExtensionsFromDirectory:packageDirOrString |
|
2273 |
|
2274 | extensionsLoaded | |
|
2275 extensionsLoaded := false. |
|
2276 ProgrammingLanguage allDo: |
|
2277 [:lang| |
|
2278 extensionsLoaded := extensionsLoaded | (self loadExtensionsFromDirectory: packageDirOrString language: lang)]. |
|
2279 ^extensionsLoaded |
|
2280 |
|
2281 "Modified: / 02-01-2010 / 10:40:33 / Jan Vrany <jan.vrany@fit.cvut.cz>" |
|
2282 ! |
|
2283 |
|
2284 loadExtensionsFromDirectory:packageDirOrString language: language |
|
2285 |packageDir f| |
|
2286 |
|
2287 packageDir := packageDirOrString asFilename. |
|
2288 |
|
2289 f := packageDir / ('extensions.' , language sourceFileSuffix). |
|
2290 f exists ifTrue:[ |
|
2291 Class withoutUpdatingChangeSetDo:[ |
|
2292 f fileIn. |
|
2293 ]. |
|
2294 VerboseLoading ifTrue:[ |
|
2295 Transcript showCR:('loaded extensions: ' , f pathName). |
|
2296 ]. |
|
2297 ^ true |
|
2298 ]. |
|
2299 ^ true"/false |
|
2300 |
|
2301 "Created: / 02-01-2010 / 10:38:08 / Jan Vrany <jan.vrany@fit.cvut.cz>" |
|
2302 "Modified: / 04-11-2011 / 13:41:19 / cg" |
|
2303 "Modified: / 31-01-2013 / 11:33:48 / Jan Vrany <jan.vrany@fit.cvut.cz>" |
|
2304 ! |
|
2305 |
|
2306 loadPackage:aPackageStringArg asAutoloaded:doLoadAsAutoloaded |
|
2307 "make certain, that some particular package is loaded into the system. |
|
2308 Return true on success, false otherwise." |
|
2309 |
|
2310 |packageId packageString packageDir def sourceCodeManager| |
|
2311 |
|
2312 packageId := aPackageStringArg asPackageId. |
|
2313 packageString := packageId string. |
|
2314 |
|
2315 "if I am here, so must my package" |
|
2316 packageString = self package ifTrue:[^ true]. |
|
2317 |
|
2318 "/ if there is a projectDefinition, let it load itself... |
|
2319 def := packageId projectDefinitionClass. |
|
2320 (def notNil and:[def isLoaded]) ifTrue:[ |
|
2321 def loadAsAutoloaded:doLoadAsAutoloaded. |
|
2322 ^ true. |
|
2323 ]. |
|
2324 |
|
2325 packageDir := self packageDirectoryForPackageId:packageId. |
|
2326 packageDir isNil ifTrue:[ |
|
2327 (packageString includes:$:) ifFalse:[ |
|
2328 "/ assume stx |
|
2329 packageDir := self packageDirectoryForPackageId:('stx:',packageString). |
|
2330 ]. |
|
2331 ]. |
|
2332 |
|
2333 [ |
|
2334 self |
|
2335 loadPackage:packageString |
|
2336 fromDirectory:packageDir |
|
2337 asAutoloaded:doLoadAsAutoloaded. |
|
2338 ] on:PackageLoadError do:[:ex| |
|
2339 AbstractSourceCodeManager notNil ifTrue:[ |
|
2340 sourceCodeManager := AbstractSourceCodeManager sourceCodeManagerForPackage:packageString. |
|
2341 sourceCodeManager notNil ifTrue:[ |
|
2342 ^ sourceCodeManager loadPackageWithId:packageString fromRepositoryAsAutoloaded:doLoadAsAutoloaded |
|
2343 ]. |
|
2344 ]. |
|
2345 ex reject. |
|
2346 ]. |
|
2347 |
|
2348 ^ true |
|
2349 |
|
2350 " |
|
2351 Smalltalk loadPackageWithId:'stx:libbasic' |
|
2352 Smalltalk loadPackageWithId:'stx:goodies/persistency' |
|
2353 Smalltalk loadPackageWithId:'exept:ctypes' |
|
2354 " |
|
2355 |
|
2356 "Modified: / 16-11-2010 / 17:42:49 / cg" |
|
2357 ! |
|
2358 |
|
2359 loadPackage:packageId fromAllSourceFilesInDirectory:aDirectory |
|
2360 "load all source files found in aDirectory and treat them like |
|
2361 a package. Allows for initial import of alien ST-code as a new package. |
|
2362 Experimental." |
|
2363 |
|
2364 |p t new anyFail repeatCount| |
|
2365 |
|
2366 "/ problem: dependencies. |
|
2367 "/ solution: repeat twice, so that superclasses are present the second time |
|
2368 |
|
2369 Class packageQuerySignal answer:packageId asSymbol do:[ |
|
2370 |any| |
|
2371 |
|
2372 repeatCount := 0. |
|
2373 [ |
|
2374 repeatCount := repeatCount + 1. |
|
2375 anyFail := false. |
|
2376 aDirectory directoryContents do:[:file | |
|
2377 |fn| |
|
2378 |
|
2379 fn := aDirectory / file. |
|
2380 (fn hasSuffix:'st') ifTrue:[ |
|
2381 Metaclass confirmationQuerySignal answer:false |
|
2382 do:[ |
|
2383 Error |
|
2384 handle:[:ex | |
|
2385 anyFail := true |
|
2386 ] |
|
2387 do:[ |
|
2388 (self fileIn:fn) ifFalse:[ |
|
2389 anyFail := true |
|
2390 ] ifTrue:[ |
|
2391 any := true. |
|
2392 ] |
|
2393 ] |
|
2394 ] |
|
2395 ] |
|
2396 ]. |
|
2397 any ifFalse:[ |
|
2398 ^ false "/ no file found |
|
2399 ] |
|
2400 ] doWhile:[anyFail and:[repeatCount<2]]. |
|
2401 ]. |
|
2402 |
|
2403 new := (p := Project projectWithId:packageId) isNil. |
|
2404 new ifTrue:[ p := Project new]. |
|
2405 |
|
2406 p name:packageId. |
|
2407 p directory:aDirectory. |
|
2408 p package:packageId. |
|
2409 t := packageId asCollectionOfSubstringsSeparatedByAny:'/\:'. |
|
2410 p repositoryModule:(t first). |
|
2411 p repositoryDirectory:(packageId copyFrom:t first size + 2). |
|
2412 p isLoaded:true. |
|
2413 |
|
2414 new ifTrue:[Project addLoadedProject:p]. |
|
2415 anyFail ifTrue:[ |
|
2416 ^ PackageLoadError raiseRequestWith:packageId. |
|
2417 ]. |
|
2418 ^ true |
|
2419 ! |
|
2420 |
|
2421 loadPackage:packageId fromClassLibrary:aFilename |
|
2422 "load a package from a compiled classLib. |
|
2423 Experimental." |
|
2424 |
|
2425 |p t new| |
|
2426 |
|
2427 (self fileIn:aFilename) ifFalse:[ |
|
2428 (self fileInClassLibrary:aFilename) ifFalse:[ |
|
2429 ^ false. |
|
2430 ] |
|
2431 ]. |
|
2432 |
|
2433 new := (p := Project projectWithId:packageId) isNil. |
|
2434 new ifTrue:[ p := Project new]. |
|
2435 |
|
2436 p name:packageId. |
|
2437 p directory:aFilename directory. |
|
2438 p package:packageId. |
|
2439 t := packageId asCollectionOfSubstringsSeparatedByAny:'/\:'. |
|
2440 p repositoryModule:(t first). |
|
2441 p repositoryDirectory:(packageId copyFrom:t first size + 2). |
|
2442 p isLoaded:true. |
|
2443 |
|
2444 new ifTrue:[Project addLoadedProject:p]. |
|
2445 |
|
2446 ^ true |
|
2447 ! |
|
2448 |
|
2449 loadPackage:aPackageString fromDirectory:packageDirOrStringOrNil asAutoloaded:doLoadAsAutoloaded |
|
2450 "load a package referenced by aPackageString - a string like 'stx:libbasic'. |
2174 "load a package referenced by aPackageString - a string like 'stx:libbasic'. |
2451 The package is either located in packageDirOrStringOrNil, or in the current directory (if nil). |
2175 The package is either located in packageDirOrStringOrNil, or in the current directory (if nil). |
2452 Answer true, if the load succeeded, false if it failed" |
2176 Answer true, if the load succeeded, false if it failed" |
2453 |
2177 |
2454 |packageDirOrNil "shLibName" |
2178 |packageDirOrNil "shLibName" |
2587 Smalltalk loadPackageWithId:'stx:goodies/persistency' |
2311 Smalltalk loadPackageWithId:'stx:goodies/persistency' |
2588 Smalltalk loadPackageWithId:'exept:ctypes' |
2312 Smalltalk loadPackageWithId:'exept:ctypes' |
2589 " |
2313 " |
2590 |
2314 |
2591 "Modified: / 29-07-2011 / 19:55:35 / cg" |
2315 "Modified: / 29-07-2011 / 19:55:35 / cg" |
|
2316 ! |
|
2317 |
|
2318 loadExtensionsForPackage:aPackageId |
|
2319 | extensionsLoaded | |
|
2320 |
|
2321 extensionsLoaded := false. |
|
2322 ProgrammingLanguage allDo:[:lang| |
|
2323 extensionsLoaded := extensionsLoaded | (self loadExtensionsForPackage:aPackageId language: lang) |
|
2324 ]. |
|
2325 ^ extensionsLoaded |
|
2326 |
|
2327 "Modified: / 18-02-2007 / 11:03:26 / cg" |
|
2328 "Modified: / 02-01-2010 / 10:43:02 / Jan Vrany <jan.vrany@fit.cvut.cz>" |
|
2329 "Modified (format): / 04-09-2011 / 09:19:24 / cg" |
|
2330 ! |
|
2331 |
|
2332 loadExtensionsForPackage:aPackageId language: language |
|
2333 |mgr packageDirName inStream projectDefinition extensionsFilename mod dir |
|
2334 extensionsRevisionString extensionsRevisionInfo| |
|
2335 |
|
2336 language supportsExtensionMethods ifFalse:[^false]. |
|
2337 |
|
2338 packageDirName := aPackageId copyReplaceAll:$: with:$/. |
|
2339 packageDirName := self getPackageFileName:packageDirName. |
|
2340 |
|
2341 (packageDirName notNil and:[Class tryLocalSourceFirst]) ifTrue:[ |
|
2342 (self loadExtensionsFromDirectory:packageDirName language: language) ifTrue:[ |
|
2343 ^ true. |
|
2344 ]. |
|
2345 packageDirName := nil. "do not try again" |
|
2346 ]. |
|
2347 |
|
2348 " |
|
2349 if there is a sourceCodeManager, ask it first for the extensions |
|
2350 " |
|
2351 (Smalltalk at:#AbstractSourceCodeManager) notNil ifTrue:[ |
|
2352 mgr := AbstractSourceCodeManager managerForPackage: aPackageId |
|
2353 ]. |
|
2354 mgr notNil ifTrue:[ |
|
2355 extensionsFilename := 'extensions.' , language sourceFileSuffix. |
|
2356 |
|
2357 projectDefinition := ProjectDefinition definitionClassForPackage:aPackageId. |
|
2358 projectDefinition notNil ifTrue:[ |
|
2359 mod := aPackageId asPackageId module. |
|
2360 dir := aPackageId asPackageId directory. |
|
2361 extensionsRevisionString := projectDefinition perform:(mgr nameOfVersionMethodForExtensions) ifNotUnderstood:nil. |
|
2362 extensionsRevisionString notNil ifTrue:[ |
|
2363 extensionsRevisionInfo := mgr revisionInfoFromString:extensionsRevisionString inClass:nil. |
|
2364 extensionsRevisionInfo notNil ifTrue:[ |
|
2365 extensionsRevisionInfo fileName = extensionsFilename ifFalse:[ |
|
2366 "JV@2011-10-23: following condition is never satisfied for |
|
2367 filed-in packages. The whole scheme of extensionVersion_XXX |
|
2368 works ONLY for compiled packages as it depends on fact, that |
|
2369 extension Init() routine is called AFTER all classes are inited, |
|
2370 therefore the extensionVersion_XXX methods from extensions.st |
|
2371 overwrites methods coming from package definition class. All this |
|
2372 is so tricky and error prone, that we have to come up with better |
|
2373 solution!!" |
|
2374 packageDirName notNil ifTrue:[ |
|
2375 ^ self loadExtensionsFromDirectory:packageDirName language: language |
|
2376 ] ifFalse:[ |
|
2377 ^ false |
|
2378 ] |
|
2379 ] |
|
2380 ] |
|
2381 ]. |
|
2382 SourceCodeManagerError handle:[:ex | |
|
2383 ] do:[ |
|
2384 inStream := mgr streamForExtensionFile:extensionsFilename package:aPackageId directory:dir module:mod cache:true. |
|
2385 ]. |
|
2386 ]. |
|
2387 inStream isNil ifTrue:[ |
|
2388 SourceCodeManagerError handle:[:ex | |
|
2389 ] do:[ |
|
2390 inStream := mgr getMostRecentSourceStreamForFile:extensionsFilename inPackage:aPackageId. |
|
2391 ]. |
|
2392 ]. |
|
2393 inStream notNil ifTrue:[ |
|
2394 Class withoutUpdatingChangeSetDo:[ |
|
2395 inStream fileIn. |
|
2396 ]. |
|
2397 inStream close. |
|
2398 VerboseLoading ifTrue:[ |
|
2399 Transcript showCR:('loaded extensions for ',aPackageId,' from repository'). |
|
2400 ]. |
|
2401 ^ true |
|
2402 ] |
|
2403 ]. |
|
2404 |
|
2405 packageDirName notNil ifTrue:[ |
|
2406 ^ self loadExtensionsFromDirectory:packageDirName language: language |
|
2407 ]. |
|
2408 ^ false |
|
2409 |
|
2410 "Created: / 02-01-2010 / 10:41:47 / Jan Vrany <jan.vrany@fit.cvut.cz>" |
|
2411 "Modified: / 19-03-2011 / 10:03:56 / Jan Vrany <jan.vrany@fit.cvut.cz>" |
|
2412 "Modified: / 04-11-2011 / 13:41:29 / cg" |
|
2413 "Modified: / 23-10-2011 / 19:35:18 / Jan Vrany <jan.vrany@fit.cvut.cz>" |
|
2414 ! |
|
2415 |
|
2416 loadExtensionsFromDirectory:packageDirOrString |
|
2417 |
|
2418 | extensionsLoaded | |
|
2419 extensionsLoaded := false. |
|
2420 ProgrammingLanguage allDo: |
|
2421 [:lang| |
|
2422 extensionsLoaded := extensionsLoaded | (self loadExtensionsFromDirectory: packageDirOrString language: lang)]. |
|
2423 ^extensionsLoaded |
|
2424 |
|
2425 "Modified: / 02-01-2010 / 10:40:33 / Jan Vrany <jan.vrany@fit.cvut.cz>" |
|
2426 ! |
|
2427 |
|
2428 loadExtensionsFromDirectory:packageDirOrString language: language |
|
2429 |packageDir f| |
|
2430 |
|
2431 packageDir := packageDirOrString asFilename. |
|
2432 |
|
2433 f := packageDir / ('extensions.' , language sourceFileSuffix). |
|
2434 f exists ifTrue:[ |
|
2435 Class withoutUpdatingChangeSetDo:[ |
|
2436 f fileIn. |
|
2437 ]. |
|
2438 VerboseLoading ifTrue:[ |
|
2439 Transcript showCR:('loaded extensions: ' , f pathName). |
|
2440 ]. |
|
2441 ^ true |
|
2442 ]. |
|
2443 ^ true"/false |
|
2444 |
|
2445 "Created: / 02-01-2010 / 10:38:08 / Jan Vrany <jan.vrany@fit.cvut.cz>" |
|
2446 "Modified: / 04-11-2011 / 13:41:19 / cg" |
|
2447 "Modified: / 31-01-2013 / 11:33:48 / Jan Vrany <jan.vrany@fit.cvut.cz>" |
|
2448 ! |
|
2449 |
|
2450 loadPackage:aPackageStringArg asAutoloaded:doLoadAsAutoloaded |
|
2451 "make certain, that some particular package is loaded into the system. |
|
2452 Return true on success, false otherwise." |
|
2453 |
|
2454 |packageId packageString packageDir def sourceCodeManager| |
|
2455 |
|
2456 packageId := aPackageStringArg asPackageId. |
|
2457 packageString := packageId string. |
|
2458 |
|
2459 "if I am here, so must my package" |
|
2460 packageString = self package ifTrue:[^ true]. |
|
2461 |
|
2462 "/ if there is a projectDefinition, let it load itself... |
|
2463 def := packageId projectDefinitionClass. |
|
2464 (def notNil and:[def isLoaded]) ifTrue:[ |
|
2465 def loadAsAutoloaded:doLoadAsAutoloaded. |
|
2466 ^ true. |
|
2467 ]. |
|
2468 |
|
2469 packageDir := self packageDirectoryForPackageId:packageId. |
|
2470 packageDir isNil ifTrue:[ |
|
2471 (packageString includes:$:) ifFalse:[ |
|
2472 "/ assume stx |
|
2473 packageDir := self packageDirectoryForPackageId:('stx:',packageString). |
|
2474 ]. |
|
2475 ]. |
|
2476 |
|
2477 [ |
|
2478 self |
|
2479 loadPackage:packageString |
|
2480 fromDirectory:packageDir |
|
2481 asAutoloaded:doLoadAsAutoloaded. |
|
2482 ] on:PackageLoadError do:[:ex| |
|
2483 AbstractSourceCodeManager notNil ifTrue:[ |
|
2484 sourceCodeManager := AbstractSourceCodeManager sourceCodeManagerForPackage:packageString. |
|
2485 sourceCodeManager notNil ifTrue:[ |
|
2486 ^ sourceCodeManager loadPackageWithId:packageString fromRepositoryAsAutoloaded:doLoadAsAutoloaded |
|
2487 ]. |
|
2488 ]. |
|
2489 ex reject. |
|
2490 ]. |
|
2491 |
|
2492 ^ true |
|
2493 |
|
2494 " |
|
2495 Smalltalk loadPackageWithId:'stx:libbasic' |
|
2496 Smalltalk loadPackageWithId:'stx:goodies/persistency' |
|
2497 Smalltalk loadPackageWithId:'exept:ctypes' |
|
2498 " |
|
2499 |
|
2500 "Modified: / 16-11-2010 / 17:42:49 / cg" |
|
2501 ! |
|
2502 |
|
2503 loadPackage:packageId fromAllSourceFilesInDirectory:aDirectory |
|
2504 "load all source files found in aDirectory and treat them like |
|
2505 a package. Allows for initial import of alien ST-code as a new package. |
|
2506 Experimental." |
|
2507 |
|
2508 |p t new anyFail repeatCount| |
|
2509 |
|
2510 "/ problem: dependencies. |
|
2511 "/ solution: repeat twice, so that superclasses are present the second time |
|
2512 |
|
2513 Class packageQuerySignal answer:packageId asSymbol do:[ |
|
2514 |any| |
|
2515 |
|
2516 repeatCount := 0. |
|
2517 [ |
|
2518 repeatCount := repeatCount + 1. |
|
2519 anyFail := false. |
|
2520 aDirectory directoryContents do:[:file | |
|
2521 |fn| |
|
2522 |
|
2523 fn := aDirectory / file. |
|
2524 (fn hasSuffix:'st') ifTrue:[ |
|
2525 Metaclass confirmationQuerySignal answer:false |
|
2526 do:[ |
|
2527 Error |
|
2528 handle:[:ex | |
|
2529 anyFail := true |
|
2530 ] |
|
2531 do:[ |
|
2532 (self fileIn:fn) ifFalse:[ |
|
2533 anyFail := true |
|
2534 ] ifTrue:[ |
|
2535 any := true. |
|
2536 ] |
|
2537 ] |
|
2538 ] |
|
2539 ] |
|
2540 ]. |
|
2541 any ifFalse:[ |
|
2542 ^ false "/ no file found |
|
2543 ] |
|
2544 ] doWhile:[anyFail and:[repeatCount<2]]. |
|
2545 ]. |
|
2546 |
|
2547 new := (p := Project projectWithId:packageId) isNil. |
|
2548 new ifTrue:[ p := Project new]. |
|
2549 |
|
2550 p name:packageId. |
|
2551 p directory:aDirectory. |
|
2552 p package:packageId. |
|
2553 t := packageId asCollectionOfSubstringsSeparatedByAny:'/\:'. |
|
2554 p repositoryModule:(t first). |
|
2555 p repositoryDirectory:(packageId copyFrom:t first size + 2). |
|
2556 p isLoaded:true. |
|
2557 |
|
2558 new ifTrue:[Project addLoadedProject:p]. |
|
2559 anyFail ifTrue:[ |
|
2560 ^ PackageLoadError raiseRequestWith:packageId. |
|
2561 ]. |
|
2562 ^ true |
|
2563 ! |
|
2564 |
|
2565 loadPackage:packageId fromClassLibrary:aFilename |
|
2566 "load a package from a compiled classLib. |
|
2567 Experimental." |
|
2568 |
|
2569 |p t new| |
|
2570 |
|
2571 (self fileIn:aFilename) ifFalse:[ |
|
2572 (self fileInClassLibrary:aFilename) ifFalse:[ |
|
2573 ^ false. |
|
2574 ] |
|
2575 ]. |
|
2576 |
|
2577 new := (p := Project projectWithId:packageId) isNil. |
|
2578 new ifTrue:[ p := Project new]. |
|
2579 |
|
2580 p name:packageId. |
|
2581 p directory:aFilename directory. |
|
2582 p package:packageId. |
|
2583 t := packageId asCollectionOfSubstringsSeparatedByAny:'/\:'. |
|
2584 p repositoryModule:(t first). |
|
2585 p repositoryDirectory:(packageId copyFrom:t first size + 2). |
|
2586 p isLoaded:true. |
|
2587 |
|
2588 new ifTrue:[Project addLoadedProject:p]. |
|
2589 |
|
2590 ^ true |
|
2591 ! |
|
2592 |
|
2593 loadPackage:aPackageString fromDirectory:packageDirOrStringOrNil asAutoloaded:doLoadAsAutoloaded |
|
2594 "load a package referenced by aPackageString - a string like 'stx:libbasic'. |
|
2595 The package is either located in packageDirOrStringOrNil, or in the current directory (if nil). |
|
2596 Answer true, if the load succeeded, false if it failed" |
|
2597 |
|
2598 |ret| |
|
2599 |
|
2600 Smalltalk changed:#prePackageLoad with:aPackageString asSymbol. |
|
2601 [ |
|
2602 ret := self basicLoadPackage:aPackageString fromDirectory:packageDirOrStringOrNil asAutoloaded:doLoadAsAutoloaded |
|
2603 ] ensure:[ |
|
2604 Smalltalk changed:#postPackageLoad with:aPackageString asSymbol. |
|
2605 ]. |
|
2606 ^ ret |
2592 ! |
2607 ! |
2593 |
2608 |
2594 loadPackage:packageId fromLoadAllFile:aFilename |
2609 loadPackage:packageId fromLoadAllFile:aFilename |
2595 <resource: #obsolete> |
2610 <resource: #obsolete> |
2596 "load a package from a loadAll - loader script. |
2611 "load a package from a loadAll - loader script. |