1346 createLoadAllFile |
1346 createLoadAllFile |
1347 "creates a 'loadAll' file, which will load all classes |
1347 "creates a 'loadAll' file, which will load all classes |
1348 of the project - this loadAll file is supposed to be located |
1348 of the project - this loadAll file is supposed to be located |
1349 in the projects source directory." |
1349 in the projects source directory." |
1350 |
1350 |
1351 |d f out in topName classes classInfo numBad firstBad msg| |
1351 |d f out in topName classes classInfo numBad firstBad msg methodsFile| |
1352 |
1352 |
1353 classes := self classes. |
1353 classes := self classes. |
1354 numBad := 0. |
1354 numBad := 0. |
1355 firstBad := nil. |
1355 firstBad := nil. |
1356 |
1356 |
1371 cls. |
1371 cls. |
1372 ] ifFalse:[ |
1372 ] ifFalse:[ |
1373 clsOrSymbol |
1373 clsOrSymbol |
1374 ] |
1374 ] |
1375 ]. |
1375 ]. |
|
1376 |
1376 numBad ~~ 0 ifTrue:[ |
1377 numBad ~~ 0 ifTrue:[ |
1377 msg := 'Cannot generate ''loadAll''-file.\\'. |
1378 msg := 'Cannot generate ''loadAll''-file.\\'. |
1378 msg := msg , 'Reason: Class ''' , firstBad asText allBold |
1379 msg := msg , 'Reason: Class ''' , firstBad asText allBold |
1379 , ''' is not loaded.'. |
1380 , ''' is not loaded.'. |
1380 numBad ~~ 1 ifTrue:[ |
1381 numBad ~~ 1 ifTrue:[ |
1401 ]. |
1404 ]. |
1402 |
1405 |
1403 out nextPutAll:'"/ |
1406 out nextPutAll:'"/ |
1404 "/ $' , 'Header' , '$ |
1407 "/ $' , 'Header' , '$ |
1405 "/ |
1408 "/ |
1406 "/ load-file to load code for: ' , self package , ' |
1409 "/ loadAll-file to fileIn code for: ' , self package , ' |
1407 "/ |
1410 "/ |
1408 "/ Automatically generated from project definition. |
1411 "/ Automatically generated from project definition. |
1409 "/ |
1412 "/ |
1410 |
1413 |
1411 "/ |
1414 "/ |
1412 "/ Prerequisites: |
1415 "/ Prerequisites: |
1413 "/ |
1416 "/ |
|
1417 "/ Smalltalk loadPackage:''module:directory''. |
|
1418 "/ Smalltalk loadPackage:''....''. |
|
1419 "/ Smalltalk loadPackage:''....''. |
|
1420 !! |
1414 |
1421 |
1415 "{ package:''' , self package , ''' }"!! |
1422 "{ package:''' , self package , ''' }"!! |
1416 |
1423 |
1417 |files| |
1424 |files| |
1418 |
1425 |
1419 ''loading package ' , self package , ' ...'' printCR. |
1426 ''loading package ' , self package , ' ...'' infoPrintCR. |
1420 |
1427 |
1421 files := #( |
1428 files := #( |
1422 '. |
1429 '. |
1423 |
1430 |
1424 classes do:[:cls | |
1431 classes do:[:cls | |
1425 out nextPutAll:' '''. |
1432 out nextPutAll:' '''. |
1426 cls nameWithoutNameSpacePrefix printOn:out. |
1433 cls nameWithoutNameSpacePrefix printOn:out. |
1427 out nextPutAll:'.st'''. |
1434 out nextPutAll:'.st'''. |
1428 out cr. |
1435 out cr. |
1429 ]. |
1436 ]. |
|
1437 (methodsFile := self propertyAt:#methodsFile) notNil ifTrue:[ |
|
1438 out |
|
1439 nextPutAll:' '''; |
|
1440 nextPutAll:methodsFile; |
|
1441 nextPutAll:''''. |
|
1442 ]. |
1430 |
1443 |
1431 out nextPutAll:') asOrderedCollection. |
1444 out nextPutAll:') asOrderedCollection. |
1432 |
1445 |
1433 (Smalltalk loadClassLibraryIfAbsent:''' , self name , ''') ifTrue:[ |
1446 (Smalltalk loadClassLibraryIfAbsent:''' , self name , ''') ifTrue:[ |
1434 |handle loaded| |
1447 |handle loaded| |
1435 |
1448 |
1436 handle := ObjectFileLoader loadedObjectHandles detect:[:h | |cls| |
1449 handle := ObjectFileLoader loadedObjectHandles |
1437 cls := h classes firstIfEmpty:nil. |
1450 detect:[:h | h package = ''' , self package , '''] ifNone:nil. |
1438 cls notNil and:[cls package = ''' , self package , '''] |
|
1439 ] ifNone:[]. |
|
1440 |
|
1441 handle ifNotNil:[ |
1451 handle ifNotNil:[ |
1442 loaded := Set new:(handle classes size). |
1452 loaded := Set new:(handle classes size). |
1443 handle classes do:[:c| c isMeta ifFalse:[loaded add:c classFilename]]. |
1453 handle classes do:[:c| c isMeta ifFalse:[loaded add:c classFilename]]. |
|
1454 '. |
|
1455 methodsFile notNil ifTrue:[ |
|
1456 out nextPutAll: |
|
1457 ' loaded add:''' , methodsFile , '''.'. |
|
1458 ]. |
|
1459 out nextPutAll:' |
1444 files := files asOrderedCollection select:[:f| (loaded includes:f) not]. |
1460 files := files asOrderedCollection select:[:f| (loaded includes:f) not]. |
1445 ]. |
1461 ]. |
1446 ]. |
1462 ]. |
1447 |
1463 |
1448 files do:[:s | |
1464 files do:[:s | |
1449 ''.'' print. |
1465 ''.'' infoPrint. |
1450 Smalltalk fileIn:s. |
1466 Smalltalk fileIn:s. |
1451 ]. |
1467 ]. |
1452 '' '' printCR. |
1468 '' '' infoPrintCR. |
1453 '' done (' , self package , ').'' printCR. |
1469 '' done (' , self package , ').'' infoPrintCR. |
1454 '. |
1470 '. |
1455 |
1471 |
1456 out close |
1472 out close |
1457 ! |
1473 ! |
1458 |
1474 |
1701 |
1719 |
1702 s nextPutAll:' \'. s cr. |
1720 s nextPutAll:' \'. s cr. |
1703 abbrev := Smalltalk fileNameForClass:aClass name. |
1721 abbrev := Smalltalk fileNameForClass:aClass name. |
1704 s nextPutAll:' '; nextPutAll:abbrev; nextPutAll:'.$(O)'. |
1722 s nextPutAll:' '; nextPutAll:abbrev; nextPutAll:'.$(O)'. |
1705 ]. |
1723 ]. |
|
1724 (methodsFile := self propertyAt:#methodsFile) notNil ifTrue:[ |
|
1725 s nextPutAll:' \'. s cr. |
|
1726 s nextPutAll:' '; |
|
1727 nextPutAll:(methodsFile asFilename withoutSuffix baseName); |
|
1728 nextPutAll:'.$(O)'. |
|
1729 ]. |
1706 s cr. |
1730 s cr. |
1707 |
1731 |
1708 s nextPutAll:' |
1732 s nextPutAll:' |
1709 # add more install actions here |
1733 # add more install actions here |
1710 install:: |
1734 install:: |
1797 classes do:[:aClass | |
1821 classes do:[:aClass | |
1798 aClass isLoaded ifFalse:[ |
1822 aClass isLoaded ifFalse:[ |
1799 aClass autoload. |
1823 aClass autoload. |
1800 ]. |
1824 ]. |
1801 ]. |
1825 ]. |
|
1826 "/ to not list private classes |
|
1827 classes := classes select:[:cls | cls owningClass isNil]. |
1802 classes := classes topologicalSort:[:a :b | a isSubclassOf:b]. |
1828 classes := classes topologicalSort:[:a :b | a isSubclassOf:b]. |
1803 |
1829 |
1804 classes do:[:aClass | |
1830 classes do:[:aClass | |
1805 Transcript show:' ... '; showCR:aClass name, '.st'; endEntry. |
1831 Transcript show:' ... '; showCR:aClass name, '.st'; endEntry. |
1806 aClass fileOutIn:dir |
1832 aClass fileOutIn:dir |