| 1 |
# selfcompanion.tcl -- |
| 2 |
# |
| 3 |
# A template demonstrating how to distribute the critcl file |
| 4 |
# as its own Tcl companion file. |
| 5 |
# |
| 6 |
# This is not really the recommended way of handling Tcl |
| 7 |
# companion code, however as critcl 2 supported this, and v3 is |
| 8 |
# still supporting it, an example might still be in order. |
| 9 |
# |
| 10 |
# One issue this causes is a dependency on critcl itself in the |
| 11 |
# generated package. Whereas if the Tcl code to distribute is |
| 12 |
# properly split off into a separate companion file such a |
| 13 |
# dependency can be avoided. |
| 14 |
# |
| 15 |
# Copyright (c) 2011,2022 Andreas Kupries <[email protected]> |
| 16 |
|
| 17 |
# # ## ### ##### ######## ############# ##################### |
| 18 |
## Requirements |
| 19 |
|
| 20 |
package require Tcl 8.6 9 |
| 21 |
package require critcl 3.2 |
| 22 |
|
| 23 |
# # ## ### ##### ######## ############# ##################### |
| 24 |
## Define the Tcl companion code. This is done always, as we |
| 25 |
## might be in mode 'build & run'. |
| 26 |
|
| 27 |
proc companion {} { |
| 28 |
return [self] |
| 29 |
} |
| 30 |
|
| 31 |
# # ## ### ##### ######## ############# ##################### |
| 32 |
## Determine the environment, and define/build the C parts only |
| 33 |
## if not noted as build already. |
| 34 |
|
| 35 |
#puts Compiled=[critcl::compiled] |
| 36 |
|
| 37 |
if {[critcl::compiled]} return |
| 38 |
|
| 39 |
#critcl::msg "Declaring, building C parts" |
| 40 |
|
| 41 |
#puts Compiling=[critcl::compiling] |
| 42 |
|
| 43 |
if {![critcl::compiling]} { |
| 44 |
return -code error "Unable to build the C parts of selfcompanion" |
| 45 |
} |
| 46 |
|
| 47 |
# # ## ### ##### ######## ############# ##################### |
| 48 |
## Administrivia |
| 49 |
|
| 50 |
critcl::license {Andreas Kupries} BSD |
| 51 |
|
| 52 |
critcl::summary {Demonstration of using the critcl file as its own Tcl companion} |
| 53 |
|
| 54 |
critcl::description { |
| 55 |
This package implements nothing. It serves only as a |
| 56 |
demonstration and template on how to setup and distribute |
| 57 |
the critcl file as its own Tcl companion file. |
| 58 |
} |
| 59 |
|
| 60 |
critcl::subject template demonstration self-companion |
| 61 |
|
| 62 |
# # ## ### ##### ######## ############# ##################### |
| 63 |
## Configuration, setup as its own Tcl companion file. |
| 64 |
|
| 65 |
critcl::tsources [info script] |
| 66 |
|
| 67 |
# # ## ### ##### ######## ############# ##################### |
| 68 |
## C code. |
| 69 |
|
| 70 |
critcl::cdata self "me" |
| 71 |
|
| 72 |
# ... And other parts of the C level ... |
| 73 |
|
| 74 |
# ### ### ### ######### ######### ######### |
| 75 |
## Ready |
| 76 |
package provide selfcompanion 1 |