ProjectDefinition.st
changeset 10010 69b2dbff964b
parent 10007 93f73465ef11
child 10011 4df81726da18
equal deleted inserted replaced
10009:72c87816423e 10010:69b2dbff964b
   588 ! !
   588 ! !
   589 
   589 
   590 !ProjectDefinition class methodsFor:'code generation'!
   590 !ProjectDefinition class methodsFor:'code generation'!
   591 
   591 
   592 classNamesAndAttributes_code_ignoreOldDefinition:ignoreOldDefinition
   592 classNamesAndAttributes_code_ignoreOldDefinition:ignoreOldDefinition
       
   593     "generate method code returning all classes of the project.
       
   594      Platform attributes are kept from the old definition.
       
   595      If ignoreOldDefinition is true, the autoload attribute is set/reset if
       
   596      the class is installed as autoloaded in the image. If false, it is taken
       
   597      from an existing definition in #classNamesAndAttributes"
       
   598 
   593     ^ String streamContents:[:s |
   599     ^ String streamContents:[:s |
       
   600         |oldSpec|
       
   601         oldSpec := self classNamesAndAttributes.
       
   602 
   594         s nextPutLine:'classNamesAndAttributes'.
   603         s nextPutLine:'classNamesAndAttributes'.
       
   604         s tab; nextPutLine:'"<className> or (<className> attributes...) in load order"'; cr.
   595         s nextPutLine:'    ^ #('.
   605         s nextPutLine:'    ^ #('.
   596         s tab; nextPutLine:'"/ <className> or (<className> attributes...)'.
       
   597         self searchForClasses do:[:eachClass |
   606         self searchForClasses do:[:eachClass |
   598             |oldSpec attributes oldSpecEntry|
   607             |attributes oldSpecEntry|
   599 
       
   600             oldSpec := self classNamesAndAttributes.
       
   601 
   608 
   602             (eachClass isLoaded not or:[eachClass isPrivate not]) ifTrue:[
   609             (eachClass isLoaded not or:[eachClass isPrivate not]) ifTrue:[
   603                 oldSpecEntry := oldSpec detect:[:entry | entry first = eachClass name] ifNone:nil.
   610                 oldSpecEntry := oldSpec detect:[:entry | entry first = eachClass name] ifNone:nil.
   604                 ignoreOldDefinition ifTrue:[
   611                 ignoreOldDefinition ifTrue:[
   605                     "/ take autoload attribute from current state
   612                     "take autoload attribute from classes state in the image"
   606                     oldSpecEntry notNil ifTrue:[
   613                     oldSpecEntry notNil ifTrue:[
   607                         attributes := oldSpecEntry copyFrom:2.
   614                         attributes := oldSpecEntry copyFrom:2.
   608                         attributes := attributes copyWithout:#autoload.
   615                         attributes := attributes copyWithout:#autoload.
   609                     ] ifFalse:[
   616                     ] ifFalse:[
   610                         attributes := #()
   617                         attributes := #()
   611                     ].
   618                     ].
   612                     eachClass isLoaded ifFalse:[
   619                     eachClass isLoaded ifFalse:[
   613                         attributes isEmpty ifTrue:[
   620                          attributes := attributes copyWith:#autoload.
   614                             attributes := attributes , #( autoload ).
       
   615                         ]
       
   616                     ].
   621                     ].
   617                 ] ifFalse:[
   622                 ] ifFalse:[
   618                     "/ keep any existing attribute
   623                     "keep any existing attribute"
   619                     oldSpecEntry notNil ifTrue:[
   624                     oldSpecEntry notNil ifTrue:[
   620                         attributes := oldSpecEntry copyFrom:2.
   625                         attributes := oldSpecEntry copyFrom:2.
   621                     ] ifFalse:[
   626                     ] ifFalse:[
   622                         attributes := eachClass isLoaded ifTrue:[ #() ] ifFalse:[ #( autoload ) ].
   627                         attributes := eachClass isLoaded ifTrue:[ #() ] ifFalse:[ #(autoload) ].
   623                     ].
   628                     ].
   624                 ].
   629                 ].
   625 
   630 
   626                 s tab.
   631                 s tab; tab.
   627                 attributes isEmptyOrNil ifTrue:[
   632                 attributes isEmptyOrNil ifTrue:[
   628                     s nextPutAll:eachClass name asString storeString.
   633                     eachClass name printOn:s.
   629                 ] ifFalse:[
   634                 ] ifFalse:[
   630                     s nextPutAll:'('; nextPutAll:eachClass name asString storeString.
   635                     s nextPut:$(. eachClass name printOn:s.
   631                     attributes do:[:eachAttribute | s nextPutAll:' '. s nextPutAll:eachAttribute storeString.].
   636                     attributes do:[:eachAttribute | s space. eachAttribute printOn:s.].
   632                     s nextPutAll:')'.
   637                     s nextPut:$).
   633                 ].
   638                 ].
   634                 s cr.
   639                 s cr.
   635              ]
   640              ]
   636         ].
   641         ].
   637         s nextPutLine:'    )'
   642         s nextPutLine:'    )'
   638     ].
   643     ].
   639 
   644 
   640 "
   645 "
   641     stx_libbasic3 classNamesAndAttributes_code
   646     stx_libbasic3 classNamesAndAttributes_code_ignoreOldDefinition:true
   642 "
   647 "
   643 
   648 
   644     "Modified: / 08-08-2006 / 19:24:34 / fm"
   649     "Modified: / 08-08-2006 / 19:24:34 / fm"
   645     "Created: / 17-08-2006 / 21:03:07 / cg"
   650     "Created: / 17-08-2006 / 21:03:07 / cg"
   646     "Modified: / 19-09-2006 / 17:14:17 / cg"
   651     "Modified: / 19-09-2006 / 17:14:17 / cg"
  1651         streamContents:[:s |
  1656         streamContents:[:s |
  1652             |classNames classesLoaded classNamesUnloaded classesSorted classNamesSorted|
  1657             |classNames classesLoaded classNamesUnloaded classesSorted classNamesSorted|
  1653 
  1658 
  1654             classNames := self compiled_classNames_common.
  1659             classNames := self compiled_classNames_common.
  1655             classesLoaded := classNames 
  1660             classesLoaded := classNames 
  1656                         collect:[:nm | |cls| cls := Smalltalk classNamed:nm]
  1661                         collect:[:nm | Smalltalk classNamed:nm]
  1657                         thenSelect:[:cls |  cls notNil and:[cls isLoaded] ].
  1662                         thenSelect:[:cls |  cls notNil and:[cls isLoaded] ].
  1658             classNamesUnloaded := classNames 
  1663             classNamesUnloaded := classNames 
  1659                         select:[:nm | |cls| cls := Smalltalk classNamed:nm. cls isNil or:[cls isLoaded not]].
  1664                         select:[:nm | |cls| cls := Smalltalk classNamed:nm. cls isNil or:[cls isLoaded not]].
  1660 
  1665 
  1661             classesSorted := Class classesSortedByLoadOrder:classesLoaded.
  1666             classesSorted := Class classesSortedByLoadOrder:classesLoaded.
  1662             classNamesSorted := classesSorted collect:[:cls |cls name].
  1667             classNamesSorted := classesSorted collect:[:cls | cls name].
  1663 
  1668 
  1664 
  1669 
  1665             s nextPutAll:'"/
  1670             s nextPutAll:'"/
  1666 "/ $' , 'Header' , '$
  1671 "/ $' , 'Header' , '$
  1667 "/
  1672 "/
  2258                     mappings := self classLine_mappings:className.
  2263                     mappings := self classLine_mappings:className.
  2259                     newClassLine := self replaceMappings:mappings in:classLineTemplate.
  2264                     newClassLine := self replaceMappings:mappings in:classLineTemplate.
  2260                     s nextPutLine:newClassLine
  2265                     s nextPutLine:newClassLine
  2261                 ].
  2266                 ].
  2262             classNames := self compiled_classNames_common.
  2267             classNames := self compiled_classNames_common.
  2263             classesLoaded := classNames 
  2268             classesLoaded := classNames collect:[:eachClassName | Smalltalk classNamed:eachClassName]
  2264                         collect:[:nm | 
  2269                                         thenSelect:[:eachClass | eachClass notNil and:[eachClass isLoaded]].
  2265                             |cls|
       
  2266 
       
  2267                             cls := Smalltalk classNamed:nm
       
  2268                         ]
       
  2269                         thenSelect:[:cls | cls notNil and:[ cls isLoaded ] ].
       
  2270             classNamesUnloaded := classNames 
  2270             classNamesUnloaded := classNames 
  2271                         select:[:nm | 
  2271                         select:[:nm | 
  2272                             |cls|
  2272                             |cls|
  2273 
  2273 
  2274                             cls := Smalltalk classNamed:nm.
  2274                             cls := Smalltalk classNamed:nm.
  2275                             cls isNil or:[ cls isLoaded not ]
  2275                             cls isNil or:[ cls isLoaded not ]
  2276                         ].
  2276                         ].
  2277             classNamesSorted := (Class classesSortedByLoadOrder:classesLoaded) 
  2277             classNamesSorted := (Class classesSortedByLoadOrder:classesLoaded) collect:[:cls | cls name].
  2278                         collect:[:cls | cls name ].
       
  2279             classNamesSorted do:putLineForClassName.
  2278             classNamesSorted do:putLineForClassName.
  2280             classNamesUnloaded do:putLineForClassName.
  2279             classNamesUnloaded do:putLineForClassName.
  2281             self namesAndAttributesIn:(self additionalClassNamesAndAttributes)
  2280             self namesAndAttributesIn:(self additionalClassNamesAndAttributes)
  2282                 do:[:nm :attr | 
  2281                 do:[:nm :attr | 
  2283                     (attr isEmptyOrNil or:[ (attr includes:#autoload) not ]) ifTrue:[
  2282                     (attr isEmptyOrNil or:[ (attr includes:#autoload) not ]) ifTrue:[
  2284                         putLineForClassName value:nm.
  2283                         putLineForClassName value:nm.
  2285                     ].
  2284                     ].
  2286                 ].
  2285                 ].
  2287             #( #('UNIX' unix)
  2286             #( ('UNIX' unix)
  2288              #('WIN32' win32)
  2287                ('WIN32' win32)
  2289              #('VMS' vms)
  2288                ('VMS' vms)
  2290              #('BEOS' beos) ) 
  2289                ('BEOS' beos) ) 
  2291                     pairsDo:[:ifdef :id | 
  2290                     pairsDo:[:ifdef :platformName | 
  2292                         |archClassNames archClassesLoaded|
  2291                         |archClassNames archClassesLoaded|
  2293 
  2292 
  2294                         archClassNames := self compiled_classNamesForPlatform:id.
  2293                         archClassNames := self compiled_classNamesForPlatform:platformName.
  2295                         archClassNames notEmpty ifTrue:[
  2294                         archClassNames notEmpty ifTrue:[
  2296                             s nextPutLine:'#ifdef ' , ifdef.
  2295                             s nextPutLine:'#ifdef ' , ifdef.
  2297                             archClassNames do:[:clsName | 
  2296                             archClassNames do:[:clsName | 
  2298                                 putLineForClassName value:clsName
  2297                                 putLineForClassName value:clsName
  2299                             ].
  2298                             ].
  2303         ]
  2302         ]
  2304 
  2303 
  2305     "
  2304     "
  2306      bosch_dapasx_datenbasis  generateClassLines_libInit_dot_cc
  2305      bosch_dapasx_datenbasis  generateClassLines_libInit_dot_cc
  2307      bosch_dapasx_kernel  generateClassLines_libInit_dot_cc
  2306      bosch_dapasx_kernel  generateClassLines_libInit_dot_cc
  2308      stx_libbasic3 generateClassLines_libInit_dot_cc"
  2307      stx_libbasic3 generateClassLines_libInit_dot_cc
       
  2308     "
       
  2309 
  2309     "Modified: / 16-08-2006 / 18:52:10 / User"
  2310     "Modified: / 16-08-2006 / 18:52:10 / User"
  2310     "Created: / 19-09-2006 / 22:47:50 / cg"
  2311     "Created: / 19-09-2006 / 22:47:50 / cg"
  2311     "Modified: / 20-09-2006 / 11:47:25 / cg"
  2312     "Modified: / 20-09-2006 / 11:47:25 / cg"
  2312 !
  2313 !
  2313 
  2314 
  2407                     s nextPutAll:' $(STCHDR)'.
  2408                     s nextPutAll:' $(STCHDR)'.
  2408                     s cr.
  2409                     s cr.
  2409                 ].
  2410                 ].
  2410             classNames := self compiled_classNames_common.
  2411             classNames := self compiled_classNames_common.
  2411             classesLoaded := classNames 
  2412             classesLoaded := classNames 
  2412                         collect:[:className | 
  2413                         collect:[:className | Smalltalk classNamed:className]
  2413                             |cls|
  2414                         thenSelect:[:cls | cls notNil and:[cls isLoaded]].
  2414 
  2415 
  2415                             cls := Smalltalk classNamed:className
       
  2416                         ]
       
  2417                         thenSelect:[:cls | cls notNil and:[ cls isLoaded ] ].
       
  2418             classesSorted := Class classesSortedByLoadOrder:classesLoaded.
  2416             classesSorted := Class classesSortedByLoadOrder:classesLoaded.
  2419             classesSorted do:putDependencyForClass.
  2417             classesSorted do:putDependencyForClass.
  2420             self namesAndAttributesIn:(self additionalClassNamesAndAttributes)
  2418             self namesAndAttributesIn:(self additionalClassNamesAndAttributes)
  2421                 do:[:className :attr | 
  2419                 do:[:className :attr | 
  2422                     |cls|
  2420                     |cls|
  2427                         ]
  2425                         ]
  2428                     ].
  2426                     ].
  2429                 ].
  2427                 ].
  2430             archClassNames := self compiled_classNamesForPlatform:whichArchitecture.
  2428             archClassNames := self compiled_classNamesForPlatform:whichArchitecture.
  2431             archClassesLoaded := archClassNames 
  2429             archClassesLoaded := archClassNames 
  2432                         collect:[:className | 
  2430                         collect:[:className | Smalltalk classNamed:className]
  2433                             |cls|
       
  2434 
       
  2435                             cls := Smalltalk classNamed:className
       
  2436                         ]
       
  2437                         thenSelect:[:cls | cls notNil and:[ cls isLoaded ] ].
  2431                         thenSelect:[:cls | cls notNil and:[ cls isLoaded ] ].
       
  2432 
  2438             archClassesLoaded notEmpty ifTrue:[
  2433             archClassesLoaded notEmpty ifTrue:[
  2439                 (Class classesSortedByLoadOrder:archClassesLoaded) 
  2434                 (Class classesSortedByLoadOrder:archClassesLoaded) do:putDependencyForClass.
  2440                     do:putDependencyForClass.
       
  2441             ].
  2435             ].
  2442             self hasExtensionMethods ifTrue:putDependencyForExtensions.
  2436             self hasExtensionMethods ifTrue:putDependencyForExtensions.
  2443         ]
  2437         ]
  2444 
  2438 
  2445     "
  2439     "
  2446      stx_libbasic3 generateDependencies:#unix
  2440      stx_libbasic3 generateDependencies:#unix
  2447      stx_libbasic3 generateDependencies:#win32"
  2441      stx_libbasic3 generateDependencies:#win32
       
  2442     "
       
  2443 
  2448     "Modified: / 16-08-2006 / 18:52:10 / User"
  2444     "Modified: / 16-08-2006 / 18:52:10 / User"
  2449     "Created: / 14-09-2006 / 12:38:57 / cg"
  2445     "Created: / 14-09-2006 / 12:38:57 / cg"
  2450     "Modified: / 14-09-2006 / 17:04:21 / cg"
  2446     "Modified: / 14-09-2006 / 17:04:21 / cg"
  2451 !
  2447 !
  2452 
  2448 
  2746 
  2742 
  2747     "Created: / 22-08-2006 / 18:20:09 / cg"
  2743     "Created: / 22-08-2006 / 18:20:09 / cg"
  2748 !
  2744 !
  2749 
  2745 
  2750 searchForClasses
  2746 searchForClasses
  2751     "answer all classes that belong to this project.
  2747     "answer all non-private classes that belong to this project.
  2752      They are sorted in load order"
  2748      They are sorted in load order"
  2753 
  2749 
  2754     ^ Class classesSortedByLoadOrder:(self searchForClassesWithProject: self package) 
  2750     ^ Class classesSortedByLoadOrder:(self searchForClassesWithProject: self package) 
  2755 
  2751 
  2756     "
  2752     "
  2757      self searchForClasses
  2753      stx_libbasic3 searchForClasses
  2758     "
  2754     "
  2759 
  2755 
  2760     "Modified: / 07-08-2006 / 21:56:25 / fm"
  2756     "Modified: / 07-08-2006 / 21:56:25 / fm"
  2761     "Created: / 17-08-2006 / 21:18:30 / cg"
  2757     "Created: / 17-08-2006 / 21:18:30 / cg"
  2762 !
  2758 !
  3200 ! !
  3196 ! !
  3201 
  3197 
  3202 !ProjectDefinition class methodsFor:'documentation'!
  3198 !ProjectDefinition class methodsFor:'documentation'!
  3203 
  3199 
  3204 version
  3200 version
  3205     ^ '$Header: /cvs/stx/stx/libbasic/ProjectDefinition.st,v 1.81 2006-09-22 16:47:25 stefan Exp $'
  3201     ^ '$Header: /cvs/stx/stx/libbasic/ProjectDefinition.st,v 1.82 2006-09-25 19:18:01 stefan Exp $'
  3206 ! !
  3202 ! !
  3207 
  3203 
  3208 ProjectDefinition initialize!
  3204 ProjectDefinition initialize!