89
|
1 |
"
|
|
2 |
COPYRIGHT (c) 1990 by Claus Gittinger
|
|
3 |
All Rights Reserved
|
|
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
|
2
|
14 |
instanceVariableNames:'name changeSet views properties'
|
149
|
15 |
classVariableNames:'CurrentProject SystemProject'
|
1
|
16 |
poolDictionaries:''
|
|
17 |
category:'System-Support'
|
|
18 |
!
|
|
19 |
|
89
|
20 |
Project comment:'
|
|
21 |
COPYRIGHT (c) 1993 by Claus Gittinger
|
|
22 |
All Rights Reserved
|
97
|
23 |
|
150
|
24 |
$Header: /cvs/stx/stx/libbasic/Project.st,v 1.10 1994-08-24 01:44:07 claus Exp $
|
89
|
25 |
'!
|
|
26 |
|
|
27 |
!Project class methodsFor:'documentation'!
|
|
28 |
|
|
29 |
copyright
|
|
30 |
"
|
|
31 |
COPYRIGHT (c) 1993 by Claus Gittinger
|
|
32 |
All Rights Reserved
|
|
33 |
|
|
34 |
This software is furnished under a license and may be used
|
|
35 |
only in accordance with the terms of that license and with the
|
|
36 |
inclusion of the above copyright notice. This software may not
|
|
37 |
be provided or otherwise made available to, or used by, any
|
|
38 |
other person. No title to or ownership of the software is
|
|
39 |
hereby transferred.
|
|
40 |
"
|
|
41 |
!
|
|
42 |
|
|
43 |
version
|
|
44 |
"
|
150
|
45 |
$Header: /cvs/stx/stx/libbasic/Project.st,v 1.10 1994-08-24 01:44:07 claus Exp $
|
89
|
46 |
"
|
|
47 |
!
|
|
48 |
|
|
49 |
documentation
|
|
50 |
"
|
|
51 |
this class is still under construction.
|
|
52 |
"
|
|
53 |
! !
|
|
54 |
|
1
|
55 |
!Project class methodsFor:'accessing'!
|
|
56 |
|
|
57 |
current
|
10
|
58 |
"return the currently active project"
|
|
59 |
|
1
|
60 |
^ CurrentProject
|
|
61 |
|
|
62 |
"Project current"
|
|
63 |
!
|
|
64 |
|
|
65 |
current:aProject
|
10
|
66 |
"set the currently active project"
|
|
67 |
|
1
|
68 |
CurrentProject := aProject
|
|
69 |
! !
|
|
70 |
|
|
71 |
!Project class methodsFor:'instance creation'!
|
|
72 |
|
|
73 |
new
|
13
|
74 |
^ self basicNew initialize
|
1
|
75 |
! !
|
|
76 |
|
|
77 |
!Project class methodsFor:'initialization'!
|
|
78 |
|
|
79 |
initialize
|
|
80 |
CurrentProject isNil ifTrue:[
|
150
|
81 |
CurrentProject := SystemProject := self new name:'System'.
|
|
82 |
"
|
|
83 |
the SystemProject does not keep a record if changes,
|
|
84 |
but instead depends on the changes file - recording anything there.
|
|
85 |
"
|
|
86 |
SystemProject changeSet:nil.
|
1
|
87 |
]
|
|
88 |
|
|
89 |
"Project initialize"
|
|
90 |
! !
|
|
91 |
|
149
|
92 |
!Project class methodsFor:'changes management'!
|
|
93 |
|
|
94 |
addMethodChange:aMethod in:aClass
|
|
95 |
"add a change for a method to the current project"
|
|
96 |
|
|
97 |
|p|
|
|
98 |
|
|
99 |
p := CurrentProject.
|
|
100 |
(p notNil
|
|
101 |
and:[p changeSet notNil]) ifTrue:[
|
|
102 |
p changeSet addMethodChange:aMethod in:aClass
|
|
103 |
]
|
|
104 |
!
|
|
105 |
|
|
106 |
currentProjectDirectory
|
|
107 |
"return the name of the directory to use for fileOut.
|
|
108 |
The returned name already includes a file-separator, so the
|
|
109 |
filename can be concatenated to it."
|
|
110 |
|
|
111 |
|p dirName|
|
|
112 |
|
|
113 |
p := CurrentProject.
|
|
114 |
p notNil ifTrue:[
|
|
115 |
dirName := p directory
|
|
116 |
] ifFalse:[
|
|
117 |
dirName := '.'
|
|
118 |
].
|
|
119 |
^ dirName , Filename separator asString
|
|
120 |
! !
|
|
121 |
|
13
|
122 |
!Project methodsFor:'initialization'!
|
|
123 |
|
|
124 |
initialize
|
|
125 |
self views:(OrderedCollection new).
|
|
126 |
self name:'a new Project'.
|
|
127 |
self changeSet:(ChangeSet new).
|
|
128 |
self directory:'.'
|
|
129 |
! !
|
|
130 |
|
1
|
131 |
!Project methodsFor:'accessing'!
|
|
132 |
|
|
133 |
views
|
|
134 |
^ views
|
|
135 |
!
|
|
136 |
|
|
137 |
views:aSetOfViews
|
|
138 |
views := aSetOfViews
|
|
139 |
!
|
|
140 |
|
|
141 |
changeSet
|
|
142 |
^ changeSet
|
|
143 |
!
|
|
144 |
|
|
145 |
changeSet:aChangeSet
|
|
146 |
changeSet := aChangeSet
|
|
147 |
!
|
|
148 |
|
|
149 |
name
|
|
150 |
^ name
|
|
151 |
!
|
|
152 |
|
|
153 |
name:aString
|
|
154 |
name := aString
|
73
|
155 |
! !
|
|
156 |
|
|
157 |
!Project methodsFor:'proerties'!
|
|
158 |
|
|
159 |
properties
|
|
160 |
^ properties
|
|
161 |
!
|
|
162 |
|
|
163 |
properties:p
|
|
164 |
properties := p
|
2
|
165 |
!
|
|
166 |
|
|
167 |
directory
|
73
|
168 |
^ properties at:#directoryName ifAbsent:['.']
|
2
|
169 |
!
|
|
170 |
|
|
171 |
directory:aDirectoryName
|
|
172 |
properties isNil ifTrue:[
|
|
173 |
properties := Dictionary new
|
|
174 |
].
|
|
175 |
properties at:#directoryName put:aDirectoryName
|
73
|
176 |
!
|
|
177 |
|
|
178 |
type
|
|
179 |
"return the type of project"
|
|
180 |
|
|
181 |
^ properties at:#type ifAbsent:[#application]
|
|
182 |
!
|
|
183 |
|
|
184 |
type:aSymbol
|
|
185 |
"set the projects type"
|
|
186 |
|
|
187 |
(#(application library smalltalk) includes:aSymbol) ifFalse:[
|
|
188 |
self warn:'invalid project type'.
|
|
189 |
^ self
|
|
190 |
].
|
|
191 |
properties at:#type put:aSymbol
|
1
|
192 |
! !
|
|
193 |
|
10
|
194 |
!Project methodsFor:'views'!
|
|
195 |
|
|
196 |
addView:aView
|
|
197 |
views add:aView
|
|
198 |
!
|
|
199 |
|
|
200 |
removeView:aView
|
|
201 |
views remove:aView ifAbsent:[]
|
|
202 |
!
|
|
203 |
|
|
204 |
showViews
|
|
205 |
self views notNil ifTrue:[
|
|
206 |
self views do:[:aView |
|
|
207 |
aView rerealize
|
|
208 |
]
|
|
209 |
].
|
|
210 |
!
|
|
211 |
|
|
212 |
hideViews
|
|
213 |
self views notNil ifTrue:[
|
|
214 |
self views do:[:aView |
|
|
215 |
aView unrealize
|
|
216 |
]
|
|
217 |
].
|
|
218 |
! !
|
|
219 |
|
2
|
220 |
!Project methodsFor:'maintenance'!
|
|
221 |
|
13
|
222 |
buildProject
|
|
223 |
OperatingSystem executeCommand:('cd ' , self directory , ' ; make')
|
|
224 |
!
|
|
225 |
|
2
|
226 |
createProjectFiles
|
|
227 |
"actually, creates all files to do a make in the project directory"
|
|
228 |
|
13
|
229 |
|dirName|
|
|
230 |
|
|
231 |
dirName := properties at:#directoryName.
|
|
232 |
dirName asFilename exists ifFalse:[
|
|
233 |
(self confirm:'create new projectDirectory: ' , dirName) ifFalse:[^ self].
|
|
234 |
OperatingSystem recursiveCreateDirectory:dirName.
|
|
235 |
].
|
2
|
236 |
self createMakefile.
|
|
237 |
self createSourcefiles.
|
|
238 |
self createClassListFile.
|
13
|
239 |
self createAbbreviationFile.
|
|
240 |
self createProtoMakefile.
|
2
|
241 |
!
|
|
242 |
|
|
243 |
createSourcefiles
|
|
244 |
"creates all st-source files"
|
|
245 |
|
|
246 |
|d f s abbrev classSymbol|
|
|
247 |
|
13
|
248 |
Transcript showCr:'creating sources'.
|
|
249 |
|
2
|
250 |
d := (properties at:#directoryName) asFilename.
|
13
|
251 |
(properties at:#classes ifAbsent:[#()]) do:[:aClassName |
|
2
|
252 |
classSymbol := aClassName asSymbol.
|
|
253 |
(Smalltalk includesKey:classSymbol) ifFalse:[
|
|
254 |
Transcript showCr:('no class named ' , aClassName)
|
|
255 |
] ifTrue:[
|
|
256 |
(Smalltalk at:classSymbol) autoload.
|
|
257 |
abbrev := Smalltalk fileNameForClass:aClassName.
|
|
258 |
f := d construct:(abbrev , '.st').
|
|
259 |
s := f writeStream.
|
13
|
260 |
s isNil ifTrue:[
|
|
261 |
self warn:'cannot create source file(s)'.
|
|
262 |
^ self
|
|
263 |
].
|
2
|
264 |
(Smalltalk at:classSymbol) fileOutOn:s.
|
|
265 |
s close
|
|
266 |
]
|
|
267 |
].
|
|
268 |
!
|
|
269 |
|
|
270 |
createClassListFile
|
|
271 |
"creates classList.stc - assume all loaded now should go into executable"
|
|
272 |
|
|
273 |
|d f in out|
|
|
274 |
|
13
|
275 |
Transcript showCr:'creating classList.stc'.
|
|
276 |
|
2
|
277 |
d := (properties at:#directoryName) asFilename.
|
|
278 |
f := d construct:'classList.stc'.
|
|
279 |
out := f writeStream.
|
13
|
280 |
out isNil ifTrue:[
|
|
281 |
self warn:'cannot create classList file'.
|
|
282 |
^ self
|
|
283 |
].
|
2
|
284 |
|
|
285 |
in := './classList.stc' asFilename readStream.
|
|
286 |
out nextPutAll:in contents asString.
|
|
287 |
in close.
|
|
288 |
|
13
|
289 |
(properties at:#classes ifAbsent:[Smalltalk allClasses collect:[:aClass| aClass name asSymbol]]) do:[:aClassSymbol |
|
2
|
290 |
(Smalltalk includesKey:aClassSymbol) ifFalse:[
|
|
291 |
Transcript showCr:('no class named ' , aClassSymbol)
|
|
292 |
] ifTrue:[
|
13
|
293 |
"
|
2
|
294 |
(Smalltalk at:aClassSymbol) autoload.
|
13
|
295 |
"
|
|
296 |
(Smalltalk at:aClassSymbol) isLoaded ifTrue:[
|
|
297 |
out nextPutAll:aClassSymbol; cr
|
|
298 |
]
|
2
|
299 |
]
|
|
300 |
].
|
|
301 |
out close.
|
|
302 |
!
|
|
303 |
|
|
304 |
createAbbreviationFile
|
|
305 |
"creates abbrev.stc"
|
|
306 |
|
|
307 |
|d f s abbrev|
|
|
308 |
|
13
|
309 |
Transcript showCr:'creating abbrev.stc'.
|
|
310 |
|
2
|
311 |
d := (properties at:#directoryName) asFilename.
|
|
312 |
f := d construct:'abbrev.stc'.
|
|
313 |
s := f writeStream.
|
13
|
314 |
s isNil ifTrue:[
|
|
315 |
self warn:'cannot create abbreviation file'.
|
|
316 |
^ self
|
|
317 |
].
|
2
|
318 |
Smalltalk allClassesDo:[:aClass |
|
|
319 |
(aClass isSubclassOf:Autoload) ifFalse:[
|
|
320 |
abbrev := Smalltalk fileNameForClass:aClass name.
|
|
321 |
abbrev ~= aClass name ifTrue:[
|
|
322 |
s nextPutAll:aClass name; tab; nextPutAll:abbrev; cr
|
|
323 |
]
|
|
324 |
].
|
|
325 |
].
|
|
326 |
s close.
|
|
327 |
!
|
|
328 |
|
|
329 |
createMakefile
|
|
330 |
"creates an initial makefile, which will recreate a correct
|
|
331 |
Makefile, then compile all"
|
|
332 |
|
|
333 |
|d f out in|
|
|
334 |
|
13
|
335 |
Transcript showCr:'creating Makefile'.
|
|
336 |
|
2
|
337 |
d := (properties at:#directoryName) asFilename.
|
|
338 |
f := d construct:'Makefile'.
|
13
|
339 |
f exists ifTrue:[
|
|
340 |
f renameTo:(d construct:'Makefile.bak')
|
|
341 |
].
|
2
|
342 |
out := f writeStream.
|
13
|
343 |
out isNil ifTrue:[
|
|
344 |
self warn:'cannot create Makefile'.
|
|
345 |
^ self
|
|
346 |
].
|
|
347 |
in := Smalltalk systemFileStreamFor:'rules/stdHeader'.
|
2
|
348 |
out nextPutAll:in contents asString.
|
|
349 |
in close.
|
13
|
350 |
out nextPutAll:'#TOP=/usr/local/lib/smalltalk'; cr.
|
|
351 |
out nextPutAll:'TOP=../..'; cr.
|
2
|
352 |
out nextPutAll:'target:'; cr.
|
|
353 |
out tab; nextPutAll:'touch Make.proto'; cr.
|
|
354 |
out tab; nextPutAll:'$(MAKE) Makefile'; cr.
|
|
355 |
out tab; nextPutAll:'make'; cr; cr.
|
|
356 |
|
13
|
357 |
in := Smalltalk systemFileStreamFor:'configurations/myConf'.
|
2
|
358 |
out nextPutAll:in contents asString.
|
|
359 |
in close.
|
13
|
360 |
in := Smalltalk systemFileStreamFor:'rules/stdRules'.
|
2
|
361 |
out nextPutAll:in contents asString.
|
|
362 |
in close.
|
|
363 |
out close
|
|
364 |
!
|
|
365 |
|
|
366 |
createProtoMakefile
|
|
367 |
"creates a Make.proto file"
|
|
368 |
|
13
|
369 |
|d f s type appName|
|
2
|
370 |
|
|
371 |
|
13
|
372 |
Transcript showCr:'creating Make.proto'.
|
|
373 |
|
2
|
374 |
d := (properties at:#directoryName) asFilename.
|
|
375 |
f := d construct:'Make.proto'.
|
|
376 |
f exists ifTrue:[
|
|
377 |
f renameTo:(d construct:'Make.proto.bak')
|
|
378 |
].
|
|
379 |
s := f writeStream.
|
13
|
380 |
s isNil ifTrue:[
|
|
381 |
self warn:'cannot create prototype Makefile'.
|
|
382 |
^ self
|
|
383 |
].
|
2
|
384 |
s nextPutAll:'#
|
|
385 |
# created by Smalltalk
|
|
386 |
#
|
|
387 |
SHELL=/bin/sh
|
|
388 |
|
|
389 |
SUBDIRS=
|
13
|
390 |
#TOP=/usr/local/lib/smalltalk
|
|
391 |
TOP=../..
|
2
|
392 |
|
|
393 |
'.
|
|
394 |
|
|
395 |
type := properties at:#projectType ifAbsent:[#executable].
|
13
|
396 |
|
|
397 |
appName := properties at:#applicationName ifAbsent:['app'].
|
|
398 |
s nextPutAll:'LIBNAME=lib' , appName; cr.
|
2
|
399 |
|
|
400 |
type == #executable ifTrue:[
|
13
|
401 |
s nextPutAll:'PROGS = ' , appName; cr
|
2
|
402 |
].
|
13
|
403 |
s nextPutAll:'STARTUP_CLASS=' , (properties at:#startupClass ifAbsent:['Smalltalk']).
|
|
404 |
s cr.
|
|
405 |
s nextPutAll:'STARTUP_SELECTOR="' , (properties at:#startupSelector ifAbsent:['start']).
|
|
406 |
s nextPutAll:'"'; cr.
|
2
|
407 |
|
|
408 |
s nextPutAll:'OBJS='.
|
13
|
409 |
(properties at:#classes ifAbsent:[#()]) do:[:aClassName |
|
2
|
410 |
|abbrev|
|
|
411 |
|
|
412 |
s nextPutAll:' \'. s cr.
|
|
413 |
abbrev := Smalltalk fileNameForClass:aClassName.
|
|
414 |
s nextPutAll:' '; nextPutAll:abbrev; nextPutAll:'.o'.
|
|
415 |
].
|
|
416 |
s cr; cr.
|
|
417 |
|
|
418 |
|
|
419 |
type == #executable ifTrue:[
|
|
420 |
s nextPutAll:'all:: $(PROGS)'; cr.
|
|
421 |
|
13
|
422 |
s nextPutAll:appName.
|
2
|
423 |
s nextPutAll:':: main.o classList.o $(OBJS)'; cr.
|
13
|
424 |
s tab; nextPutAll:'$(LD) $(ST_LDFLAG) $(LDFLAGS) -o ';
|
|
425 |
nextPutAll:appName;
|
2
|
426 |
nextPutAll:' \'; cr.
|
13
|
427 |
s tab; tab; nextPutAll:'$(CRT0) main.$(O) classList.$(O) $(OBJS) $(EXTRA_OBJ) $(LIBOBJS) \'; cr.
|
2
|
428 |
s tab; tab; nextPutAll:'$(LIBRUNDIR)/hidata.o $(LIBRUN) \'; cr.
|
13
|
429 |
s tab; tab; nextPutAll:'$(MATHLIB) $(EXTRALIBS) -lXext $(SYSLIBS) $(OTHERLIBS) $(CRTN)'; cr.
|
2
|
430 |
].
|
|
431 |
|
|
432 |
s close
|
|
433 |
! !
|
|
434 |
|
|
435 |
!Project methodsFor:'specifications'!
|
|
436 |
|
|
437 |
readSpec
|
|
438 |
|s chunk fileName|
|
|
439 |
|
|
440 |
fileName := (properties at:#directoryName) asFilename construct:'.project'.
|
|
441 |
s := fileName readStream.
|
|
442 |
s isNil ifTrue:[^ self].
|
|
443 |
[s atEnd] whileFalse:[
|
|
444 |
chunk := s nextChunk.
|
|
445 |
Compiler evaluate:chunk receiver:properties notifying:nil
|
|
446 |
].
|
|
447 |
s close.
|
|
448 |
|
|
449 |
"(Project new directory:'../projects/Clock') readSpec"
|
|
450 |
!
|
|
451 |
|
|
452 |
saveSpec
|
|
453 |
|f d s|
|
|
454 |
|
|
455 |
d := (properties at:#directoryName) asFilename.
|
|
456 |
d exists ifFalse:[
|
|
457 |
self error:'directory does not exist'.
|
|
458 |
^ self
|
|
459 |
].
|
|
460 |
f := d construct:'.project'.
|
|
461 |
s := f writeStream.
|
|
462 |
s isNil ifTrue:[^ self].
|
|
463 |
properties associationsDo:[:aProp |
|
|
464 |
(aProp == #directoryName) ifFalse:[
|
|
465 |
s nextChunkPut:('self at:' , aProp key storeString,
|
|
466 |
' put:' , aProp value storeString).
|
|
467 |
s cr
|
|
468 |
]
|
|
469 |
].
|
|
470 |
s close
|
|
471 |
|
|
472 |
"((Project new directory:'../projects/Clock') readSpec
|
|
473 |
directory:'../projects/xxx') saveSpec"
|
|
474 |
! !
|
|
475 |
|
1
|
476 |
Project initialize!
|