author | Claus Gittinger <cg@exept.de> |
Thu, 14 Dec 1995 16:56:13 +0100 | |
changeset 750 | f4ed622893ce |
parent 725 | 02759b2003a8 |
child 848 | 76a83f34c26a |
permissions | -rw-r--r-- |
89 | 1 |
" |
236 | 2 |
COPYRIGHT (c) 1993 by Claus Gittinger |
203 | 3 |
All Rights Reserved |
89 | 4 |
|
5 |
This software is furnished under a license and may be used |
|
6 |
only in accordance with the terms of that license and with the |
|
7 |
inclusion of the above copyright notice. This software may not |
|
8 |
be provided or otherwise made available to, or used by, any |
|
9 |
other person. No title to or ownership of the software is |
|
10 |
hereby transferred. |
|
11 |
" |
|
1 | 12 |
|
13 |
Object subclass:#Project |
|
654 | 14 |
instanceVariableNames:'name changeSet views directoryName properties packageName |
725
02759b2003a8
keep module & directory separately (as defaults when creating a container)
Claus Gittinger <cg@exept.de>
parents:
705
diff
changeset
|
15 |
repositoryDirectory repositoryModule' |
315 | 16 |
classVariableNames:'CurrentProject SystemProject NextSequential' |
203 | 17 |
poolDictionaries:'' |
18 |
category:'System-Support' |
|
1 | 19 |
! |
20 |
||
89 | 21 |
!Project class methodsFor:'documentation'! |
22 |
||
23 |
copyright |
|
24 |
" |
|
25 |
COPYRIGHT (c) 1993 by Claus Gittinger |
|
203 | 26 |
All Rights Reserved |
89 | 27 |
|
28 |
This software is furnished under a license and may be used |
|
29 |
only in accordance with the terms of that license and with the |
|
30 |
inclusion of the above copyright notice. This software may not |
|
31 |
be provided or otherwise made available to, or used by, any |
|
32 |
other person. No title to or ownership of the software is |
|
33 |
hereby transferred. |
|
34 |
" |
|
35 |
! |
|
36 |
||
37 |
documentation |
|
38 |
" |
|
338 | 39 |
this class is still under construction (especially the build features are unfinished). |
235 | 40 |
Currently, all it does is keep track of per-project views |
41 |
(to hide or show them), define the directory when filing-out, |
|
725
02759b2003a8
keep module & directory separately (as defaults when creating a container)
Claus Gittinger <cg@exept.de>
parents:
705
diff
changeset
|
42 |
and define packageNames for new classes and methods. |
02759b2003a8
keep module & directory separately (as defaults when creating a container)
Claus Gittinger <cg@exept.de>
parents:
705
diff
changeset
|
43 |
|
02759b2003a8
keep module & directory separately (as defaults when creating a container)
Claus Gittinger <cg@exept.de>
parents:
705
diff
changeset
|
44 |
instance variables: |
02759b2003a8
keep module & directory separately (as defaults when creating a container)
Claus Gittinger <cg@exept.de>
parents:
705
diff
changeset
|
45 |
name <String> the name of this project, as shown |
02759b2003a8
keep module & directory separately (as defaults when creating a container)
Claus Gittinger <cg@exept.de>
parents:
705
diff
changeset
|
46 |
in a ProjectView |
02759b2003a8
keep module & directory separately (as defaults when creating a container)
Claus Gittinger <cg@exept.de>
parents:
705
diff
changeset
|
47 |
|
02759b2003a8
keep module & directory separately (as defaults when creating a container)
Claus Gittinger <cg@exept.de>
parents:
705
diff
changeset
|
48 |
changeSet <ChangeSet> changes done, while this was the active project |
02759b2003a8
keep module & directory separately (as defaults when creating a container)
Claus Gittinger <cg@exept.de>
parents:
705
diff
changeset
|
49 |
|
02759b2003a8
keep module & directory separately (as defaults when creating a container)
Claus Gittinger <cg@exept.de>
parents:
705
diff
changeset
|
50 |
views <Collection> views opened while this was the active project |
02759b2003a8
keep module & directory separately (as defaults when creating a container)
Claus Gittinger <cg@exept.de>
parents:
705
diff
changeset
|
51 |
|
02759b2003a8
keep module & directory separately (as defaults when creating a container)
Claus Gittinger <cg@exept.de>
parents:
705
diff
changeset
|
52 |
directoryName <String> directory name, where fileOuts are done |
02759b2003a8
keep module & directory separately (as defaults when creating a container)
Claus Gittinger <cg@exept.de>
parents:
705
diff
changeset
|
53 |
|
02759b2003a8
keep module & directory separately (as defaults when creating a container)
Claus Gittinger <cg@exept.de>
parents:
705
diff
changeset
|
54 |
properties |
02759b2003a8
keep module & directory separately (as defaults when creating a container)
Claus Gittinger <cg@exept.de>
parents:
705
diff
changeset
|
55 |
|
02759b2003a8
keep module & directory separately (as defaults when creating a container)
Claus Gittinger <cg@exept.de>
parents:
705
diff
changeset
|
56 |
packageName <String> given to classes/methods which are created while |
02759b2003a8
keep module & directory separately (as defaults when creating a container)
Claus Gittinger <cg@exept.de>
parents:
705
diff
changeset
|
57 |
this is the active project |
02759b2003a8
keep module & directory separately (as defaults when creating a container)
Claus Gittinger <cg@exept.de>
parents:
705
diff
changeset
|
58 |
|
02759b2003a8
keep module & directory separately (as defaults when creating a container)
Claus Gittinger <cg@exept.de>
parents:
705
diff
changeset
|
59 |
repositoryDirectory (default) name of the repository, when a new source containers are |
02759b2003a8
keep module & directory separately (as defaults when creating a container)
Claus Gittinger <cg@exept.de>
parents:
705
diff
changeset
|
60 |
created. |
02759b2003a8
keep module & directory separately (as defaults when creating a container)
Claus Gittinger <cg@exept.de>
parents:
705
diff
changeset
|
61 |
|
02759b2003a8
keep module & directory separately (as defaults when creating a container)
Claus Gittinger <cg@exept.de>
parents:
705
diff
changeset
|
62 |
repositoryModule (default) name of the module, when new source containers are |
02759b2003a8
keep module & directory separately (as defaults when creating a container)
Claus Gittinger <cg@exept.de>
parents:
705
diff
changeset
|
63 |
created. |
235 | 64 |
|
65 |
Future: |
|
725
02759b2003a8
keep module & directory separately (as defaults when creating a container)
Claus Gittinger <cg@exept.de>
parents:
705
diff
changeset
|
66 |
- keep track of per-project changes |
02759b2003a8
keep module & directory separately (as defaults when creating a container)
Claus Gittinger <cg@exept.de>
parents:
705
diff
changeset
|
67 |
- allow speficiation of the type of the project (application, library, etc) |
02759b2003a8
keep module & directory separately (as defaults when creating a container)
Claus Gittinger <cg@exept.de>
parents:
705
diff
changeset
|
68 |
- allow building of whatever the target (as defined by the type) is |
02759b2003a8
keep module & directory separately (as defaults when creating a container)
Claus Gittinger <cg@exept.de>
parents:
705
diff
changeset
|
69 |
(this will allow build of class libs and apps by clicking a button) |
02759b2003a8
keep module & directory separately (as defaults when creating a container)
Claus Gittinger <cg@exept.de>
parents:
705
diff
changeset
|
70 |
- allow removal of project specific classes, methods etc. |
89 | 71 |
" |
72 |
! ! |
|
73 |
||
236 | 74 |
!Project class methodsFor:'initialization'! |
75 |
||
76 |
initialize |
|
338 | 77 |
SystemProject isNil ifTrue:[ |
315 | 78 |
NextSequential := 1. |
338 | 79 |
SystemProject := self new name:'default'. |
80 |
SystemProject packageName:'private'. |
|
236 | 81 |
" |
82 |
the SystemProject does not keep a record if changes, |
|
83 |
but instead depends on the changes file - recording anything there. |
|
84 |
" |
|
85 |
SystemProject changeSet:nil. |
|
338 | 86 |
]. |
87 |
||
88 |
CurrentProject := SystemProject. |
|
236 | 89 |
|
315 | 90 |
" |
91 |
Project initialize |
|
92 |
" |
|
236 | 93 |
! ! |
94 |
||
95 |
!Project class methodsFor:'instance creation'! |
|
96 |
||
97 |
new |
|
98 |
^ self basicNew initialize |
|
99 |
! ! |
|
100 |
||
1 | 101 |
!Project class methodsFor:'accessing'! |
102 |
||
103 |
current |
|
10 | 104 |
"return the currently active project" |
105 |
||
1 | 106 |
^ CurrentProject |
107 |
||
362 | 108 |
" |
109 |
Project current |
|
110 |
" |
|
1 | 111 |
! |
112 |
||
113 |
current:aProject |
|
10 | 114 |
"set the currently active project" |
115 |
||
315 | 116 |
CurrentProject := aProject. |
117 |
self changed:#currentProject |
|
334 | 118 |
! |
119 |
||
617 | 120 |
currentPackageName |
121 |
CurrentProject notNil ifTrue:[ |
|
122 |
^ CurrentProject packageName |
|
123 |
]. |
|
124 |
^ 'no package' |
|
125 |
||
126 |
" |
|
127 |
Project currentPackageName |
|
128 |
" |
|
129 |
! |
|
130 |
||
336 | 131 |
defaultProject |
132 |
"return the SystemDefault project" |
|
133 |
||
134 |
^ SystemProject. |
|
135 |
! |
|
136 |
||
334 | 137 |
setDefaultProject |
138 |
"set the currently active project to be the SystemDEfault project" |
|
139 |
||
140 |
self current:SystemProject. |
|
1 | 141 |
! ! |
142 |
||
149 | 143 |
!Project class methodsFor:'changes management'! |
144 |
||
664 | 145 |
addClassDefinitionChangeFor:aClass |
146 |
|p c| |
|
147 |
||
148 |
p := CurrentProject. |
|
149 |
(p notNil |
|
150 |
and:[(c := p changeSet) notNil]) ifTrue:[ |
|
666
6d4175de8c55
fixed primitiveDefinitions changes
Claus Gittinger <cg@exept.de>
parents:
664
diff
changeset
|
151 |
c addClassDefinitionChangeFor:aClass |
664 | 152 |
] |
153 |
||
154 |
"Created: 3.12.1995 / 13:44:58 / cg" |
|
155 |
"Modified: 3.12.1995 / 13:58:04 / cg" |
|
156 |
! |
|
157 |
||
617 | 158 |
addMethodCategoryChange:aMethod category:newCategory in:aClass |
159 |
|p c| |
|
160 |
||
161 |
p := CurrentProject. |
|
162 |
(p notNil |
|
163 |
and:[(c := p changeSet) notNil]) ifTrue:[ |
|
164 |
c addMethodCategoryChange:aMethod category:newCategory in:aClass |
|
165 |
] |
|
166 |
! |
|
167 |
||
149 | 168 |
addMethodChange:aMethod in:aClass |
169 |
"add a change for a method to the current project" |
|
170 |
||
235 | 171 |
|p c| |
149 | 172 |
|
173 |
p := CurrentProject. |
|
174 |
(p notNil |
|
235 | 175 |
and:[(c := p changeSet) notNil]) ifTrue:[ |
176 |
c addMethodChange:aMethod in:aClass |
|
203 | 177 |
] |
178 |
! |
|
179 |
||
617 | 180 |
addMethodPrivacyChange:aMethod in:aClass |
181 |
|p c| |
|
182 |
||
183 |
p := CurrentProject. |
|
184 |
(p notNil |
|
185 |
and:[(c := p changeSet) notNil]) ifTrue:[ |
|
186 |
c addMethodPrivacyChange:aMethod in:aClass |
|
187 |
] |
|
188 |
||
189 |
"Modified: 27.8.1995 / 22:48:17 / claus" |
|
190 |
! |
|
191 |
||
705 | 192 |
addPrimitiveDefinitionsChangeFor:aClass |
193 |
|p c| |
|
194 |
||
195 |
p := CurrentProject. |
|
196 |
(p notNil |
|
197 |
and:[(c := p changeSet) notNil]) ifTrue:[ |
|
198 |
c addPrimitiveDefinitionsChangeFor:aClass |
|
199 |
] |
|
200 |
! |
|
201 |
||
202 |
addPrimitiveFunctionsChangeFor:aClass |
|
203 |
|p c| |
|
204 |
||
205 |
p := CurrentProject. |
|
206 |
(p notNil |
|
207 |
and:[(c := p changeSet) notNil]) ifTrue:[ |
|
208 |
c addPrimitiveFunctionsChangeFor:aClass |
|
209 |
] |
|
210 |
! |
|
211 |
||
212 |
addPrimitiveVariablesChangeFor:aClass |
|
213 |
|p c| |
|
214 |
||
215 |
p := CurrentProject. |
|
216 |
(p notNil |
|
217 |
and:[(c := p changeSet) notNil]) ifTrue:[ |
|
218 |
c addPrimitiveVariablesChangeFor:aClass |
|
219 |
] |
|
220 |
! |
|
221 |
||
149 | 222 |
currentProjectDirectory |
223 |
"return the name of the directory to use for fileOut. |
|
235 | 224 |
The returned name already includes a file-separator at the end, |
225 |
so the filename can be concatenated to it." |
|
149 | 226 |
|
227 |
|p dirName| |
|
228 |
||
229 |
p := CurrentProject. |
|
230 |
p notNil ifTrue:[ |
|
203 | 231 |
dirName := p directory |
149 | 232 |
] ifFalse:[ |
203 | 233 |
dirName := '.' |
149 | 234 |
]. |
235 |
^ dirName , Filename separator asString |
|
13 | 236 |
! ! |
237 |
||
1 | 238 |
!Project methodsFor:'accessing'! |
239 |
||
240 |
changeSet |
|
241 |
^ changeSet |
|
242 |
! |
|
243 |
||
236 | 244 |
changeSet:aChangeSet |
245 |
changeSet := aChangeSet |
|
73 | 246 |
! |
247 |
||
315 | 248 |
directory |
249 |
directoryName isNil ifTrue:[^ '.']. |
|
250 |
^ directoryName |
|
251 |
! |
|
252 |
||
253 |
directory:aDirectoryName |
|
254 |
directoryName := aDirectoryName. |
|
255 |
self == CurrentProject ifTrue:[ |
|
256 |
Project changed:#directory |
|
257 |
] |
|
617 | 258 |
! |
356 | 259 |
|
617 | 260 |
name |
261 |
^ name |
|
262 |
! |
|
356 | 263 |
|
617 | 264 |
name:aString |
265 |
name := aString. |
|
266 |
self == CurrentProject ifTrue:[ |
|
267 |
Project changed:#name |
|
268 |
] |
|
356 | 269 |
! |
270 |
||
617 | 271 |
packageName |
272 |
^ packageName |
|
10 | 273 |
! |
274 |
||
617 | 275 |
packageName:aStringOrSymbol |
276 |
packageName := aStringOrSymbol asSymbol. |
|
277 |
self == CurrentProject ifTrue:[ |
|
278 |
Project changed:#package |
|
279 |
] |
|
10 | 280 |
! |
281 |
||
654 | 282 |
repositoryDirectory |
725
02759b2003a8
keep module & directory separately (as defaults when creating a container)
Claus Gittinger <cg@exept.de>
parents:
705
diff
changeset
|
283 |
^ repositoryDirectory |
654 | 284 |
|
285 |
"Created: 25.11.1995 / 18:04:51 / cg" |
|
725
02759b2003a8
keep module & directory separately (as defaults when creating a container)
Claus Gittinger <cg@exept.de>
parents:
705
diff
changeset
|
286 |
"Modified: 9.12.1995 / 16:58:05 / cg" |
654 | 287 |
! |
288 |
||
289 |
repositoryDirectory:aRelativePathName |
|
725
02759b2003a8
keep module & directory separately (as defaults when creating a container)
Claus Gittinger <cg@exept.de>
parents:
705
diff
changeset
|
290 |
repositoryDirectory := aRelativePathName |
654 | 291 |
|
292 |
"Created: 25.11.1995 / 18:05:06 / cg" |
|
725
02759b2003a8
keep module & directory separately (as defaults when creating a container)
Claus Gittinger <cg@exept.de>
parents:
705
diff
changeset
|
293 |
"Modified: 9.12.1995 / 16:58:11 / cg" |
02759b2003a8
keep module & directory separately (as defaults when creating a container)
Claus Gittinger <cg@exept.de>
parents:
705
diff
changeset
|
294 |
! |
02759b2003a8
keep module & directory separately (as defaults when creating a container)
Claus Gittinger <cg@exept.de>
parents:
705
diff
changeset
|
295 |
|
02759b2003a8
keep module & directory separately (as defaults when creating a container)
Claus Gittinger <cg@exept.de>
parents:
705
diff
changeset
|
296 |
repositoryModule |
02759b2003a8
keep module & directory separately (as defaults when creating a container)
Claus Gittinger <cg@exept.de>
parents:
705
diff
changeset
|
297 |
^ repositoryModule |
02759b2003a8
keep module & directory separately (as defaults when creating a container)
Claus Gittinger <cg@exept.de>
parents:
705
diff
changeset
|
298 |
|
02759b2003a8
keep module & directory separately (as defaults when creating a container)
Claus Gittinger <cg@exept.de>
parents:
705
diff
changeset
|
299 |
"Created: 25.11.1995 / 18:04:51 / cg" |
02759b2003a8
keep module & directory separately (as defaults when creating a container)
Claus Gittinger <cg@exept.de>
parents:
705
diff
changeset
|
300 |
"Modified: 9.12.1995 / 16:58:18 / cg" |
02759b2003a8
keep module & directory separately (as defaults when creating a container)
Claus Gittinger <cg@exept.de>
parents:
705
diff
changeset
|
301 |
! |
02759b2003a8
keep module & directory separately (as defaults when creating a container)
Claus Gittinger <cg@exept.de>
parents:
705
diff
changeset
|
302 |
|
02759b2003a8
keep module & directory separately (as defaults when creating a container)
Claus Gittinger <cg@exept.de>
parents:
705
diff
changeset
|
303 |
repositoryModule:aString |
02759b2003a8
keep module & directory separately (as defaults when creating a container)
Claus Gittinger <cg@exept.de>
parents:
705
diff
changeset
|
304 |
repositoryModule := aString |
02759b2003a8
keep module & directory separately (as defaults when creating a container)
Claus Gittinger <cg@exept.de>
parents:
705
diff
changeset
|
305 |
|
02759b2003a8
keep module & directory separately (as defaults when creating a container)
Claus Gittinger <cg@exept.de>
parents:
705
diff
changeset
|
306 |
"Created: 25.11.1995 / 18:05:06 / cg" |
02759b2003a8
keep module & directory separately (as defaults when creating a container)
Claus Gittinger <cg@exept.de>
parents:
705
diff
changeset
|
307 |
"Modified: 9.12.1995 / 16:58:35 / cg" |
654 | 308 |
! |
309 |
||
617 | 310 |
views |
311 |
^ views asArray |
|
338 | 312 |
! |
313 |
||
617 | 314 |
views:aSetOfViews |
315 |
views := WeakIdentitySet withAll:aSetOfViews |
|
10 | 316 |
! ! |
317 |
||
236 | 318 |
!Project methodsFor:'initialization'! |
319 |
||
320 |
initialize |
|
338 | 321 |
|numString| |
322 |
||
330 | 323 |
views := WeakIdentitySet new. |
338 | 324 |
numString := NextSequential printString. |
315 | 325 |
NextSequential := NextSequential + 1. |
338 | 326 |
|
327 |
name := 'new Project-' , numString. |
|
328 |
packageName := 'private-' , numString. |
|
664 | 329 |
changeSet := ChangeSet new. |
654 | 330 |
self directory:'.'. |
725
02759b2003a8
keep module & directory separately (as defaults when creating a container)
Claus Gittinger <cg@exept.de>
parents:
705
diff
changeset
|
331 |
self repositoryModule:(OperatingSystem getLoginName). |
654 | 332 |
self repositoryDirectory:'private' |
333 |
||
334 |
"Created: 25.11.1995 / 18:05:44 / cg" |
|
725
02759b2003a8
keep module & directory separately (as defaults when creating a container)
Claus Gittinger <cg@exept.de>
parents:
705
diff
changeset
|
335 |
"Modified: 9.12.1995 / 17:14:30 / cg" |
236 | 336 |
! ! |
337 |
||
2 | 338 |
!Project methodsFor:'maintenance'! |
339 |
||
13 | 340 |
buildProject |
341 |
OperatingSystem executeCommand:('cd ' , self directory , ' ; make') |
|
342 |
! |
|
343 |
||
2 | 344 |
createMakefile |
345 |
"creates an initial makefile, which will recreate a correct |
|
346 |
Makefile, then compile all" |
|
347 |
||
362 | 348 |
|d f out in topName| |
2 | 349 |
|
13 | 350 |
Transcript showCr:'creating Makefile'. |
351 |
||
356 | 352 |
d := directoryName asFilename. |
2 | 353 |
f := d construct:'Makefile'. |
13 | 354 |
f exists ifTrue:[ |
203 | 355 |
f renameTo:(d construct:'Makefile.bak') |
13 | 356 |
]. |
2 | 357 |
out := f writeStream. |
13 | 358 |
out isNil ifTrue:[ |
203 | 359 |
self warn:'cannot create Makefile'. |
360 |
^ self |
|
13 | 361 |
]. |
362 |
in := Smalltalk systemFileStreamFor:'rules/stdHeader'. |
|
2 | 363 |
out nextPutAll:in contents asString. |
364 |
in close. |
|
362 | 365 |
|
366 |
topName := self findTopFrom:directoryName. |
|
367 |
||
13 | 368 |
out nextPutAll:'#TOP=/usr/local/lib/smalltalk'; cr. |
362 | 369 |
out nextPutAll:'TOP=' , topName; cr. |
2 | 370 |
out nextPutAll:'target:'; cr. |
371 |
out tab; nextPutAll:'touch Make.proto'; cr. |
|
372 |
out tab; nextPutAll:'$(MAKE) Makefile'; cr. |
|
373 |
out tab; nextPutAll:'make'; cr; cr. |
|
374 |
||
362 | 375 |
in := Smalltalk systemFileStreamFor:'configurations/COMMON/defines'. |
376 |
out nextPutAll:in contents asString. |
|
377 |
in close. |
|
378 |
||
379 |
in := Smalltalk systemFileStreamFor:'configurations/vendorConf'. |
|
380 |
out nextPutAll:in contents asString. |
|
381 |
in close. |
|
382 |
||
13 | 383 |
in := Smalltalk systemFileStreamFor:'configurations/myConf'. |
2 | 384 |
out nextPutAll:in contents asString. |
385 |
in close. |
|
362 | 386 |
|
13 | 387 |
in := Smalltalk systemFileStreamFor:'rules/stdRules'. |
2 | 388 |
out nextPutAll:in contents asString. |
389 |
in close. |
|
390 |
out close |
|
391 |
! |
|
392 |
||
617 | 393 |
createProjectFiles |
394 |
"actually, creates all files to do a make in the project directory" |
|
395 |
||
396 |
directoryName asFilename exists ifFalse:[ |
|
397 |
(self confirm:'create new projectDirectory: ' , directoryName) |
|
398 |
ifFalse:[^ self]. |
|
399 |
OperatingSystem recursiveCreateDirectory:directoryName. |
|
400 |
]. |
|
401 |
self createMakefile. |
|
402 |
self createSourcefiles. |
|
403 |
self createProtoMakefile. |
|
404 |
! |
|
405 |
||
2 | 406 |
createProtoMakefile |
407 |
"creates a Make.proto file" |
|
408 |
||
362 | 409 |
|d f s type appName libName startUpClass startUpSelector |
410 |
topName classes| |
|
2 | 411 |
|
362 | 412 |
topName := self findTopFrom:directoryName. |
2 | 413 |
|
13 | 414 |
Transcript showCr:'creating Make.proto'. |
415 |
||
356 | 416 |
d := directoryName asFilename. |
2 | 417 |
f := d construct:'Make.proto'. |
418 |
f exists ifTrue:[ |
|
203 | 419 |
f renameTo:(d construct:'Make.proto.bak') |
2 | 420 |
]. |
421 |
s := f writeStream. |
|
13 | 422 |
s isNil ifTrue:[ |
203 | 423 |
self warn:'cannot create prototype Makefile'. |
424 |
^ self |
|
13 | 425 |
]. |
2 | 426 |
s nextPutAll:'# |
362 | 427 |
# ' , Smalltalk timeStamp , ' |
428 |
# |
|
235 | 429 |
# created by Smalltalks Project support |
2 | 430 |
# |
362 | 431 |
|
432 |
||
433 |
# the next line defines the path to the TOP directory, |
|
434 |
# (where the directories "configurations" and "include" are found) |
|
435 |
# |
|
436 |
#TOP=/usr/local/lib/smalltalk |
|
437 |
TOP=' , topName ,' |
|
438 |
||
439 |
# |
|
440 |
# add any subdirectories that have to be visited by make |
|
441 |
# |
|
442 |
SUBDIRS= |
|
443 |
||
444 |
# |
|
445 |
# do not change |
|
446 |
# |
|
2 | 447 |
SHELL=/bin/sh |
448 |
||
362 | 449 |
'. |
450 |
||
451 |
s nextPutAll:'# |
|
452 |
# set the stc options |
|
453 |
# |
|
454 |
STCOPT=$(DEFAULT_STCOPT) |
|
455 |
# STCOPT=+optspace2 |
|
456 |
# STCOPT=+optspace2 -warnNonStandard |
|
457 |
||
458 |
# |
|
459 |
# and packageName option |
|
460 |
# |
|
461 |
STCLOCALOPT=''-Pprivate-classes-(libapp)'' |
|
2 | 462 |
|
463 |
'. |
|
464 |
||
356 | 465 |
type := #library. |
466 |
appName := 'app'. |
|
467 |
libName := 'lib'. |
|
468 |
startUpClass := 'Smalltalk'. |
|
469 |
startUpSelector := 'start'. |
|
13 | 470 |
|
356 | 471 |
properties notNil ifTrue:[ |
472 |
type := properties at:#projectType ifAbsent:type. |
|
473 |
appName := properties at:#applicationName ifAbsent:appName. |
|
474 |
startUpClass := properties at:#startupClass ifAbsent:startUpClass. |
|
475 |
startUpSelector := properties at:#startupSelector ifAbsent:startUpSelector. |
|
476 |
]. |
|
477 |
||
362 | 478 |
s nextPutAll:'# |
479 |
# define the name of the library to create |
|
480 |
# |
|
481 |
'. |
|
482 |
s nextPutAll:'LIBNAME=lib' , appName; cr; cr. |
|
483 |
||
484 |
s nextPutAll:'# |
|
485 |
# the target rule: |
|
486 |
# |
|
487 |
all:: abbrev.stc objs genClassList $(OBJTARGET) |
|
488 |
||
489 |
'. |
|
2 | 490 |
|
491 |
type == #executable ifTrue:[ |
|
362 | 492 |
s nextPutAll:'PROGS = ' , appName; cr. |
493 |
s nextPutAll:('STARTUP_CLASS=' , startUpClass); cr. |
|
494 |
s nextPutAll:'STARTUP_SELECTOR="' , startUpSelector; nextPutAll:'"'; cr. |
|
2 | 495 |
]. |
496 |
||
362 | 497 |
s nextPutAll:'# |
498 |
# define the object files that are to be created |
|
499 |
# |
|
500 |
'. |
|
2 | 501 |
s nextPutAll:'OBJS='. |
502 |
||
362 | 503 |
(classes := self classes) notNil ifTrue:[ |
504 |
classes do:[:aClass | |
|
505 |
|abbrev| |
|
506 |
||
507 |
s nextPutAll:' \'. s cr. |
|
508 |
abbrev := Smalltalk fileNameForClass:aClass name. |
|
509 |
s nextPutAll:' '; nextPutAll:abbrev; nextPutAll:'.o'. |
|
510 |
]. |
|
2 | 511 |
]. |
512 |
s cr; cr. |
|
513 |
||
362 | 514 |
s nextPutAll:'# |
515 |
# dependencies: |
|
516 |
# |
|
517 |
I=$(TOP)/include |
|
518 |
RT_STUFF=$(I)/Object.H $(I)/stc.h $(I)/stcIntern.h |
|
519 |
||
520 |
'. |
|
521 |
classes notNil ifTrue:[ |
|
522 |
classes do:[:aClass | |
|
523 |
|abbrev| |
|
524 |
||
525 |
abbrev := Smalltalk fileNameForClass:aClass name. |
|
526 |
s nextPutAll:abbrev; nextPutAll:'.o: '. |
|
527 |
s nextPutAll:abbrev; nextPutAll:'.st '. |
|
528 |
aClass allSuperclassesDo:[:superClass| |
|
529 |
s nextPutAll:'$(I)/'. |
|
530 |
s nextPutAll:(Smalltalk fileNameForClass:superClass name) , '.H '. |
|
531 |
]. |
|
532 |
s nextPutAll:'$(RT_STUFF)'; cr. |
|
533 |
]. |
|
534 |
]. |
|
535 |
s cr; cr. |
|
2 | 536 |
|
537 |
type == #executable ifTrue:[ |
|
203 | 538 |
s nextPutAll:'all:: $(PROGS)'; cr. |
2 | 539 |
|
203 | 540 |
s nextPutAll:appName. |
541 |
s nextPutAll:':: main.o classList.o $(OBJS)'; cr. |
|
542 |
s tab; nextPutAll:'$(LD) $(ST_LDFLAG) $(LDFLAGS) -o '; |
|
543 |
nextPutAll:appName; |
|
544 |
nextPutAll:' \'; cr. |
|
545 |
s tab; tab; nextPutAll:'$(CRT0) main.$(O) classList.$(O) $(OBJS) $(EXTRA_OBJ) $(LIBOBJS) \'; cr. |
|
546 |
s tab; tab; nextPutAll:'$(LIBRUNDIR)/hidata.o $(LIBRUN) \'; cr. |
|
547 |
s tab; tab; nextPutAll:'$(MATHLIB) $(EXTRALIBS) -lXext $(SYSLIBS) $(OTHERLIBS) $(CRTN)'; cr. |
|
2 | 548 |
]. |
549 |
||
550 |
s close |
|
617 | 551 |
! |
552 |
||
553 |
createSourcefiles |
|
554 |
"creates all Smalltalk-source files in the project directory" |
|
555 |
||
556 |
|classes methods methodClasses dir stream| |
|
557 |
||
558 |
dir := FileDirectory directoryNamed:self directory. |
|
559 |
Transcript showCr:'creating sources in ' , dir pathName , ' ...'; endEntry. |
|
560 |
||
561 |
classes := self classes. |
|
562 |
classes isNil ifTrue:[ |
|
563 |
self warn:'no classes in current project' |
|
564 |
]. |
|
565 |
||
566 |
classes notNil ifTrue:[ |
|
567 |
classes do:[:aClass | |
|
568 |
aClass isLoaded ifFalse:[ |
|
569 |
aClass autoload. |
|
570 |
]. |
|
571 |
]. |
|
572 |
classes := classes topologicalSort:[:a :b | a isSubclassOf:b]. |
|
573 |
||
574 |
classes do:[:aClass | |
|
575 |
Transcript show:' ... '; showCr:aClass name, '.st'; endEntry. |
|
576 |
aClass fileOutIn:dir |
|
577 |
] |
|
578 |
]. |
|
579 |
||
580 |
methods := self individualMethods. |
|
581 |
methods notNil ifTrue:[ |
|
582 |
methods := methods asIdentitySet. |
|
583 |
" |
|
584 |
get classes ... |
|
585 |
" |
|
586 |
methodClasses := IdentitySet new. |
|
587 |
methods do:[:m | |
|
588 |
|mCls| |
|
589 |
||
590 |
mCls := m who at:1. |
|
591 |
mCls isMeta ifTrue:[ |
|
592 |
mCls := mCls soleInstance. |
|
593 |
]. |
|
594 |
methodClasses add:mCls]. |
|
595 |
" |
|
596 |
fileOut by class |
|
597 |
" |
|
598 |
methodClasses do:[:cls | |
|
599 |
stream := (self directory asFilename construct:(cls name , '.chg')) writeStream. |
|
600 |
||
601 |
Transcript show:' ... '; showCr:cls name, '.chg'; endEntry. |
|
602 |
methods do:[:m | |
|
603 |
|mCls| |
|
604 |
||
605 |
mCls := m who at:1. |
|
606 |
(mCls == cls or:[mCls == cls class]) ifTrue:[ |
|
607 |
mCls fileOutMethod:m on:stream. |
|
608 |
]. |
|
609 |
stream cr. |
|
610 |
]. |
|
611 |
stream close. |
|
612 |
]. |
|
613 |
]. |
|
614 |
! |
|
615 |
||
616 |
findTopFrom:directoryName |
|
617 |
"returns the relative path from directoryName to the TOP |
|
618 |
directory." |
|
619 |
||
620 |
|topName relParent foundTop| |
|
621 |
||
622 |
"/ find TOP |
|
623 |
relParent := '..'. |
|
624 |
foundTop := false. |
|
625 |
[foundTop] whileFalse:[ |
|
626 |
topName := directoryName , '/' , relParent. |
|
627 |
topName asFilename pathName = '/' ifTrue:[ |
|
628 |
self warn:'could not find TOP; assume absoulte path to TOP'. |
|
629 |
topName := '/usr/local/lib/smalltalk'. |
|
630 |
foundTop := true. |
|
631 |
] ifFalse:[ |
|
632 |
(topName , '/configurations') asFilename exists ifTrue:[ |
|
633 |
(topName , '/include') asFilename exists ifTrue:[ |
|
634 |
foundTop := true. |
|
635 |
topName := relParent. |
|
636 |
] |
|
637 |
]. |
|
638 |
foundTop ifFalse:[ |
|
639 |
relParent := relParent , '/..'. |
|
640 |
] |
|
641 |
] |
|
642 |
]. |
|
643 |
^ topName |
|
644 |
! ! |
|
645 |
||
646 |
!Project methodsFor:'properties'! |
|
647 |
||
648 |
properties |
|
649 |
^ properties |
|
650 |
! |
|
651 |
||
652 |
properties:p |
|
653 |
properties := p |
|
654 |
! |
|
655 |
||
656 |
type |
|
657 |
"return the type of project" |
|
658 |
||
659 |
^ properties at:#type ifAbsent:[#application] |
|
660 |
! |
|
661 |
||
662 |
type:aSymbol |
|
663 |
"set the projects type" |
|
664 |
||
665 |
(#(application library smalltalk) includes:aSymbol) ifFalse:[ |
|
666 |
self warn:'invalid project type'. |
|
667 |
^ self |
|
668 |
]. |
|
669 |
properties at:#type put:aSymbol |
|
670 |
! ! |
|
671 |
||
672 |
!Project methodsFor:'queries'! |
|
673 |
||
674 |
classes |
|
675 |
"return a collection of classes belonging to that project" |
|
676 |
||
677 |
|classes| |
|
678 |
||
679 |
properties notNil ifTrue:[classes := properties at:#classes ifAbsent:nil]. |
|
680 |
classes isNil ifTrue:[ |
|
681 |
classes := OrderedCollection new. |
|
682 |
Smalltalk allClassesDo:[:aClass | aClass package = packageName ifTrue:[classes add:aClass]]. |
|
683 |
classes isEmpty ifTrue:[^ nil]. |
|
684 |
]. |
|
685 |
^ classes |
|
686 |
||
687 |
! |
|
688 |
||
689 |
individualMethods |
|
690 |
"return a collection of individual methods belonging to that project, |
|
691 |
only methods are returned which are not contained in the |
|
692 |
projects class set." |
|
693 |
||
694 |
|classes methods| |
|
695 |
||
696 |
classes := self classes. |
|
697 |
classes notNil ifTrue:[ |
|
698 |
classes := classes asIdentitySet. |
|
699 |
] ifFalse:[ |
|
700 |
classes := #() |
|
701 |
]. |
|
702 |
||
703 |
methods := IdentitySet new. |
|
704 |
Smalltalk allBehaviorsDo:[:cls | |
|
705 |
(classes isNil or:[(classes includes:cls) not]) ifTrue:[ |
|
706 |
cls methodArray do:[:m | |
|
707 |
m package = packageName ifTrue:[ |
|
708 |
methods add:m |
|
709 |
] |
|
710 |
]. |
|
711 |
cls class methodArray do:[:m | |
|
712 |
m package = packageName ifTrue:[ |
|
713 |
methods add:m |
|
714 |
] |
|
715 |
]. |
|
716 |
] |
|
717 |
]. |
|
718 |
^ methods asArray |
|
719 |
||
720 |
" |
|
721 |
Project current classes |
|
722 |
Project current individualMethods |
|
723 |
" |
|
2 | 724 |
! ! |
725 |
||
726 |
!Project methodsFor:'specifications'! |
|
727 |
||
728 |
readSpec |
|
729 |
|s chunk fileName| |
|
730 |
||
731 |
fileName := (properties at:#directoryName) asFilename construct:'.project'. |
|
732 |
s := fileName readStream. |
|
733 |
s isNil ifTrue:[^ self]. |
|
734 |
[s atEnd] whileFalse:[ |
|
203 | 735 |
chunk := s nextChunk. |
736 |
Compiler evaluate:chunk receiver:properties notifying:nil |
|
2 | 737 |
]. |
738 |
s close. |
|
739 |
||
740 |
"(Project new directory:'../projects/Clock') readSpec" |
|
741 |
! |
|
742 |
||
743 |
saveSpec |
|
744 |
|f d s| |
|
745 |
||
746 |
d := (properties at:#directoryName) asFilename. |
|
747 |
d exists ifFalse:[ |
|
203 | 748 |
self error:'directory does not exist'. |
749 |
^ self |
|
2 | 750 |
]. |
751 |
f := d construct:'.project'. |
|
752 |
s := f writeStream. |
|
753 |
s isNil ifTrue:[^ self]. |
|
754 |
properties associationsDo:[:aProp | |
|
203 | 755 |
(aProp == #directoryName) ifFalse:[ |
756 |
s nextChunkPut:('self at:' , aProp key storeString, |
|
757 |
' put:' , aProp value storeString). |
|
758 |
s cr |
|
759 |
] |
|
2 | 760 |
]. |
761 |
s close |
|
762 |
||
763 |
"((Project new directory:'../projects/Clock') readSpec |
|
203 | 764 |
directory:'../projects/xxx') saveSpec" |
2 | 765 |
! ! |
766 |
||
617 | 767 |
!Project methodsFor:'views'! |
768 |
||
769 |
addView:aView |
|
770 |
views notNil ifTrue:[views add:aView] |
|
771 |
! |
|
772 |
||
773 |
destroyViews |
|
774 |
"destroy all views of this project" |
|
775 |
||
776 |
views notNil ifTrue:[ |
|
777 |
views do:[:aView | |
|
778 |
aView notNil ifTrue:[aView destroy] |
|
779 |
] |
|
780 |
]. |
|
781 |
! |
|
782 |
||
783 |
hideViews |
|
784 |
"hide all views of this project" |
|
785 |
||
786 |
views notNil ifTrue:[ |
|
787 |
views do:[:aView | |
|
788 |
aView notNil ifTrue:[aView unrealize] |
|
789 |
] |
|
790 |
]. |
|
791 |
! |
|
792 |
||
793 |
removeView:aView |
|
794 |
views notNil ifTrue:[views remove:aView ifAbsent:[]] |
|
795 |
! |
|
796 |
||
797 |
showViews |
|
798 |
views notNil ifTrue:[ |
|
799 |
views do:[:aView | |
|
800 |
aView notNil ifTrue:[aView rerealize] |
|
801 |
] |
|
802 |
]. |
|
803 |
! ! |
|
804 |
||
630 | 805 |
!Project class methodsFor:'documentation'! |
806 |
||
807 |
version |
|
725
02759b2003a8
keep module & directory separately (as defaults when creating a container)
Claus Gittinger <cg@exept.de>
parents:
705
diff
changeset
|
808 |
^ '$Header: /cvs/stx/stx/libbasic/Project.st,v 1.35 1995-12-09 17:39:20 cg Exp $'! ! |
1 | 809 |
Project initialize! |