diff --git a/kernel/PkgLoader.st b/kernel/PkgLoader.st index 260d8b8..475d544 100644 --- a/kernel/PkgLoader.st +++ b/kernel/PkgLoader.st @@ -431,7 +431,7 @@ PackageContainer subclass: PackageDirectory [ self file withReadStreamDo: [ :fileStream | [self parse: fileStream] on: SystemExceptions.PackageNotAvailable - do: [:ex | ex resignalAs: PackageSkip new]]. + do: [:ex | ex resignalAs: PackageSkip new]]. self packages: (self packages reject: [:each | each isDisabled]) ] @@ -1101,16 +1101,108 @@ PackageInfo subclass: StarPackage [ +Namespace current: Kernel [ + +Object subclass: Version [ + | major minor patch | + + Version class >> fromString: aString [ + + + | result | + [ result := aString searchRegex: '^(\d+)\.(\d+)(?:\.(\d+))?' ] on: Error do: [ :ex | self error: 'Bad version format ', aString, ' should be xx.yy(.zz)' ]. + ^ self major: result first asInteger minor: result second asInteger patch: (result third ifNil: [ 0 ] ifNotNil: [ result third asInteger ]) + ] + + Version class >> major: major minor: minor patch: patch [ + + + ^ self new + major: major minor: minor patch: patch + ] + + major: major minor: minor patch: patch [ + + + self + major: major; + minor: minor; + patch: patch + ] + + major [ + + + ^ major + ] + + major: anInteger [ + + + major := anInteger + ] + + minor [ + + + ^ minor + ] + + minor: anInteger [ + + + minor := anInteger + ] + + patch [ + + + ^ patch + ] + + patch: anInteger [ + + + patch := anInteger + ] +] +] + + Kernel.PackageInfo subclass: Package [ | features prerequisites builtFiles files fileIns relativeDirectory baseDirectories libraries modules callouts url namespace sunitScripts - startScript stopScript test | + startScript stopScript test version | + Package class [ | Tags | ] + + Package class >> tags [ + + + ^ Tags ifNil: [ Tags := Dictionary from: { + 'file' -> #addFile:. + 'filein' -> #addFileIn:. + 'prereq' -> #addPrerequisite:. + 'provides' -> #addFeature:. + 'module' -> #addModule:. + 'directory' -> #relativeDirectory:. + 'name' -> #name:. + 'url' -> #url:. + 'version' -> #parseVersion:. + 'namespace' -> #namespace:. + 'library' -> #addLibrary:. + 'built-file' -> #addBuiltFile:. + 'sunit' -> #addSunitScript:. + 'start' -> #startScript:. + 'stop' -> #stopScript:. + 'callout' -> #addCallout: } ] + ] + Package class >> parse: file [ "Answer a package from the XML description in file." @@ -1209,6 +1301,12 @@ XML.'> namespace := aString ] + addFeature: aString [ + + + self features add: aString + ] + features [ "Answer a (modifiable) Set of features provided by the package." @@ -1217,6 +1315,12 @@ XML.'> ^features ] + addPrerequisite: aString [ + + + self prerequisites add: aString + ] + prerequisites [ "Answer a (modifiable) Set of prerequisites." @@ -1225,6 +1329,12 @@ XML.'> ^prerequisites ] + addBuiltFile: aString [ + + + self builtFiles add: aString + ] + builtFiles [ "Answer a (modifiable) OrderedCollection of files that are part of the package but are not distributed." @@ -1234,6 +1344,12 @@ XML.'> ^builtFiles ] + addFile: aString [ + + + self files add: aString + ] + files [ "Answer a (modifiable) OrderedCollection of files that are part of the package." @@ -1243,6 +1359,12 @@ XML.'> ^files ] + addFileIn: aString [ + + + self fileIns add: aString + ] + fileIns [ "Answer a (modifiable) OrderedCollections of files that are to be filed-in to load the package. This is usually a subset of @@ -1253,6 +1375,12 @@ XML.'> ^fileIns ] + addLibrary: aString [ + + + self libraries add: aString + ] + libraries [ "Answer a (modifiable) Set of shared library names that are required to load the package." @@ -1262,6 +1390,12 @@ XML.'> ^libraries ] + addModule: aString [ + + + self modules add: aString + ] + modules [ "Answer a (modifiable) Set of modules that are required to load the package." @@ -1271,6 +1405,12 @@ XML.'> ^modules ] + addSunitScript: aString [ + + + self sunitScripts add: aString + ] + sunitScripts [ "Answer a (modifiable) OrderedCollection of SUnit scripts that compose the package's test suite." @@ -1280,6 +1420,12 @@ XML.'> ^sunitScripts ] + addCallout: aString [ + + + self callouts add: aString + ] + callouts [ "Answer a (modifiable) Set of call-outs that are required to load the package. Their presence is checked after the libraries and @@ -1366,6 +1512,24 @@ XML.'> relativeDirectory := dir ] + version [ + + + ^ version + ] + + version: aVersion [ + + + version := aVersion + ] + + parseVersion: aString [ + + + self version: (Version fromString: aString) + ] + primFileIn [ "Private - File in the given package without paying attention at dependencies and C callout availability" @@ -1417,24 +1581,8 @@ XML.'> (file upTo: $>) = tag ifFalse: [^self error: 'error in packages file: unmatched end tag ' , tag]. - "I tried to put these from the most common to the least common" - tag = 'file' ifTrue: [self files add: cdata] ifFalse: [ - tag = 'filein' ifTrue: [self fileIns add: cdata] ifFalse: [ - tag = 'prereq' ifTrue: [self prerequisites add: cdata] ifFalse: [ - tag = 'provides' ifTrue: [self features add: cdata] ifFalse: [ - tag = 'module' ifTrue: [self modules add: cdata] ifFalse: [ - tag = 'directory' ifTrue: [self relativeDirectory: cdata] ifFalse: [ - tag = 'name' ifTrue: [self name: cdata] ifFalse: [ - tag = 'url' ifTrue: [self url: cdata] ifFalse: [ - tag = 'namespace' ifTrue: [self namespace: cdata] ifFalse: [ - tag = 'library' ifTrue: [self libraries add: cdata] ifFalse: [ - tag = 'built-file' ifTrue: [self builtFiles add: cdata] ifFalse: [ - tag = 'sunit' ifTrue: [self sunitScripts add: cdata] ifFalse: [ - tag = 'start' ifTrue: [self startScript: cdata] ifFalse: [ - tag = 'stop' ifTrue: [self stopScript: cdata] ifFalse: [ - tag = 'callout' ifTrue: [self callouts add: cdata] ifFalse: [ - tag = openingTag ifTrue: [^self] ifFalse: [ - self error: 'invalid tag ' , tag]]]]]]]]]]]]]]]]. + tag = openingTag ifTrue: [ ^ self ]. + self perform: (self class tags at: tag ifAbsent: [ self error: 'invalid tag ', tag ]) with: cdata. cdata := nil]. ch isAlphaNumeric ifTrue: