45 "/ ensure that everything is loaded... |
45 "/ ensure that everything is loaded... |
46 projectDefinitionClass loadAsAutoloaded:false. |
46 projectDefinitionClass loadAsAutoloaded:false. |
47 projectDefinitionClass loadExtensions. |
47 projectDefinitionClass loadExtensions. |
48 projectDefinitionClass loadAllClassesAsAutoloaded:false. |
48 projectDefinitionClass loadAllClassesAsAutoloaded:false. |
49 |
49 |
50 self halt. |
|
51 module := package module. |
50 module := package module. |
52 directory := package directory. |
51 directory := package directory. |
53 |
52 |
54 buildDirectory := PreviousBuildDirectory ifNil:[ UserPreferences current buildDirectory ]. |
53 buildDirectory := PreviousBuildDirectory ifNil:[ UserPreferences current buildDirectory ]. |
55 buildDirectory isNil ifTrue:[ |
54 buildDirectory isNil ifTrue:[ |
67 sourceCodeManager := SourceCodeManagerUtilities sourceCodeManagerFor:projectDefinitionClass. |
66 sourceCodeManager := SourceCodeManagerUtilities sourceCodeManagerFor:projectDefinitionClass. |
68 ] |
67 ] |
69 ]. |
68 ]. |
70 sourceCodeManager := nil. |
69 sourceCodeManager := nil. |
71 |
70 |
72 mySTXTopDirectory := |
71 myTopDirectory := |
73 Smalltalk packagePath |
72 Smalltalk packagePath |
74 detect:[:aPath | |
73 detect:[:aPath | |
75 (aPath asFilename / 'stx' / 'include') exists |
74 (aPath asFilename / 'stx' / 'include') exists |
76 and: [ (aPath asFilename / 'stx' / 'rules') exists ]] |
75 and: [ (aPath asFilename / 'stx' / 'rules') exists ]] |
77 ifNone:nil. |
76 ifNone:nil. |
78 mySTXTopDirectory isNil ifTrue:[ |
77 myTopDirectory isNil ifTrue:[ |
79 self error:('Cannot figure out my top directory (where include and rules are)') |
78 self error:('Cannot figure out my top directory (where stx/include and stx/rules are)') |
80 ]. |
79 ]. |
|
80 myTopDirectory := myTopDirectory asFilename. |
|
81 mySTXTopDirectory := myTopDirectory / 'stx'. |
81 |
82 |
82 self setupBuildDirectory. |
83 self setupBuildDirectory. |
83 self generateSourceFiles. |
84 self generateSourceFiles. |
|
85 self halt. |
84 |
86 |
85 OperatingSystem |
87 OperatingSystem |
86 executeCommand:(ParserFlags makeCommand) |
88 executeCommand:(ParserFlags makeCommand) |
87 inputFrom:nil |
89 inputFrom:nil |
88 outputTo:Transcript |
90 outputTo:Transcript |
100 ((Smalltalk projectDirectoryForPackage:'stx') asFilename construct:relativepath) |
102 ((Smalltalk projectDirectoryForPackage:'stx') asFilename construct:relativepath) |
101 recursiveCopyTo:(buildDirectory construct:'stx'). |
103 recursiveCopyTo:(buildDirectory construct:'stx'). |
102 ! |
104 ! |
103 |
105 |
104 copyDirectoryForBuild:subdir |
106 copyDirectoryForBuild:subdir |
105 |targetDir| |
107 |targetDir targetFile| |
106 |
108 |
107 targetDir := buildDirectory / 'stx' / subdir. |
109 targetDir := buildDirectory / 'stx' / subdir. |
108 targetDir exists ifFalse:[ |
110 targetDir exists ifFalse:[ |
109 targetDir makeDirectory. |
111 targetDir makeDirectory. |
110 (mySTXTopDirectory / subdir) directoryContentsAsFilenamesDo:[:eachFile | |
112 ]. |
111 eachFile isDirectory ifFalse:[ |
113 (mySTXTopDirectory / subdir) directoryContentsAsFilenamesDo:[:eachFile | |
|
114 eachFile isDirectory ifFalse:[ |
|
115 targetFile := targetDir / eachFile baseName. |
|
116 (targetFile exists not |
|
117 or:[ targetFile modificationTime < eachFile modificationTime ]) ifTrue:[ |
|
118 self activityNotification:'copying ',eachFile pathName,'...'. |
112 eachFile copyTo:(targetDir construct:eachFile baseName) |
119 eachFile copyTo:(targetDir construct:eachFile baseName) |
113 ] |
120 ] |
114 ]. |
121 ]. |
|
122 ]. |
|
123 self activityNotification:nil |
|
124 ! |
|
125 |
|
126 createHeaderFileFor:aClass in:packageTargetDir |
|
127 |instVarList classInstVarList classVarList bindings superclassFilename |
|
128 template file newContents oldContents| |
|
129 |
|
130 instVarList := StringCollection new. |
|
131 aClass instVarNames do:[:v | |
|
132 instVarList add:('OBJ %1;' bindWith:v) |
|
133 ]. |
|
134 classInstVarList := StringCollection new. |
|
135 aClass class instVarNames do:[:v | |
|
136 (v includes:$_) ifTrue:[self halt]. |
|
137 classInstVarList add:('OBJ %1;' bindWith:v) |
|
138 ]. |
|
139 classVarList := StringCollection new. |
|
140 aClass classVarNames do:[:v | |
|
141 classVarList add:('extern OBJ %1_%2;' bindWith:aClass name with:v) |
|
142 ]. |
|
143 |
|
144 bindings := Dictionary new. |
|
145 bindings at:'ClassName' put:aClass name. |
|
146 aClass superclass isNil ifTrue:[ |
|
147 bindings at:'SuperclassName' put:'-'. |
|
148 bindings at:'SuperclassFileInclude' put:nil. |
|
149 ] ifFalse:[ |
|
150 bindings at:'SuperclassName' put:aClass superclass name. |
|
151 bindings at:'SuperclassFileName' put:(superclassFilename := Smalltalk fileNameForClass:aClass superclass). |
|
152 bindings at:'SuperclassFileInclude' put:('#include "%1.STH"' bindWith:superclassFilename). |
|
153 ]. |
|
154 bindings at:'InstVarList' put:instVarList asString. |
|
155 bindings at:'ClassVarList' put:classVarList asString. |
|
156 bindings at:'ClassInstVarList' put:classInstVarList asString. |
|
157 |
|
158 template := |
|
159 '/* This file was generated by ProjectBuilder. */ |
|
160 /* !!!!!!!! Do not change by hand !!!!!!!! */ |
|
161 |
|
162 /* Class: %(ClassName) */ |
|
163 /* Superclass: %(SuperclassName) */ |
|
164 |
|
165 %(SuperclassFileInclude) |
|
166 |
|
167 /* INDIRECTGLOBALS */ |
|
168 #ifdef _HEADER_INST_ |
|
169 %(InstVarList) |
|
170 #endif /* _HEADER_INST_ */ |
|
171 |
|
172 #ifdef _HEADER_CLASS_ |
|
173 %(ClassVarList) |
|
174 #endif /* _HEADER_CLASS_ */ |
|
175 |
|
176 #ifdef _HEADER_CLASSINST_ |
|
177 %(ClassInstVarList) |
|
178 #endif /* _HEADER_CLASSINST_ */ |
|
179 '. |
|
180 newContents := template bindWithArguments:bindings. |
|
181 file := packageTargetDir asFilename / ((Smalltalk fileNameForClass:aClass),'.STH'). |
|
182 (file exists not |
|
183 or:[ (oldContents := file contents) ~= newContents ]) ifTrue:[ |
|
184 file contents: newContents. |
115 ]. |
185 ]. |
116 ! |
186 ! |
117 |
187 |
118 generateSourceFiles |
188 generateSourceFiles |
119 sourceCodeManager notNil ifTrue:[ |
189 sourceCodeManager notNil ifTrue:[ |
176 (package module ~= 'stx') ifTrue:[ |
246 (package module ~= 'stx') ifTrue:[ |
177 (buildDirectory / package module) makeDirectory. |
247 (buildDirectory / package module) makeDirectory. |
178 ]. |
248 ]. |
179 |
249 |
180 "/ file out the package(s) |
250 "/ file out the package(s) |
181 |
251 ((Array with:package)) |
182 ((Array with:package) , (projectDefinitionClass allPreRequisites)) |
|
183 do:[:eachPackageToFileout | |
252 do:[:eachPackageToFileout | |
184 |packageModule packageDirectory packageTargetDir| |
253 |packageId packageModule packageDirectory packageTargetDir packageDef| |
185 |
254 |
186 packageModule := eachPackageToFileout asPackageId module. |
255 packageId := eachPackageToFileout asPackageId. |
187 packageDirectory := eachPackageToFileout asPackageId directory. |
256 packageModule := packageId module. |
|
257 packageDirectory := packageId directory. |
188 packageTargetDir := (buildDirectory / packageModule / packageDirectory) recursiveMakeDirectory. |
258 packageTargetDir := (buildDirectory / packageModule / packageDirectory) recursiveMakeDirectory. |
189 |
259 |
190 (Smalltalk allClassesInPackage:eachPackageToFileout) do:[:cls | |
260 packageDef := packageId projectDefinitionClass. |
191 cls isPrivate ifFalse:[ |
261 (packageDef compiled_classNames_common , |
192 cls isLoaded ifFalse:[ |
262 packageDef compiled_classNamesForPlatform) do:[:eachClassName | |
193 self halt. |
263 |cls| |
194 cls autoload. |
264 |
195 ]. |
265 cls := Smalltalk classNamed:eachClassName. |
196 cls fileOutIn:packageTargetDir |
266 self assert:cls isLoaded. |
197 ] |
267 cls fileOutIn:packageTargetDir |
198 ]. |
268 ]. |
|
269 |
|
270 "/ (Smalltalk allClassesInPackage:eachPackageToFileout) do:[:cls | |
|
271 "/ cls isPrivate ifFalse:[ |
|
272 "/ cls isLoaded ifFalse:[ |
|
273 "/ self halt. |
|
274 "/ cls autoload. |
|
275 "/ ]. |
|
276 "/ cls fileOutIn:packageTargetDir |
|
277 "/ ] |
|
278 "/ ]. |
|
279 ]. |
|
280 "/ generate header files... |
|
281 (projectDefinitionClass allPreRequisites) |
|
282 do:[:eachPackageToFileout | |
|
283 |packageId packageDef packageModule packageDirectory packageTargetDir| |
|
284 |
|
285 packageId := eachPackageToFileout asPackageId. |
|
286 packageModule := packageId module. |
|
287 packageDirectory := packageId directory. |
|
288 packageTargetDir := (buildDirectory / packageModule / packageDirectory) recursiveMakeDirectory. |
|
289 |
|
290 packageDef := packageId projectDefinitionClass. |
|
291 (packageDef compiled_classNames_common , |
|
292 packageDef compiled_classNamesForPlatform) do:[:eachClassName | |
|
293 |cls| |
|
294 |
|
295 cls := Smalltalk classNamed:eachClassName. |
|
296 self assert:cls isLoaded. |
|
297 cls isLoaded ifTrue:[ |
|
298 self createHeaderFileFor:cls in:packageTargetDir |
|
299 ]. |
|
300 ]. |
|
301 |
|
302 "/ (Smalltalk allClassesInPackage:eachPackageToFileout) do:[:cls | |
|
303 "/ cls isPrivate ifFalse:[ |
|
304 "/ cls isLoaded ifTrue:[ |
|
305 "/ self createHeaderFileFor:cls in:packageTargetDir |
|
306 "/ ] |
|
307 "/ ] |
|
308 "/ ]. |
199 ]. |
309 ]. |
200 |
310 |
201 "/ "/ copy h-files preRequisite packages |
311 "/ "/ copy h-files preRequisite packages |
202 "/ prerequisitePackages := projectDefinitionClass preRequisitesForBuilding. |
312 "/ prerequisitePackages := projectDefinitionClass preRequisitesForBuilding. |
203 "/ prerequisitePackages do:[:eachPackage | |
313 "/ prerequisitePackages do:[:eachPackage | |