Tcl Extension Architecture (TEA) Sample Extension

Check-in [8e7886ba94]
Login
Bounty program for improvements to Tcl and certain Tcl packages.
Tcl 2018 Conference, Houston/TX, US, Oct 15-19
Send your abstracts to tclconference@googlegroups.com
or submit via the online form by Aug 20.

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

Overview
Comment:Updated the practcl version of the sample extension to use the newest version of practcl
Downloads: Tarball | ZIP archive | SQL archive
Timelines: family | ancestors | descendants | both | practcl
Files: files | file ages | folders
SHA3-256:8e7886ba94e9b4029048d15de16d1499dbf405cc6414bc4ee1cbf404e241bae0
User & Date: seandeelywoods 2018-01-17 20:23:43
Context
2018-01-18
00:32
Updated TEA

Added a "teapot" build target as a reference example check-in: 746f2b387e user: seandeelywoods tags: practcl

2018-01-17
20:23
Updated the practcl version of the sample extension to use the newest version of practcl check-in: 8e7886ba94 user: seandeelywoods tags: practcl
2016-10-13
15:28
Re-ran autoconf check-in: cbc0e011dc user: seandeelywoods tags: practcl
Changes
Hide Diffs Unified Diffs Ignore Whitespace Patch

Changes to configure.ac.

23
24
25
26
27
28
29
30
31
32
33
34
35
36
37

#--------------------------------------------------------------------
# Call TEA_INIT as the first TEA_ macro to set up initial vars.
# This will define a ${TEA_PLATFORM} variable == "unix" or "windows"
# as well as PKG_LIB_FILE and PKG_STUB_LIB_FILE.
#--------------------------------------------------------------------

TEA_INIT([3.10])
AC_PROG_LN_S
CONFIG_CLEAN_FILES=
if test ! -d $srcdir/tclconfig ; then
    if test -d $srcdir/../tclconfig ; then
        $LN_S $srcdir/../tclconfig tclconfig
        CONFIG_CLEAN_FILES=tclconfig
    fi







|







23
24
25
26
27
28
29
30
31
32
33
34
35
36
37

#--------------------------------------------------------------------
# Call TEA_INIT as the first TEA_ macro to set up initial vars.
# This will define a ${TEA_PLATFORM} variable == "unix" or "windows"
# as well as PKG_LIB_FILE and PKG_STUB_LIB_FILE.
#--------------------------------------------------------------------

TEA_INIT(4.0])
AC_PROG_LN_S
CONFIG_CLEAN_FILES=
if test ! -d $srcdir/tclconfig ; then
    if test -d $srcdir/../tclconfig ; then
        $LN_S $srcdir/../tclconfig tclconfig
        CONFIG_CLEAN_FILES=tclconfig
    fi

Changes to make.tcl.

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
83
84
85
86
87
88


89
90
91
92


93
94
95
96

97
98
99
100
101
102
103
104
105
106
107
108


109

110
111
112
113
114
115
116
117
118
119
120

121
122
123
124




125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145



146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165



















set CWD [pwd]
set ::project(builddir) $::CWD
set ::project(srcdir) [file dirname [file normalize [info script]]]
set ::project(sandbox)  [file dirname $::project(srcdir)]

if {[file exists [file join $CWD $::project(sandbox) tclconfig practcl.tcl]]} {
  source [file join $CWD $::project(sandbox) tclconfig practcl.tcl]
} else {
  source [file join $SRCPATH tclconfig practcl.tcl]
}

array set ::project [::practcl::config.tcl $CWD]
::practcl::library create LIBRARY [array get ::project]


LIBRARY add [file join $::project(srcdir) generic sample.c]
LIBRARY add [file join $::project(srcdir) generic sample.tcl]
LIBRARY define add public-verbatim [file join $::project(srcdir) generic sample.h]







###
# Create build targets
###
::practcl::target implement {}
::practcl::target autoconf {
  triggers implement
}
::practcl::target all {
  depends library
}
::practcl::target binaries {
  depends library
}
::practcl::target libraries {
  depends library
}
::practcl::target library {
  triggers implement
  filename [LIBRARY define get libfile]
}
::practcl::target doc {}

::practcl::target install {
  depends {library doc}
  triggers {install-package}
}
::practcl::target install-package {
  depends {library doc}
}
switch [lindex $argv 0] {
  install {
    ::practcl::trigger install
    set DESTDIR [file normalize [string trimright [lindex $argv 1]]]
  }
  install-package {
    ::practcl::trigger install
    set DESTDIR [file normalize [string trimright [lindex $argv 1]]]
  }
  default {
    ::practcl::trigger {*}$argv
  }
}

