author | Claus Gittinger <cg@exept.de> |
Fri, 19 Dec 2014 19:11:29 +0100 | |
changeset 17234 | 18ad9ee33b13 |
parent 16497 | d607fbd6eb43 |
child 17235 | 6b5be0a1dcb9 |
permissions | -rw-r--r-- |
9571 | 1 |
" |
2 |
COPYRIGHT (c) 2006 by eXept Software AG |
|
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 |
" |
|
10230 | 12 |
"{ Package: 'stx:libbasic' }" |
9571 | 13 |
|
14 |
Object subclass:#PackageId |
|
15 |
instanceVariableNames:'packageIdString' |
|
16 |
classVariableNames:'' |
|
17 |
poolDictionaries:'' |
|
18 |
category:'System-Support-Projects' |
|
19 |
! |
|
20 |
||
21 |
!PackageId class methodsFor:'documentation'! |
|
22 |
||
23 |
copyright |
|
24 |
" |
|
25 |
COPYRIGHT (c) 2006 by eXept Software AG |
|
26 |
All Rights Reserved |
|
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 |
" |
|
39 |
Represents packageID's. |
|
40 |
Knows the relationship between modules and directories in the package-organization. |
|
41 |
" |
|
42 |
! ! |
|
43 |
||
44 |
!PackageId class methodsFor:'instance creation'! |
|
45 |
||
46 |
from: aStringOrSymbol |
|
47 |
^ self new packageIdString:aStringOrSymbol |
|
48 |
||
9840 | 49 |
" |
50 |
(self from:'stx:libbasic') module |
|
51 |
(self from:'stx:libbasic') directory |
|
52 |
" |
|
53 |
||
9571 | 54 |
"Created: / 18-08-2006 / 12:11:58 / cg" |
9840 | 55 |
"Modified: / 12-09-2006 / 15:27:42 / cg" |
56 |
! |
|
57 |
||
58 |
module:moduleString directory:directoryString |
|
59 |
^ self new module:moduleString directory:directoryString |
|
60 |
||
61 |
" |
|
10190 | 62 |
(PackageId module:'stx' directory:'libbasic') module |
63 |
(PackageId module:'stx' directory:'libbasic') directory |
|
9840 | 64 |
" |
65 |
||
66 |
"Created: / 12-09-2006 / 15:26:24 / cg" |
|
10190 | 67 |
"Modified: / 18-11-2006 / 17:09:12 / cg" |
9571 | 68 |
! ! |
69 |
||
12212 | 70 |
!PackageId class methodsFor:'defaults'! |
71 |
||
72 |
noProjectID |
|
73 |
"return the symbol used to tag classes and methods which are loose. |
|
74 |
This means: not yet assigned to a particular project." |
|
75 |
||
76 |
^ #'__NoProject__'. |
|
77 |
! ! |
|
78 |
||
9571 | 79 |
!PackageId methodsFor:'accessing'! |
80 |
||
14570 | 81 |
directory |
82 |
"return the directory component. That's the rest after the colon. |
|
83 |
The module is typically used to define the project-path or project-id within its |
|
84 |
sourcecode repository (which is selected via the module)." |
|
85 |
||
86 |
|idx| |
|
87 |
||
88 |
idx := packageIdString indexOf:$:. |
|
89 |
idx == 0 ifTrue:[ |
|
90 |
^ ''. |
|
91 |
]. |
|
92 |
^ packageIdString copyFrom:idx+1 |
|
93 |
||
94 |
" |
|
95 |
(PackageId from:'stx:libbasic') module |
|
96 |
(PackageId from:'stx:libbasic') directory |
|
97 |
(PackageId from:'stx') module |
|
98 |
(PackageId from:'stx') directory |
|
99 |
(PackageId from:'stx:goodies/xml/stx') module |
|
100 |
(PackageId from:'stx:goodies/xml/stx') directory |
|
101 |
" |
|
102 |
||
103 |
"Created: / 18-08-2006 / 12:15:33 / cg" |
|
104 |
"Modified: / 28-11-2006 / 11:39:14 / cg" |
|
105 |
"Modified (comment): / 19-09-2011 / 11:01:08 / cg" |
|
106 |
! |
|
107 |
||
108 |
module |
|
109 |
"return the module component. That's the first component up to the colon. |
|
110 |
The module is typically used to select a corresponding sourcecode repository." |
|
111 |
||
112 |
|idx| |
|
113 |
||
114 |
idx := packageIdString indexOf:$:. |
|
115 |
idx == 0 ifTrue:[ |
|
116 |
^ packageIdString. |
|
117 |
]. |
|
118 |
^ packageIdString copyTo:idx-1 |
|
119 |
||
120 |
" |
|
121 |
(PackageId from:'stx:libbasic') module |
|
122 |
(PackageId from:'stx:libbasic') directory |
|
123 |
" |
|
124 |
||
125 |
"Created: / 18-08-2006 / 12:13:53 / cg" |
|
126 |
"Modified: / 27-12-2006 / 11:51:25 / cg" |
|
127 |
"Modified (comment): / 19-09-2011 / 11:01:15 / cg" |
|
128 |
! |
|
129 |
||
9840 | 130 |
module:moduleString directory:directoryString |
14570 | 131 |
|ds| |
132 |
||
133 |
(directoryString includes:$\) ifTrue:[ |
|
134 |
ds := directoryString asFilename components asStringWith:$/. |
|
135 |
] ifFalse:[ |
|
136 |
ds := directoryString |
|
137 |
]. |
|
138 |
packageIdString := (moduleString,':',ds) asSymbol. |
|
139 |
||
140 |
" |
|
141 |
(self new module:'stx' directory:'libbasic') module |
|
142 |
(self new module:'stx' directory:'libbasic') directory |
|
143 |
(self new module:'stx' directory:'goodies/net') module |
|
144 |
(self new module:'stx' directory:'goodies/net') directory |
|
145 |
(self new module:'stx' directory:'goodies\net') module |
|
146 |
(self new module:'stx' directory:'goodies\net') directory |
|
147 |
" |
|
9840 | 148 |
|
149 |
"Created: / 12-09-2006 / 15:26:48 / cg" |
|
150 |
! |
|
151 |
||
14570 | 152 |
packageIdString:aString |
153 |
"the required format is: |
|
154 |
module:path |
|
155 |
where path is a unix-like path (i.e. containing slashes). |
|
156 |
However, for our convenience, also allow for |
|
157 |
module/path |
|
158 |
and even: |
|
159 |
module\ms-dos-path |
|
160 |
and convert them as required. |
|
161 |
This makes it easier on a doit, by copy-pasting port of a path into a loadPackage |
|
162 |
expression" |
|
163 |
||
164 |
|components| |
|
165 |
||
166 |
(aString includes:$:) ifFalse:[ |
|
167 |
"/ assume its a path |
|
168 |
components := aString asFilename components. |
|
169 |
self module:components first directory:((components copyFrom:2) asStringWith:$/). |
|
170 |
] ifTrue:[ |
|
171 |
packageIdString := aString asSymbol. |
|
172 |
] |
|
173 |
||
174 |
" |
|
175 |
'stx:libbasic' asPackageId module |
|
176 |
'stx:libbasic' asPackageId directory |
|
177 |
'stx/goodies/net' asPackageId module |
|
178 |
'stx/goodies/net' asPackageId directory |
|
179 |
'stx\goodies\net' asPackageId module |
|
180 |
'stx\goodies\net' asPackageId directory |
|
181 |
" |
|
9571 | 182 |
|
183 |
"Created: / 18-08-2006 / 12:14:45 / cg" |
|
184 |
! |
|
185 |
||
186 |
string |
|
187 |
^ packageIdString |
|
188 |
||
189 |
"Created: / 18-08-2006 / 12:20:54 / cg" |
|
190 |
! ! |
|
191 |
||
192 |
!PackageId methodsFor:'comparing'! |
|
193 |
||
194 |
= aPackageId |
|
9841 | 195 |
"compares equal to a corresponding string" |
196 |
||
9571 | 197 |
^ packageIdString = aPackageId asPackageId string |
198 |
||
199 |
" |
|
9841 | 200 |
'stx:libbasic' asPackageId = 'stx:libbasic' |
9571 | 201 |
'stx:libbasic' asPackageId = 'stx:libbasic' asSymbol asPackageId |
202 |
'stx:libbasic' asPackageId = 'stx:libbasic' asPackageId |
|
203 |
'stx:libbasic2' asPackageId = 'stx:libbasic3' asPackageId |
|
204 |
" |
|
205 |
||
206 |
"Created: / 18-08-2006 / 12:20:47 / cg" |
|
9841 | 207 |
"Modified: / 12-09-2006 / 15:33:00 / cg" |
9571 | 208 |
! |
209 |
||
210 |
hash |
|
211 |
^ packageIdString hash |
|
212 |
||
213 |
"Created: / 18-08-2006 / 12:21:19 / cg" |
|
214 |
! ! |
|
215 |
||
216 |
!PackageId methodsFor:'converting'! |
|
217 |
||
218 |
asPackageId |
|
219 |
^ self |
|
220 |
||
221 |
"Created: / 18-08-2006 / 12:22:10 / cg" |
|
222 |
! |
|
223 |
||
224 |
asString |
|
12185 | 225 |
^ packageIdString asString |
9571 | 226 |
|
227 |
"Created: / 18-08-2006 / 12:12:22 / cg" |
|
228 |
! |
|
229 |
||
230 |
asSymbol |
|
231 |
^ packageIdString asSymbol |
|
232 |
||
233 |
"Created: / 18-08-2006 / 12:12:29 / cg" |
|
234 |
! ! |
|
235 |
||
10075 | 236 |
!PackageId methodsFor:'printing'! |
237 |
||
238 |
printOn:aStream |
|
239 |
aStream |
|
240 |
nextPutAll:'PackageId('; nextPutAll:packageIdString; nextPutAll:')' |
|
241 |
||
242 |
"Created: / 12-10-2006 / 10:30:10 / cg" |
|
243 |
! ! |
|
244 |
||
9577 | 245 |
!PackageId methodsFor:'queries'! |
246 |
||
12329 | 247 |
isModuleId |
248 |
"true if this is a module-id only (i.e. no directory component present). |
|
249 |
These are not allowed to be used as real projects, but only for organization. |
|
250 |
The reason is that this is used as selector to select the sourceCodeManager and |
|
14570 | 251 |
also the manager's repository" |
12329 | 252 |
|
253 |
^ self directory isEmptyOrNil |
|
254 |
! |
|
255 |
||
9577 | 256 |
libraryName |
257 |
"return the name of the library, when compiled to a binary (i.e. dll/so). |
|
258 |
To avoid conflicts with the projectDefinition class |
|
259 |
(which is named <module>_<directory_components>), we prefix the library name |
|
260 |
with 'lib'. This has the added advantage, that under unix, linking can be done with |
|
261 |
'-l'shortName." |
|
262 |
||
263 |
^ 'lib' , (packageIdString copy asString replaceAny:':/' with:$_) |
|
264 |
||
265 |
" |
|
266 |
(PackageId from:'stx:libbasic') libraryName |
|
267 |
(PackageId from:'stx:goodies/xml/stx') libraryName |
|
268 |
(PackageId from:'bosch:dapasx') libraryName |
|
269 |
(PackageId from:'exept:expecco') libraryName |
|
270 |
" |
|
271 |
||
272 |
"Created: / 18-08-2006 / 12:35:04 / cg" |
|
273 |
! |
|
274 |
||
16497 | 275 |
packageDirectory |
17234 | 276 |
"return the pathName of the directory for this package in the file system" |
277 |
||
16497 | 278 |
^ Smalltalk packageDirectoryForPackageId:packageIdString. |
279 |
||
280 |
" |
|
17234 | 281 |
'stx:libbasic2' asPackageId packageDirectory |
16497 | 282 |
" |
283 |
! |
|
284 |
||
9668 | 285 |
parentPackage |
17234 | 286 |
"the packageID of my parent package (in the folder hierarchy)" |
287 |
||
288 |
|dir idx name rest| |
|
9668 | 289 |
|
290 |
dir := self directory. |
|
10211
6516bfb2ae56
changed #parentPackage - handle nil
Stefan Vogel <sv@exept.de>
parents:
10208
diff
changeset
|
291 |
dir isNil ifTrue:[ |
6516bfb2ae56
changed #parentPackage - handle nil
Stefan Vogel <sv@exept.de>
parents:
10208
diff
changeset
|
292 |
^ nil. |
6516bfb2ae56
changed #parentPackage - handle nil
Stefan Vogel <sv@exept.de>
parents:
10208
diff
changeset
|
293 |
]. |
9668 | 294 |
idx := dir lastIndexOf:$/. |
295 |
idx == 0 ifTrue:[ |
|
17234 | 296 |
idx := packageIdString indexOf:$:. |
297 |
idx == 0 ifTrue:[ |
|
298 |
^ nil |
|
299 |
]. |
|
300 |
name := packageIdString copyTo:idx-1 |
|
301 |
] ifFalse:[ |
|
302 |
rest := (dir copyTo:idx-1). |
|
303 |
rest isEmpty ifTrue:[ |
|
304 |
name := self module |
|
305 |
] ifFalse:[ |
|
306 |
name := self module , ':' , rest |
|
307 |
]. |
|
9668 | 308 |
]. |
17234 | 309 |
^ self class from:name |
9668 | 310 |
|
311 |
" |
|
17234 | 312 |
(PackageId from:'stx:libbasic') parentPackage |
313 |
(PackageId from:'stx:goodies/xml/stx') parentPackage |
|
9668 | 314 |
(PackageId from:'stx:goodies/xml/stx') parentPackage parentPackage |
17234 | 315 |
(PackageId from:'stx:goodies/xml/stx') parentPackage parentPackage parentPackage |
9668 | 316 |
" |
317 |
||
318 |
"Created: / 23-08-2006 / 15:10:13 / cg" |
|
12185 | 319 |
! |
320 |
||
321 |
pathRelativeToTopDirectory |
|
14249
e071c4ff23ae
changed: #pathRelativeToTopDirectory
Claus Gittinger <cg@exept.de>
parents:
13714
diff
changeset
|
322 |
^ (self module asFilename construct:(self directory)) name. |
12185 | 323 |
|
324 |
" |
|
17234 | 325 |
'stx:libbasic' asPackageId pathRelativeToTopDirectory |
326 |
'stx:goodies/net/ssl' asPackageId pathRelativeToTopDirectory |
|
327 |
'bosch:dapasx' asPackageId pathRelativeToTopDirectory |
|
12185 | 328 |
" |
14249
e071c4ff23ae
changed: #pathRelativeToTopDirectory
Claus Gittinger <cg@exept.de>
parents:
13714
diff
changeset
|
329 |
|
e071c4ff23ae
changed: #pathRelativeToTopDirectory
Claus Gittinger <cg@exept.de>
parents:
13714
diff
changeset
|
330 |
"Modified: / 25-07-2012 / 23:02:40 / cg" |
12185 | 331 |
! |
332 |
||
333 |
pathRelativeToTopDirectory:aDirectory |
|
334 |
^ aDirectory asFilename construct:(self pathRelativeToTopDirectory) |
|
335 |
||
336 |
" |
|
337 |
|top| |
|
338 |
||
339 |
top := Smalltalk packagePath first. |
|
340 |
'stx:goodies/net/ssl' asPackageId pathRelativeToTopDirectory:top |
|
341 |
" |
|
12199 | 342 |
! |
343 |
||
344 |
projectDefinitionClass |
|
345 |
^ ProjectDefinition definitionClassForPackage:self |
|
346 |
||
347 |
" |
|
348 |
'stx:libbasic' asPackageId projectDefinitionClass |
|
15373 | 349 |
'exept/expecco/foo' asPackageId projectDefinitionClass |
350 |
'exept/expecco/plugin/manualTest' asPackageId projectDefinitionClass |
|
351 |
'exept:expecco/plugin/manualTest' asPackageId projectDefinitionClass |
|
352 |
'exept_expecco_plugin_manualTest' asPackageId projectDefinitionClass |
|
12199 | 353 |
" |
13714 | 354 |
! |
355 |
||
356 |
projectDirectory |
|
16497 | 357 |
"/ replace by: |
358 |
^ self packageDirectory. |
|
14594 | 359 |
|
16497 | 360 |
"/ which works always. |
361 |
"/ the one below only works if a projDefClss is present... |
|
362 |
"/ |pdClass| |
|
363 |
"/ |
|
364 |
"/ (pdClass := self projectDefinitionClass) isNil ifTrue:[^ nil]. |
|
365 |
"/ ^ pdClass projectDirectory |
|
13714 | 366 |
|
367 |
" |
|
16497 | 368 |
'stx:libbasic2' asPackageId projectDirectory |
13714 | 369 |
" |
370 |
||
371 |
"Created: / 21-09-2011 / 18:21:32 / cg" |
|
9577 | 372 |
! ! |
373 |
||
9571 | 374 |
!PackageId class methodsFor:'documentation'! |
375 |
||
376 |
version |
|
17234 | 377 |
^ '$Header: /cvs/stx/stx/libbasic/PackageId.st,v 1.24 2014-12-19 18:11:29 cg Exp $' |
12185 | 378 |
! |
379 |
||
380 |
version_CVS |
|
17234 | 381 |
^ '$Header: /cvs/stx/stx/libbasic/PackageId.st,v 1.24 2014-12-19 18:11:29 cg Exp $' |
9571 | 382 |
! ! |
15373 | 383 |