Project.st
changeset 4785 4ced52c817e6
parent 4779 767b94dabb98
child 4786 2375c3d2bffc
equal deleted inserted replaced
4784:8616fba1e9e3 4785:4ced52c817e6
  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:[
  1382         ].
  1383         ].
  1383         self warn:msg withCRs.
  1384         self warn:msg withCRs.
  1384         ^ self.
  1385         ^ self.
  1385     ].
  1386     ].
  1386 
  1387 
       
  1388     "/ to not list private classes
       
  1389     classes := classes select:[:cls | cls owningClass isNil].
  1387     classes := classes copy topologicalSort:[:a :b | b isSubclassOf:a].
  1390     classes := classes copy topologicalSort:[:a :b | b isSubclassOf:a].
  1388 
  1391 
  1389     Transcript showCR:'creating loadAll file'.
  1392     Transcript showCR:'creating loadAll file'.
  1390 
  1393 
  1391     d := directoryName asFilename.
  1394     d := directoryName asFilename.
  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 
  1493 
  1509 
  1494 createProtoMakefile
  1510 createProtoMakefile
  1495     "creates a Make.proto file"
  1511     "creates a Make.proto file"
  1496 
  1512 
  1497     |d f s type appName libName startUpClass startUpSelector
  1513     |d f s type appName libName startUpClass startUpSelector
  1498      topName classes numBad firstBad msg|
  1514      topName classes numBad firstBad msg methodsFile|
  1499 
  1515 
  1500     classes := self classes.
  1516     classes := self classes.
  1501     numBad := 0.
  1517     numBad := 0.
  1502     firstBad := nil.
  1518     firstBad := nil.
  1503 
  1519 
  1529         ].
  1545         ].
  1530         self warn:msg withCRs.
  1546         self warn:msg withCRs.
  1531         ^ self.
  1547         ^ self.
  1532     ].
  1548     ].
  1533 
  1549 
       
  1550     "/ to not list private classes
       
  1551     classes := classes select:[:cls | cls owningClass isNil].
  1534     classes := classes copy topologicalSort:[:a :b | b isSubclassOf:a].
  1552     classes := classes copy topologicalSort:[:a :b | b isSubclassOf:a].
  1535 
  1553 
  1536     topName := self findTopFrom:directoryName.
  1554     topName := self findTopFrom:directoryName.
  1537 
  1555 
  1538 
  1556 
  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
  2569 ! !
  2595 ! !
  2570 
  2596 
  2571 !Project class methodsFor:'documentation'!
  2597 !Project class methodsFor:'documentation'!
  2572 
  2598 
  2573 version
  2599 version
  2574     ^ '$Header: /cvs/stx/stx/libbasic/Project.st,v 1.99 1999-09-20 14:36:21 cg Exp $'
  2600     ^ '$Header: /cvs/stx/stx/libbasic/Project.st,v 1.100 1999-09-22 08:11:02 cg Exp $'
  2575 ! !
  2601 ! !
  2576 Project initialize!
  2602 Project initialize!