ProjectDefinition.st
changeset 10864 512cd79cee0e
parent 10849 3c5732b4c798
child 10869 e8176ae800f0
equal deleted inserted replaced
10863:daabfcda3d90 10864:512cd79cee0e
  1331     "Created: / 07-08-2006 / 19:02:57 / fm"
  1331     "Created: / 07-08-2006 / 19:02:57 / fm"
  1332     "Modified: / 07-08-2006 / 21:25:25 / fm"
  1332     "Modified: / 07-08-2006 / 21:25:25 / fm"
  1333     "Modified: / 21-08-2006 / 18:48:31 / cg"
  1333     "Modified: / 21-08-2006 / 18:48:31 / cg"
  1334 !
  1334 !
  1335 
  1335 
       
  1336 compiled_classNamesForPlatform
       
  1337     "answer the classes to be compiled only for the current platformName"
       
  1338 
       
  1339     ^ self compiled_classNamesForPlatform:OperatingSystem platformName
       
  1340 !
       
  1341 
  1336 compiled_classNamesForPlatform:platformName
  1342 compiled_classNamesForPlatform:platformName
  1337     "answer the classes to be compiled only for platformName
  1343     "answer the classes to be compiled only for platformName
  1338      platformName is one of #unix, #win32 (OperatingSystem platformName)"
  1344      platformName is one of #unix, #win32 (OperatingSystem platformName)"
  1339 
  1345 
  1340     ^ self 
  1346     ^ self 
  1893 ! !
  1899 ! !
  1894 
  1900 
  1895 !ProjectDefinition class methodsFor:'file generation'!
  1901 !ProjectDefinition class methodsFor:'file generation'!
  1896 
  1902 
  1897 basicFileNamesToGenerate
  1903 basicFileNamesToGenerate
  1898     self subclassResponsibility
  1904     "answer a dictionary (filename -> generator method) with all the files, that have to be generated for this
  1899 
  1905      package"
  1900     "Created: / 14-09-2006 / 14:36:31 / cg"
  1906 
       
  1907     |dict|
       
  1908 
       
  1909     dict := Dictionary withKeysAndValues:#( 
       
  1910           'Make.spec'         #'generate_make_dot_spec'
       
  1911           'Make.proto'        #'generate_make_dot_proto'
       
  1912           'bc.mak'            #'generate_bc_dot_mak'
       
  1913           'abbrev.stc'        #'generate_abbrev_dot_stc' 
       
  1914           'bmake.bat'         #'generate_bmake_dot_mak' 
       
  1915     ).
       
  1916 
       
  1917     dict 
       
  1918         at:self rcFilename      put:#'generate_packageName_dot_rc'.
       
  1919 
       
  1920     ^ dict.
  1901 !
  1921 !
  1902 
  1922 
  1903 fileNamesToGenerate
  1923 fileNamesToGenerate
  1904     ^ self basicFileNamesToGenerate reject:[:p | self protectedFileNames includes:(p first) ].
  1924     "answer the files that have to be generated"
  1905 
  1925 
  1906     "Modified: / 14-09-2006 / 14:36:10 / cg"
  1926     ^ self basicFileNamesToGenerate removeAllKeys:self protectedFileNames ifAbsent:[]
       
  1927 
       
  1928     "
       
  1929       stx_libbasic fileNamesToGenerate
       
  1930     "
  1907 !
  1931 !
  1908 
  1932 
  1909 forEachFileNameAndGeneratedContentsDo:aTwoArgBlock 
  1933 forEachFileNameAndGeneratedContentsDo:aTwoArgBlock 
  1910     |pairs|
  1934     |pairs|
  1911 
  1935 
  1921 
  1945 
  1922     "Created: / 16-08-2006 / 18:37:52 / User"
  1946     "Created: / 16-08-2006 / 18:37:52 / User"
  1923 !
  1947 !
  1924 
  1948 
  1925 forEachFileNameAndGeneratorMethodDo:aTwoArgBlock 
  1949 forEachFileNameAndGeneratorMethodDo:aTwoArgBlock 
  1926     |fileNamesAndSelectors|
  1950     self fileNamesToGenerate keysAndValuesDo:aTwoArgBlock
  1927 
       
  1928     fileNamesAndSelectors := self fileNamesToGenerate.
       
  1929     fileNamesAndSelectors pairsDo:aTwoArgBlock
       
  1930 
  1951 
  1931     "Modified: / 14-09-2006 / 21:02:37 / cg"
  1952     "Modified: / 14-09-2006 / 21:02:37 / cg"
  1932 !
  1953 !
  1933 
  1954 
  1934 generateFile:filename
  1955 generateFile:filename
  1935     self basicFileNamesToGenerate
  1956     |action|
  1936         pairsDo:[:fn :action | 
  1957 
  1937             filename = fn ifTrue:[
  1958     action := self basicFileNamesToGenerate at:filename ifAbsent:[].
  1938                 ^ self perform:action
  1959     action notNil ifTrue:[
  1939             ].
  1960         ^ self perform:action
  1940         ].
  1961     ].
  1941     (filename = 'app.rc' or:[filename = 'lib.rc' or:[filename = self rcFilename]]) ifTrue:[
  1962     (filename = 'app.rc' or:[filename = 'lib.rc']) ifTrue:[
  1942         ^ self generate_packageName_dot_rc
  1963         ^ self generate_packageName_dot_rc
  1943     ].
  1964     ].
  1944     (filename = 'loadAll') ifTrue:[
  1965     (filename = 'loadAll') ifTrue:[
  1945         ^ self generate_loadAll
  1966         ^ self generate_loadAll
  1946     ].
  1967     ].
  2234 "
  2255 "
  2235 
  2256 
  2236     "Modified: / 09-08-2006 / 11:31:21 / fm"
  2257     "Modified: / 09-08-2006 / 11:31:21 / fm"
  2237 !
  2258 !
  2238 
  2259 
  2239 nsiFilename
       
  2240     ^ self packageName,'.nsi'.
       
  2241 
       
  2242     "Created: / 14-09-2006 / 21:03:41 / cg"
       
  2243 !
       
  2244 
       
  2245 protectedFileNames
  2260 protectedFileNames
  2246     "names of files which should NOT be generated 
  2261     "names of files which should NOT be generated 
  2247      - redefine this to protect a hand-written Make.proto"
  2262      - redefine this to protect a hand-written Make.proto"
  2248 
  2263 
  2249     ^ #()
  2264     ^ #()
  2694 !
  2709 !
  2695 
  2710 
  2696 generateDependencies:whichArchitecture 
  2711 generateDependencies:whichArchitecture 
  2697     ^ String 
  2712     ^ String 
  2698         streamContents:[:s | 
  2713         streamContents:[:s | 
  2699             |classNames classesPresent classesLoaded classesSorted classNamesSorted putDependencyForClassBlock 
  2714             |classNames classesPresent classesLoaded clsBaseName putDependencyForClassBlock 
  2700              archClassNames archClassesLoaded 
  2715              putDependencyForClassBaseNameBlock
       
  2716              archClassNames archClassesPresent archClassesLoaded  
  2701              putSingleClassDependencyEntryBlock putDependencyForExtensionsBlock|
  2717              putSingleClassDependencyEntryBlock putDependencyForExtensionsBlock|
  2702 
  2718 
  2703             putSingleClassDependencyEntryBlock := [:cls | 
  2719             putSingleClassDependencyEntryBlock := [:cls | 
  2704                     |sclsBaseName|
  2720                     |sclsBaseName|
  2705 
  2721 
  2711                                 inPackage:cls package
  2727                                 inPackage:cls package
  2712                                 architecture:whichArchitecture).
  2728                                 architecture:whichArchitecture).
  2713                     s nextPutAll:'.$(H)'.
  2729                     s nextPutAll:'.$(H)'.
  2714                 ].
  2730                 ].
  2715 
  2731 
  2716             putDependencyForClassBlock := [:cls | 
  2732             putDependencyForClassBaseNameBlock := [:clsBaseName |
  2717                     |clsBaseName already|
       
  2718 
       
  2719                     clsBaseName := cls classFilename asFilename withoutSuffix baseName.
       
  2720                     s nextPutAll:'$(OUTDIR)'.
  2733                     s nextPutAll:'$(OUTDIR)'.
  2721                     s nextPutAll:clsBaseName.
  2734                     s nextPutAll:clsBaseName.
  2722                     s nextPutAll:'.$(O)'.
  2735                     s nextPutAll:'.$(O)'.
  2723                     s nextPutAll:' '.
  2736                     s nextPutAll:' '.
  2724                     s nextPutAll:clsBaseName.
  2737                     s nextPutAll:clsBaseName.
  2725                     s nextPutAll:'.$(H)'.
  2738                     s nextPutAll:'.$(H)'.
  2726                     s nextPutAll:': '.
  2739                     s nextPutAll:': '.
  2727                     s nextPutAll:clsBaseName.
  2740                     s nextPutAll:clsBaseName.
  2728                     s nextPutAll:'.st'.
  2741                     s nextPutAll:'.st'.
       
  2742                 ].
       
  2743 
       
  2744 
       
  2745             putDependencyForClassBlock := [:cls |
       
  2746                     |clsBaseName already|
       
  2747 
       
  2748                     clsBaseName := cls classFilename asFilename withoutSuffix baseName.
       
  2749                     putDependencyForClassBaseNameBlock value:clsBaseName.
  2729                     cls isLoaded ifTrue:[
  2750                     cls isLoaded ifTrue:[
  2730                         already := Set new.
  2751                         already := IdentitySet new.
  2731                         cls 
  2752                         cls 
  2732                             allSuperclassesDo:[:scls | 
  2753                             allSuperclassesDo:[:scls | 
  2733                                 putSingleClassDependencyEntryBlock value:scls.
  2754                                 putSingleClassDependencyEntryBlock value:scls.
  2734                                 already add:scls.
  2755                                 already add:scls.
  2735                             ].
  2756                             ].
  2785                         collect:[:className | Smalltalk classNamed:className]
  2806                         collect:[:className | Smalltalk classNamed:className]
  2786                         thenSelect:[:cls | cls notNil].
  2807                         thenSelect:[:cls | cls notNil].
  2787             classesLoaded := classesPresent 
  2808             classesLoaded := classesPresent 
  2788                         select:[:cls | cls isLoaded].
  2809                         select:[:cls | cls isLoaded].
  2789 
  2810 
  2790             classesSorted := Class classesSortedByLoadOrder:classesLoaded.
  2811             (Class classesSortedByLoadOrder:classesLoaded) do:putDependencyForClassBlock.
  2791             classesSorted do:putDependencyForClassBlock.
       
  2792             (classesPresent select:[:cls | cls isLoaded not]) do:putDependencyForClassBlock.
  2812             (classesPresent select:[:cls | cls isLoaded not]) do:putDependencyForClassBlock.
  2793 
  2813 
  2794             self namesAndAttributesIn:(self additionalClassNamesAndAttributes)
  2814             self namesAndAttributesIn:(self additionalClassNamesAndAttributes)
  2795                 do:[:className :attr | 
  2815                 do:[:className :attr | 
  2796                     |cls|
  2816                     |cls|
  2800                             putDependencyForClassBlock value:cls.
  2820                             putDependencyForClassBlock value:cls.
  2801                         ]
  2821                         ]
  2802                     ].
  2822                     ].
  2803                 ].
  2823                 ].
  2804             archClassNames := self compiled_classNamesForPlatform:whichArchitecture.
  2824             archClassNames := self compiled_classNamesForPlatform:whichArchitecture.
  2805             archClassesLoaded := archClassNames 
  2825             archClassesPresent := archClassNames 
  2806                         collect:[:className | Smalltalk classNamed:className]
  2826                 collect:[:className | Smalltalk classNamed:className]
  2807                         thenSelect:[:cls | cls notNil and:[ cls isLoaded ] ].
  2827                 thenSelect:[:cls | cls notNil].
  2808 
  2828 
  2809             archClassesLoaded notEmpty ifTrue:[
  2829             archClassesLoaded := archClassesPresent 
  2810                 (Class classesSortedByLoadOrder:archClassesLoaded)
  2830                 select:[:cls | cls isLoaded].
  2811 		    do:putDependencyForClassBlock.
  2831 
  2812             ].
  2832             (Class classesSortedByLoadOrder:archClassesLoaded) do:putDependencyForClassBlock.
       
  2833 
       
  2834             "some classes are not loaded - probably this is the wrong architecture.
       
  2835              Sorry, but for these classes, we do not know the superclass chain"
       
  2836             archClassesPresent 
       
  2837                 select:[:cls | cls isLoaded not] 
       
  2838                 thenDo:putDependencyForClassBlock.
       
  2839 
       
  2840             "for the following classes, we do not know the superclass chain
       
  2841              and neither the real class file name"
       
  2842             archClassNames 
       
  2843                 select:[:eachClassName | (Smalltalk classNamed:eachClassName) isNil] 
       
  2844                 thenDo:[:eachClassName |
       
  2845                     putDependencyForClassBaseNameBlock value:(eachClassName copyReplaceAll:$: with:$_).
       
  2846                     s nextPutLine:' $(STCHDR)'.
       
  2847                 ].
       
  2848 
  2813             self hasExtensionMethods ifTrue:putDependencyForExtensionsBlock.
  2849             self hasExtensionMethods ifTrue:putDependencyForExtensionsBlock.
  2814         ]
  2850         ]
  2815 
  2851 
  2816     "
  2852     "
  2817      stx_libbasic3 generateDependencies:#unix
  2853      stx_libbasic3 generateDependencies:#unix
  2818      stx_libbasic3 generateDependencies:#win32
  2854      stx_libbasic3 generateDependencies:#win32
  2819     "
  2855     "
  2820 
  2856 
  2821     "Modified: / 16-08-2006 / 18:52:10 / User"
       
  2822     "Created: / 14-09-2006 / 12:38:57 / cg"
  2857     "Created: / 14-09-2006 / 12:38:57 / cg"
  2823     "Modified: / 25-10-2006 / 16:01:13 / cg"
  2858     "Modified: / 25-10-2006 / 16:01:13 / cg"
  2824 !
  2859 !
  2825 
  2860 
  2826 generateDependencies_unix
  2861 generateDependencies_unix
  3919 ! !
  3954 ! !
  3920 
  3955 
  3921 !ProjectDefinition class methodsFor:'documentation'!
  3956 !ProjectDefinition class methodsFor:'documentation'!
  3922 
  3957 
  3923 version
  3958 version
  3924     ^ '$Header: /cvs/stx/stx/libbasic/ProjectDefinition.st,v 1.172 2008-01-23 10:46:42 stefan Exp $'
  3959     ^ '$Header: /cvs/stx/stx/libbasic/ProjectDefinition.st,v 1.173 2008-02-05 10:26:11 stefan Exp $'
  3925 ! !
  3960 ! !
  3926 
  3961 
  3927 ProjectDefinition initialize!
  3962 ProjectDefinition initialize!