MCStxMczWriter.st
author Claus Gittinger <cg@exept.de>
Thu, 28 Mar 2013 17:23:21 +0100
changeset 771 cfb9eb763bc2
parent 769 6a647dbd3630
child 847 3426cc8e79d9
permissions -rw-r--r--
class: MCStxMczWriter added: #serializeDefinitions: fix for wide strings
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
738
85d0afcc16e3 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
     1
"{ Package: 'stx:goodies/monticello' }"
85d0afcc16e3 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
     2
85d0afcc16e3 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
     3
MCMczWriter subclass:#MCStxMczWriter
85d0afcc16e3 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
     4
	instanceVariableNames:''
85d0afcc16e3 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
     5
	classVariableNames:''
85d0afcc16e3 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
     6
	poolDictionaries:''
743
a43cc4d9b6dc option to save st/x extra stuff in the mcz
Claus Gittinger <cg@exept.de>
parents: 738
diff changeset
     7
	category:'SCM-Monticello-St/X Storing'
738
85d0afcc16e3 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
     8
!
85d0afcc16e3 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
     9
85d0afcc16e3 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    10
!MCStxMczWriter class methodsFor:'documentation'!
85d0afcc16e3 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    11
85d0afcc16e3 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    12
documentation
85d0afcc16e3 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    13
"
85d0afcc16e3 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    14
    redefined to add some more stuff to the mcz archive:
85d0afcc16e3 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    15
85d0afcc16e3 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    16
    - package pragma to the source code.
85d0afcc16e3 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    17
    - stx subdirectory (optional), containing required support files for building
85d0afcc16e3 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    18
          plus resource files.
85d0afcc16e3 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    19
    - stx.bin subdirectory (optional), containing a precompiled binary dll as per architecture.
85d0afcc16e3 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    20
"
85d0afcc16e3 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    21
! !
85d0afcc16e3 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    22
85d0afcc16e3 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    23
!MCStxMczWriter methodsFor:'accessing'!
85d0afcc16e3 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    24
85d0afcc16e3 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    25
snapshotWriterClass
85d0afcc16e3 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    26
        ^ MCStxStWriter
85d0afcc16e3 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    27
! !
85d0afcc16e3 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    28
771
cfb9eb763bc2 class: MCStxMczWriter
Claus Gittinger <cg@exept.de>
parents: 769
diff changeset
    29
!MCStxMczWriter methodsFor:'serializing'!
cfb9eb763bc2 class: MCStxMczWriter
Claus Gittinger <cg@exept.de>
parents: 769
diff changeset
    30
cfb9eb763bc2 class: MCStxMczWriter
Claus Gittinger <cg@exept.de>
parents: 769
diff changeset
    31
serializeDefinitions:definitions
cfb9eb763bc2 class: MCStxMczWriter
Claus Gittinger <cg@exept.de>
parents: 769
diff changeset
    32
    |string|
cfb9eb763bc2 class: MCStxMczWriter
Claus Gittinger <cg@exept.de>
parents: 769
diff changeset
    33
cfb9eb763bc2 class: MCStxMczWriter
Claus Gittinger <cg@exept.de>
parents: 769
diff changeset
    34
    string := super serializeDefinitions:definitions.
cfb9eb763bc2 class: MCStxMczWriter
Claus Gittinger <cg@exept.de>
parents: 769
diff changeset
    35
    string isWideString ifTrue:[
cfb9eb763bc2 class: MCStxMczWriter
Claus Gittinger <cg@exept.de>
parents: 769
diff changeset
    36
        ^ string utf8Encoded
cfb9eb763bc2 class: MCStxMczWriter
Claus Gittinger <cg@exept.de>
parents: 769
diff changeset
    37
    ].
cfb9eb763bc2 class: MCStxMczWriter
Claus Gittinger <cg@exept.de>
parents: 769
diff changeset
    38
    ^ string
cfb9eb763bc2 class: MCStxMczWriter
Claus Gittinger <cg@exept.de>
parents: 769
diff changeset
    39
! !
cfb9eb763bc2 class: MCStxMczWriter
Claus Gittinger <cg@exept.de>
parents: 769
diff changeset
    40
738
85d0afcc16e3 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    41
!MCStxMczWriter methodsFor:'visiting'!
85d0afcc16e3 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    42
85d0afcc16e3 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    43
writeBuildSupportFiles:aVersion for:aProjectDefinition
769
6a647dbd3630 class: MCStxMczWriter
Claus Gittinger <cg@exept.de>
parents: 759
diff changeset
    44
    Error handle:[:ex |
6a647dbd3630 class: MCStxMczWriter
Claus Gittinger <cg@exept.de>
parents: 759
diff changeset
    45
        Dialog information:('Cannot write build support files because:\\',ex description,'\\Writing source files only.') withCRs.
6a647dbd3630 class: MCStxMczWriter
Claus Gittinger <cg@exept.de>
parents: 759
diff changeset
    46
        ^ self
6a647dbd3630 class: MCStxMczWriter
Claus Gittinger <cg@exept.de>
parents: 759
diff changeset
    47
    ] do:[
6a647dbd3630 class: MCStxMczWriter
Claus Gittinger <cg@exept.de>
parents: 759
diff changeset
    48
        aProjectDefinition forEachFileNameAndGeneratedContentsDo:[:file :contents |
6a647dbd3630 class: MCStxMczWriter
Claus Gittinger <cg@exept.de>
parents: 759
diff changeset
    49
            self addString: contents at: 'snapshot.stx/', file.
6a647dbd3630 class: MCStxMczWriter
Claus Gittinger <cg@exept.de>
parents: 759
diff changeset
    50
        ].
6a647dbd3630 class: MCStxMczWriter
Claus Gittinger <cg@exept.de>
parents: 759
diff changeset
    51
    ]
