author | Jan Vrany <jan.vrany@fit.cvut.cz> |
Mon, 10 Jun 2013 17:32:35 +0100 | |
branch | jv |
changeset 18066 | 89d51443ba6f |
parent 18011 | deb0c3355881 |
parent 15373 | f9b5fc793c3f |
child 18120 | e3a375d5f6a8 |
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 |
||
9668 | 275 |
parentPackage |
276 |
|dir idx| |
|
277 |
||
278 |
dir := self directory. |
|
10211
6516bfb2ae56
changed #parentPackage - handle nil
Stefan Vogel <sv@exept.de>
parents:
10208
diff
changeset
|
279 |
dir isNil ifTrue:[ |
6516bfb2ae56
changed #parentPackage - handle nil
Stefan Vogel <sv@exept.de>
parents:
10208
diff
changeset
|
280 |
^ nil. |
6516bfb2ae56
changed #parentPackage - handle nil
Stefan Vogel <sv@exept.de>
parents:
10208
diff
changeset
|
281 |
]. |
9668 | 282 |
idx := dir lastIndexOf:$/. |
283 |
idx == 0 ifTrue:[ |
|
284 |
^ nil |
|
285 |
]. |
|
286 |
^ self class from:(self module , ':' , (dir copyTo:idx-1)) |
|
287 |
||
288 |
" |
|
289 |
(PackageId from:'stx:libbasic') parentPackage |
|
290 |
(PackageId from:'stx:goodies/xml/stx') parentPackage |
|
291 |
(PackageId from:'stx:goodies/xml/stx') parentPackage parentPackage |
|
292 |
" |
|
293 |
||
294 |
"Created: / 23-08-2006 / 15:10:13 / cg" |
|
12185 | 295 |
! |
296 |
||
297 |
pathRelativeToTopDirectory |
|
14249
e071c4ff23ae
changed: #pathRelativeToTopDirectory
Claus Gittinger <cg@exept.de>
parents:
13714
diff
changeset
|
298 |
^ (self module asFilename construct:(self directory)) name. |
12185 | 299 |
|
300 |
" |
|
301 |
'stx:libbasic' asPackageId pathRelativeToTopDirectory |
|
302 |
'stx:goodies/net/ssl' asPackageId pathRelativeToTopDirectory |
|
303 |
" |
|
14249
e071c4ff23ae
changed: #pathRelativeToTopDirectory
Claus Gittinger <cg@exept.de>
parents:
13714
diff
changeset
|
304 |
|
e071c4ff23ae
changed: #pathRelativeToTopDirectory
Claus Gittinger <cg@exept.de>
parents:
13714
diff
changeset
|
305 |
"Modified: / 25-07-2012 / 23:02:40 / cg" |
12185 | 306 |
! |
307 |
||
308 |
pathRelativeToTopDirectory:aDirectory |
|
309 |
^ aDirectory asFilename construct:(self pathRelativeToTopDirectory) |
|
310 |
||
311 |
" |
|
312 |
|top| |
|
313 |
||
314 |
top := Smalltalk packagePath first. |
|
315 |
'stx:goodies/net/ssl' asPackageId pathRelativeToTopDirectory:top |
|
316 |
" |
|
12199 | 317 |
! |
318 |
||
319 |
projectDefinitionClass |
|
320 |
^ ProjectDefinition definitionClassForPackage:self |
|
321 |
||
322 |
" |
|
323 |
'stx:libbasic' asPackageId projectDefinitionClass |
|
15373 | 324 |
'exept/expecco/foo' asPackageId projectDefinitionClass |
325 |
'exept/expecco/plugin/manualTest' asPackageId projectDefinitionClass |
|
326 |
'exept:expecco/plugin/manualTest' asPackageId projectDefinitionClass |
|
327 |
'exept_expecco_plugin_manualTest' asPackageId projectDefinitionClass |
|
12199 | 328 |
" |
13714 | 329 |
! |
330 |
||
331 |
projectDirectory |
|
14594 | 332 |
|pdClass| |
333 |
||
334 |
(pdClass := self projectDefinitionClass) isNil ifTrue:[^ nil]. |
|
335 |
^ pdClass projectDirectory |
|
13714 | 336 |
|
337 |
" |
|
338 |
'stx:libbasic2' asPackageId projectDirectory |
|
339 |
" |
|
340 |
||
341 |
"Created: / 21-09-2011 / 18:21:32 / cg" |
|
9577 | 342 |
! ! |
343 |
||
9571 | 344 |
!PackageId class methodsFor:'documentation'! |
345 |
||
346 |
version |
|
15373 | 347 |
^ '$Header: /cvs/stx/stx/libbasic/PackageId.st,v 1.22 2013-06-05 08:40:44 cg Exp $' |
12185 | 348 |
! |
349 |
||
350 |
version_CVS |
|
15373 | 351 |
^ '$Header: /cvs/stx/stx/libbasic/PackageId.st,v 1.22 2013-06-05 08:40:44 cg Exp $' |
9571 | 352 |
! ! |
15373 | 353 |