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