738
85d0afcc16e3 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    52
!
85d0afcc16e3 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    53
85d0afcc16e3 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    54
writeIndividualSourceFiles:aVersion for:aProjectDefinition
85d0afcc16e3 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    55
    "individual source files for dll compilation"
85d0afcc16e3 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    56
85d0afcc16e3 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    57
    aProjectDefinition classNames do:[:eachClassName |
85d0afcc16e3 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    58
        |cls fileName source|
85d0afcc16e3 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    59
85d0afcc16e3 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    60
        cls := Smalltalk classNamed:eachClassName.
85d0afcc16e3 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    61
        cls isNil ifTrue:[
85d0afcc16e3 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    62
            Transcript showCR:'class missing: ',eachClassName
85d0afcc16e3 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    63
        ] ifFalse:[
85d0afcc16e3 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    64
            cls autoload.
85d0afcc16e3 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    65
85d0afcc16e3 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    66
            fileName := (Smalltalk fileNameForClass:cls),'.st'.
85d0afcc16e3 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    67
            source := String streamContents:[:s | cls fileOutOn:s withTimeStamp:false].
743
a43cc4d9b6dc option to save st/x extra stuff in the mcz
Claus Gittinger <cg@exept.de>
parents: 738
diff changeset
    68
            self addString: source at: 'snapshot.stx/', fileName.                               
738
85d0afcc16e3 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    69
        ]
85d0afcc16e3 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    70
    ].
85d0afcc16e3 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    71
!
85d0afcc16e3 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    72
85d0afcc16e3 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    73
writeResourceFiles:aVersion for:aProjectDefinition
85d0afcc16e3 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    74
    "language translations kept in externalfiles"
85d0afcc16e3 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    75
85d0afcc16e3 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    76
    |dir rsrcDir|
85d0afcc16e3 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    77
769
6a647dbd3630 class: MCStxMczWriter
Claus Gittinger <cg@exept.de>
parents: 759
diff changeset
    78
    dir := aProjectDefinition projectDirectory.
6a647dbd3630 class: MCStxMczWriter
Claus Gittinger <cg@exept.de>
parents: 759
diff changeset
    79
    dir isNil ifTrue:[
6a647dbd3630 class: MCStxMczWriter
Claus Gittinger <cg@exept.de>
parents: 759
diff changeset
    80
        "/ no directory - no resource files
6a647dbd3630 class: MCStxMczWriter
Claus Gittinger <cg@exept.de>
parents: 759
diff changeset
    81
        ^  self.
6a647dbd3630 class: MCStxMczWriter
Claus Gittinger <cg@exept.de>
parents: 759
diff changeset
    82
    ].
6a647dbd3630 class: MCStxMczWriter
Claus Gittinger <cg@exept.de>
parents: 759
diff changeset
    83
    (rsrcDir := dir asFilename / 'resources') exists ifTrue:[
738
85d0afcc16e3 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    84
        rsrcDir recursiveDirectoryContentsDo:[:relFn |
85d0afcc16e3 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    85
            (rsrcDir construct:relFn) isDirectory ifFalse:[
743
a43cc4d9b6dc option to save st/x extra stuff in the mcz
Claus Gittinger <cg@exept.de>
parents: 738
diff changeset
    86
                self addString: ((rsrcDir construct:relFn) contentsOfEntireFile) at: 'snapshot.stx/resources/', relFn.
738
85d0afcc16e3 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    87
            ]            
85d0afcc16e3 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    88
        ].
85d0afcc16e3 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    89
    ].
85d0afcc16e3 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    90
!
85d0afcc16e3 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    91
759
fc131485692e class: MCStxMczWriter
Claus Gittinger <cg@exept.de>
parents: 743
diff changeset
    92
writeSnapshot: aSnapshot  forVersion: aVersion
fc131485692e class: MCStxMczWriter
Claus Gittinger <cg@exept.de>
parents: 743
diff changeset
    93
    |source|
fc131485692e class: MCStxMczWriter
Claus Gittinger <cg@exept.de>
parents: 743
diff changeset
    94
fc131485692e class: MCStxMczWriter
Claus Gittinger <cg@exept.de>
parents: 743
diff changeset
    95
    source := 
fc131485692e class: MCStxMczWriter
Claus Gittinger <cg@exept.de>
parents: 743
diff changeset
    96
        ('"{ Package: ''%1'' }" !!\\' withCRs bindWith:aVersion package name)
