File: first.inc

package info (click to toggle)
critcl 3.3.1%2Bdfsg-1
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid, trixie
  • size: 9,680 kB
  • sloc: ansic: 41,058; tcl: 12,090; sh: 7,230; pascal: 3,456; asm: 3,058; ada: 1,681; cpp: 1,001; cs: 879; makefile: 333; perl: 104; xml: 95; f90: 10
file content (82 lines) | stat: -rw-r--r-- 3,130 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
[comment {-*- mode: tcl ; fill-column: 90 -*-}]

To create a minimal working package

[list_begin enumerated]

[enum] Choose a directory to develop in and make it the working directory. This should
not be a checkout of [vset critcl] itself.

[enum] Save the following example to a file. In the following it is assumed that the file
was named [file example.tcl].

[example_begin]
[include first_pkg.inc]
[example_end]

[enum] Invoke the command [example { critcl -keep -debug all -pkg example.tcl }]

[para] This compiles the example and installs it into a [file lib/] sub directory of the
working directory, generating output similar to

[example {
    Config:   linux-x86_64-gcc
    Build:    linux-x86_64-gcc
    Target:   linux-x86_64
    Source:   example.tcl  (provide critcl-example 1) Building ...
    Library:  example.so
     (tclStubsPtr     =>  const TclStubs *tclStubsPtr;)
     (tclPlatStubsPtr =>  const TclPlatStubs *tclPlatStubsPtr;)
    Package:  lib/example
    Files left in /home/aku/.critcl/pkg2567272.1644845439   
}]

during operation.

[para] The [option -keep] option suppressed the cleanup of the generated C files, object
files, compiler log, etc. normally done at the end of building.

[example {
% ls -l /home/aku/.critcl/pkg2567272.1644845439
total 36
-rw-r--r-- 1 aku aku  1260 Feb 14 18:30 v3118_00000000000000000000000000000004.c
-rw-r--r-- 1 aku aku  2096 Feb 14 18:30 v3118_00000000000000000000000000000004_pic.o
-rw-r--r-- 1 aku aku  1728 Feb 14 18:30 v3118_00000000000000000000000000000009.c
-rw-r--r-- 1 aku aku  2448 Feb 14 18:30 v3118_00000000000000000000000000000009_pic.o
-rwxr-xr-x 1 aku aku 14424 Feb 14 18:30 v3118_00000000000000000000000000000009.so
-rw-r--r-- 1 aku aku  1725 Feb 14 18:30 v3118.log
}]

This enables inspection of the generated C code.

Simply drop the option from the command if that is not desired.

[para] The option [option -debug], with argument [const all] activated Tcl's memory
debugging and caused the generation of the symbol tables needed by [syscmd gdb] or any
other debugger. The alternate arguments [const memory] and [const symbols] activate just
one of the these.

[enum] Now invoke an interactive [syscmd tclsh] and enter the commands:
[list_begin itemized]
[item] [emph {lappend auto_path lib}]
[item] [emph {package require critcl-example}]
[item] [emph {info loaded}]
[item] [emph hello]
[item] [emph exit]
[list_end]

I.e. extend [syscmd tclsh]'s package search path to include the location of the new
package, load the package, verify that the associated shared library is present, invoke
the package command, and stop the session.

[para] When the package command is invoked the terminal will show [const {hello world}],
followed by the prompt.

[list_end]

[para] Commands: [term critcl::compiling], [term critcl::cproc],
[term critcl::description], [term critcl::license], [term critcl::load],
[term critcl::msg], [term critcl::subject], [term critcl::summary], [term critcl::tcl].

[para] Make a copy of [file example.tcl] before going through the sub-sections. Keep it as
a save point to return to from the editing done in the sub-section.