if {$make(implement)} {
  LIBRARY go
  LIBRARY implement $::project(builddir)
  set fout [open pkgIndex.tcl w]
  puts $fout "
  #
  # Tcl package index file
  #
  "
  puts $fout [LIBRARY package-ifneeded]
  close $fout
  if {![file exists make.tcl]} {
    set fout [open make.tcl w]
    puts $fout "# Redirect to the make file that lives in the project's source dir"
    puts $fout [list source [file join $::project(srcdir) make.tcl]]
    close $fout
    if {$::tcl_platform(platform)!="windows"} {
      file attributes -permission a+x make.tcl
    }
  }
}

if {$make(autoconf)} {
  #set mkout [open sample.mk w]
  #puts $mkout [::practcl::build::Makefile $::project(builddir) LIBRARY]
  #close $mkout
  LIBRARY generate-decls [LIBRARY define get name] $::project(builddir)
}



if {$make(library)} {
  puts "BUILDING [LIBRARY define get libfile]"
  ::practcl::build::library [LIBRARY define get libfile] LIBRARY
}



# Generate documentation
if {$make(doc)} {


}

if {![info exists DESTDIR] && [info exists ::env(DESTDIR)]} {
  set DESTDIR $::env(DESTDIR)
} else {
  set DESTDIR {}
}

###
# Build local variables needed for install
###
set dat [LIBRARY define dump]


set PKG_DIR [dict get $dat name][dict get $dat version]

dict with dat {}
if {$DESTDIR ne {}} {
  foreach path {
    includedir
    mandir
    datadir
    libdir
  } {
    set $path [file join [string trimright $DESTDIR /] [string trimleft [set $path] /]]
  }
}

set pkgdatadir [file join $datadir $PKG_DIR]
set pkglibdir [file join $libdir $PKG_DIR]
set pkgincludedir [file join $includedir $PKG_DIR]





if {$make(install)} {
  #========================================================================
  # This rule installs platform-independent files, such as header files.
  #========================================================================
  puts "Installing header files in ${includedir}"
  set result {}
  foreach hfile [LIBRARY install-headers] {
    ::practcl::installDir [file join $srcdir $hfile] ${includedir}
  }
  
  #========================================================================
  # Install documentation.  Unix manpages should go in the $(mandir)
  # directory.
  #========================================================================
  puts "Installing documentation in ${mandir}"
  foreach file [glob -nocomplain [file join $srcdir doc *.n]] {
    ::practcl::installDir $file [file join ${mandir} mann]
  }
}

if {$make(install-package)} {



  #========================================================================
  # Install binary object libraries.  On Windows this includes both .dll and
  # .lib files.  Because the .lib files are not explicitly listed anywhere,
  # we need to deduce their existence from the .dll file of the same name.
  # Library files go into the lib directory.
  # In addition, this will generate the pkgIndex.tcl
  # file in the install location (assuming it can find a usable tclsh shell)
  #
  # You should not have to modify this target.
  #========================================================================
  puts "Installing Library to ${pkglibdir}"
  ::practcl::installDir [LIBRARY define get libfile] $pkglibdir
  foreach file [glob -nocomplain *.lib] {
    ::practcl::installDir $file $pkglibdir
  }
  ::practcl::installDir pkgIndex.tcl $pkglibdir
  if {[LIBRARY define get output_tcl] ne {}} {
    ::practcl::installDir [LIBRARY define get output_tcl] $pkglibdir
  }
}





















|
|

|
|

|




>
>
|
|
|
>
>
>
>
>
>
>



<
<
|
<
<
<
<
<
<
<
|
<
|
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<













|







|
|
|
<
<

|
>
>
|
|
<
|
>
>
|
<
<
|
>
|
<
<
<
<
<
<
<
|
|
|
<
>
>
|
>
|
|
|
|
|
|
|
|
|
|
|
>
|
|
|
|
>
>
>
>
|





|
|
|
<










|
>
>
>











|




|
|
|
|
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
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
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104

105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
set CWD [pwd]
set ::project(builddir) $::CWD
set ::SRCDIR   [file dirname [file normalize [info script]]]
set ::SANDBOX  [file dirname $::SRCDIR]

if {[file exists [file join $::SANDBOX tclconfig practcl.tcl]]} {
  source [file join $::SANDBOX tclconfig practcl.tcl]
} else {
  source [file join $SRCDIR tclconfig practcl.tcl]
}

