Check-in [0b3cc9ffb0]
Not logged in

Many hyperlinks are disabled.
Use anonymous login to enable hyperlinks.

Overview
Comment:Added a "-load" option to mkmodule to be able to control the package name associated with a shared object when it is loaded.
Timelines: family | ancestors | descendants | both | trunk
Files: files | file ages | folders
SHA1:0b3cc9ffb03b46e7b85dc7380da80973b83a02da
User & Date: andrewm 2019-02-20 14:53:53
Context
2019-03-01
11:45
Merging dbusclient develop onto the trunk and releasing the package as version 1.0 check-in: d72d1d5123 user: andrewm tags: trunk
2019-02-20
14:53
Added a "-load" option to mkmodule to be able to control the package name associated with a shared object when it is loaded. check-in: 0b3cc9ffb0 user: andrewm tags: trunk
2019-02-02
14:51
Adding literate program PDF to the release. check-in: f4346a12c4 user: andrewm tags: trunk, mecate-1.1
Changes

Changes to applications/mkmodule.

50
51
52
53
54
55
56




57
58
59
60
61
62
63
..
97
98
99
100
101
102
103

104
105
106
107
108
109
110
...
118
119
120
121
122
123
124



125
126
127
128
129
130
131
...
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
#   -script scriptfile gives the name of a text file containing
#           a Tcl script. Multiple script files may be placed in the module.
#   -Linux | -Windows | -Darwin | -FreeBSD libraryfile gives the name of
#           a shared object file for the appropriate OS. Multiple platform
#           binaries may be placed in the module
#   -outdir The name of directory where the output module file is placed.
#           By default, the current directory.




#
#   A Tcl module file is constructed from the binary and script files
#   and placed in the output directory. The file name follows the
#   pattern required by Tcl module files, i.e. package-version.tm.

namespace eval ::mkmodule {
    namespace export module
................................................................................
    variable templateSize 256
}

proc ::mkmodule::module {package version args} {
    set scripts [list]
    set binaries [dict create]
    set outdir .


    # Parse arguments and accumlate the argument information into
    # some data variables for later.
    set nargs [llength $args]
    for {set aindex 0} {$aindex < $nargs} {incr aindex} {
        set arg [lindex $args $aindex]
        switch -exact -- $arg {
................................................................................
            }
            -outdir {
                set outdir [lindex $args [incr aindex]]
                if {![file isdirectory $outdir]} {
                    error "output location, \"$outdir\", is not a directory"
                }
            }



            -Windows -
            -Linux -
            -Darwin -
            -FreeBSD {
                set filename [lindex $args [incr aindex]]
                validateFile $filename
                if {[dict exists $binaries $filename]} {
................................................................................
                if {$count != 1} {
                    chan puts -nonewline $tmchan " else"
                }
                incr count

                set loadCode [format $loadTemplate\
                    [dict get $props os] [dict get $props offset]\
                    [dict get $props size] $package]
                chan puts -nonewline $tmchan $loadCode
            }
            chan puts $tmchan " else \{"
            chan puts $tmchan {    error "no binary found for\
                    $::tcl_platform(os)"}
            chan puts $tmchan "\}"
            puts $tmchan "rename __copyAndLoad__ {}"
            # Check that the overwriting didn't destroy anything.
            if {[chan tell $tmchan] - $loadOffset > $slackSpace} {
                error "panic, overwrote space allocated for loading script"
            }
        }
    } finally {
        chan close $tmchan







>
>
>
>







 







>







 







>
>
>







 







|






|







50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
...
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
...
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
...
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
#   -script scriptfile gives the name of a text file containing
#           a Tcl script. Multiple script files may be placed in the module.
#   -Linux | -Windows | -Darwin | -FreeBSD libraryfile gives the name of
#           a shared object file for the appropriate OS. Multiple platform
#           binaries may be placed in the module
#   -outdir The name of directory where the output module file is placed.
#           By default, the current directory.
#   -load   The name to give to the load command when loading a
#           binary extension. By default this is the same name as the
#           package. However, some packages use different names for
#           the package and the shared object that is loaded.
#
#   A Tcl module file is constructed from the binary and script files
#   and placed in the output directory. The file name follows the
#   pattern required by Tcl module files, i.e. package-version.tm.

namespace eval ::mkmodule {
    namespace export module
................................................................................
    variable templateSize 256
}

proc ::mkmodule::module {package version args} {
    set scripts [list]
    set binaries [dict create]
    set outdir .
    set loadname $package

    # Parse arguments and accumlate the argument information into
    # some data variables for later.
    set nargs [llength $args]
    for {set aindex 0} {$aindex < $nargs} {incr aindex} {
        set arg [lindex $args $aindex]
        switch -exact -- $arg {
................................................................................
            }
            -outdir {
                set outdir [lindex $args [incr aindex]]
                if {![file isdirectory $outdir]} {
                    error "output location, \"$outdir\", is not a directory"
                }
            }
            -load {
                set loadname [lindex $args [incr aindex]]
            }
            -Windows -
            -Linux -
            -Darwin -
            -FreeBSD {
                set filename [lindex $args [incr aindex]]
                validateFile $filename
                if {[dict exists $binaries $filename]} {
................................................................................
                if {$count != 1} {
                    chan puts -nonewline $tmchan " else"
                }
                incr count

                set loadCode [format $loadTemplate\
                    [dict get $props os] [dict get $props offset]\
                    [dict get $props size] [list $loadname]]
                chan puts -nonewline $tmchan $loadCode
            }
            chan puts $tmchan " else \{"
            chan puts $tmchan {    error "no binary found for\
                    $::tcl_platform(os)"}
            chan puts $tmchan "\}"
            puts $tmchan "catch {rename __copyAndLoad__ {}}"
            # Check that the overwriting didn't destroy anything.
            if {[chan tell $tmchan] - $loadOffset > $slackSpace} {
                error "panic, overwrote space allocated for loading script"
            }
        }
    } finally {
        chan close $tmchan