fc131485692e class: MCStxMczWriter
Claus Gittinger <cg@exept.de>
parents: 743
diff changeset
    97
        ,  (self serializeDefinitions: aSnapshot definitions).
fc131485692e class: MCStxMczWriter
Claus Gittinger <cg@exept.de>
parents: 743
diff changeset
    98
fc131485692e class: MCStxMczWriter
Claus Gittinger <cg@exept.de>
parents: 743
diff changeset
    99
    self addString: source at: 'snapshot/source.', self snapshotWriterClass extension.
738
85d0afcc16e3 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   100
    "/ I whink, we can comment the following (or is it compatible?)
85d0afcc16e3 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   101
    self addString: (self serializeInBinary: aSnapshot) at: 'snapshot.bin'
85d0afcc16e3 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   102
!
85d0afcc16e3 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   103
85d0afcc16e3 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   104
writeVersion: aVersion
85d0afcc16e3 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   105
    |packageID prjDef|
85d0afcc16e3 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   106
743
a43cc4d9b6dc option to save st/x extra stuff in the mcz
Claus Gittinger <cg@exept.de>
parents: 738
diff changeset
   107
    super writeVersion: aVersion.
738
85d0afcc16e3 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   108
743
a43cc4d9b6dc option to save st/x extra stuff in the mcz
Claus Gittinger <cg@exept.de>
parents: 738
diff changeset
   109
    aVersion snapshot includeExtrasForSTX ifTrue:[
a43cc4d9b6dc option to save st/x extra stuff in the mcz
Claus Gittinger <cg@exept.de>
parents: 738
diff changeset
   110
        "/ ST/X specific stuff here.
738
85d0afcc16e3 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   111
743
a43cc4d9b6dc option to save st/x extra stuff in the mcz
Claus Gittinger <cg@exept.de>
parents: 738
diff changeset
   112
        packageID := aVersion package name.
a43cc4d9b6dc option to save st/x extra stuff in the mcz
Claus Gittinger <cg@exept.de>
parents: 738
diff changeset
   113
        prjDef := ProjectDefinition definitionClassForPackage:packageID.
a43cc4d9b6dc option to save st/x extra stuff in the mcz
Claus Gittinger <cg@exept.de>
parents: 738
diff changeset
   114
        prjDef isNil ifTrue:[
a43cc4d9b6dc option to save st/x extra stuff in the mcz
Claus Gittinger <cg@exept.de>
parents: 738
diff changeset
   115
            "/ not a project definition mcz - simply skip
a43cc4d9b6dc option to save st/x extra stuff in the mcz
Claus Gittinger <cg@exept.de>
parents: 738
diff changeset
   116
            Transcript show:'No projectDefinition for ',packageID, ' generated simple source only'.
a43cc4d9b6dc option to save st/x extra stuff in the mcz
Claus Gittinger <cg@exept.de>
parents: 738
diff changeset
   117
        ] ifFalse:[
a43cc4d9b6dc option to save st/x extra stuff in the mcz
Claus Gittinger <cg@exept.de>
parents: 738
diff changeset
   118
            "/ additional support files for recompilation...
a43cc4d9b6dc option to save st/x extra stuff in the mcz
Claus Gittinger <cg@exept.de>
parents: 738
diff changeset
   119
            self writeIndividualSourceFiles: aVersion for: prjDef.
a43cc4d9b6dc option to save st/x extra stuff in the mcz
Claus Gittinger <cg@exept.de>
parents: 738
diff changeset
   120
            self writeBuildSupportFiles: aVersion for: prjDef.
a43cc4d9b6dc option to save st/x extra stuff in the mcz
Claus Gittinger <cg@exept.de>
parents: 738
diff changeset
   121
            self writeResourceFiles: aVersion for: prjDef.
a43cc4d9b6dc option to save st/x extra stuff in the mcz
Claus Gittinger <cg@exept.de>
parents: 738
diff changeset
   122
        ]
738
85d0afcc16e3 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   123
    ]
85d0afcc16e3 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   124
! !
85d0afcc16e3 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   125
85d0afcc16e3 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   126
!MCStxMczWriter class methodsFor:'documentation'!
85d0afcc16e3 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   127
85d0afcc16e3 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   128
version
771
cfb9eb763bc2 class: MCStxMczWriter
Claus Gittinger <cg@exept.de>
parents: 769
diff changeset
   129
    ^ '$Header: /cvs/stx/stx/goodies/monticello/MCStxMczWriter.st,v 1.5 2013-03-28 16:23:21 cg Exp $'
738
85d0afcc16e3 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   130
!
85d0afcc16e3 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   131
85d0afcc16e3 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   132
version_CVS
771
cfb9eb763bc2 class: MCStxMczWriter
Claus Gittinger <cg@exept.de>
parents: 769
diff changeset
   133
    ^ '$Header: /cvs/stx/stx/goodies/monticello/MCStxMczWriter.st,v 1.5 2013-03-28 16:23:21 cg Exp $'
738
85d0afcc16e3 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   134
! !
85d0afcc16e3 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   135