array set ::project [::practcl::config.tcl $CWD]
::practcl::library create LIBRARY [array get ::project]
LIBRARY define set builddir $CWD
LIBRARY define set srcdir $SRCDIR
LIBRARY add [file join $::SRCDIR generic sample.c]
LIBRARY add [file join $::SRCDIR generic sample.tcl]
LIBRARY define add public-verbatim [file join $::SRCDIR generic sample.h]

if {![LIBRARY define exists TCL_SRC_DIR]} {
  # Did not detect the Tcl source directory. Run autoconf
  ::practcl::doexec sh [file join $::SRCDIR configure]
  array set ::project [::practcl::config.tcl $CWD]
  LIBRARY define set [array get ::project]
}
###
# Create build targets
###


LIBRARY target add implement {







  filename sample.c

} {




























  LIBRARY go
  LIBRARY implement $::project(builddir)
  set fout [open pkgIndex.tcl w]
  puts $fout "
  #
  # Tcl package index file
  #
  "
  puts $fout [LIBRARY package-ifneeded]
  close $fout
  if {![file exists make.tcl]} {
    set fout [open make.tcl w]
    puts $fout "# Redirect to the make file that lives in the project's source dir"
    puts $fout [list source [file join $::SRCDIR make.tcl]]
    close $fout
    if {$::tcl_platform(platform)!="windows"} {
      file attributes -permission a+x make.tcl
    }
  }
}

LIBRARY target add all {
  aliases {binaries libraries}
  depends library


}

LIBRARY target add library {
  aliases {all libraries}
  triggers implement
  filename [LIBRARY define get libfile]

} {
  puts "BUILDING [my define get libfile]"
  my build-library [my define get libfile] [self]
}



LIBRARY target add install-info {
} {







  ###
  # Build local variables needed for install
  ###

  
  set dat [my define dump]
  set PKG_DIR [dict get $dat name][dict get $dat version]
  
  dict with dat {}
  if {$DESTDIR ne {}} {
    foreach path {
      includedir
      mandir
      datadir
      libdir
    } {
      set $path [file join [string trimright $DESTDIR /] [string trimleft [set $path] /]]
    }
  }
  
  set pkgdatadir [file join $datadir $PKG_DIR]
  set pkglibdir [file join $libdir $PKG_DIR]
  set pkgincludedir [file join $includedir $PKG_DIR]
}

LIBRARY target add install {
  depends {library doc}
  triggers {install-info install-package}
} {
  #========================================================================
  # This rule installs platform-independent files, such as header files.
  #========================================================================
  puts "Installing header files in ${includedir}"
  set result {}
  foreach hfile [my install-headers] {
    ::practcl::installDir [file join $srcdir $hfile] ${includedir}
  }

  #========================================================================
  # Install documentation.  Unix manpages should go in the $(mandir)
  # directory.
  #========================================================================
  puts "Installing documentation in ${mandir}"
  foreach file [glob -nocomplain [file join $srcdir doc *.n]] {
    ::practcl::installDir $file [file join ${mandir} mann]
  }
}

LIBRARY target add install-package {
  depends {library doc}
  triggers {install-info}
} {
  #========================================================================
  # Install binary object libraries.  On Windows this includes both .dll and
  # .lib files.  Because the .lib files are not explicitly listed anywhere,
  # we need to deduce their existence from the .dll file of the same name.
  # Library files go into the lib directory.
  # In addition, this will generate the pkgIndex.tcl
  # file in the install location (assuming it can find a usable tclsh shell)
  #
  # You should not have to modify this target.
  #========================================================================
  puts "Installing Library to ${pkglibdir}"
  ::practcl::installDir [my define get libfile] $pkglibdir
  foreach file [glob -nocomplain *.lib] {
    ::practcl::installDir $file $pkglibdir
  }
  ::practcl::installDir pkgIndex.tcl $pkglibdir
  if {[my define get output_tcl] ne {}} {
    ::practcl::installDir [my define get output_tcl] $pkglibdir
  }
}


if {[info exists ::env(DESTDIR)]} {
  LIBRARY define set DESTDIR $::env(DESTDIR)
}
switch [lindex $argv 0] {
  install {
    LIBRARY target trigger install
    LIBRARY define set DESTDIR [file normalize [string trimright [lindex $argv 1]]]
  }
  install-package {
    LIBRARY target trigger install
    LIBRARY define set DESTDIR [file normalize [string trimright [lindex $argv 1]]]
  }
  default {
    LIBRARY target trigger {*}$argv
  }
}
LIBRARY target do