-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathtclapp.tcl
110 lines (82 loc) · 3.31 KB
/
tclapp.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
# -*- tcl -*- Copyright (c) 2012-2024 Andreas Kupries
# # ## ### ##### ######## ############# #####################
## Handle tklib/diagram figures (documentation)
namespace eval ::kettle { namespace export tclapp }
# # ## ### ##### ######## ############# #####################
## API.
proc ::kettle::tclapp {fname} {
## Recipe: Pure Tcl application installation.
io trace {}
io trace {DECLARE tcl application $fname @ [path sourcedir]}
meta scan
set src [path sourcedir $fname]
if {![file exists $src]} {
io trace { NOT FOUND}
return
}
# Derive application name from the path. Ignore extension and the
# directory the app file is in.
set name [file tail [file rootname $fname]]
meta read-internal $src application $name
io trace { Accepted: $fname}
recipe define install-app-$fname "Install application $fname" {name src} {
path install-script \
$src [path bindir] [info nameofexecutable] \
[lambda {name dst} {
kettle meta insert $dst application $name
} $name]
} $name $src
recipe define uninstall-app-$fname "Uninstall application $fname" {src} {
path uninstall-application \
$src [path bindir]
} $src
recipe define reinstall-app-$fname "Reinstall application $fname" {fname} {
invoke self uninstall-app-$fname
invoke self install-app-$fname
} $fname
# Hook the application specific recipes into a hierarchy of more
# general recipes.
recipe parent install-app-$fname install-tcl-applications
recipe parent install-tcl-applications install-applications
recipe parent install-applications install
recipe parent uninstall-app-$fname uninstall-tcl-applications
recipe parent uninstall-tcl-applications uninstall-applications
recipe parent uninstall-applications uninstall
recipe parent reinstall-app-$fname reinstall-tcl-applications
recipe parent reinstall-tcl-applications reinstall-applications
recipe parent reinstall-applications reinstall
# For applications without user-specified meta data we initialize
# a recipe which allows the developer to quickly insert a basic
# structure with standard keys, which can then be completed
# manually.
if {![meta defined? application $name]} {
recipe define meta-generate-application-$fname "Generate empty data for application $fname" {src name} {
dict set m platform tcl
dict set m author ?
dict set m summary ?
dict set m description ?
dict set m subject ?
dict set m category ?
dict set m require ?
meta fix-location m
if {![dict exists $m location]} {
dict set m location ?
}
set m [meta format-internal application $name ? $m]
path write-modify $src \
[list kettle path add-top-comment $m]
} $src $name
recipe parent meta-generate-application-$fname meta-generate-tcl-applications
recipe parent meta-generate-tcl-applications meta-generate-applications
recipe parent meta-generate-applications meta-generate
}
recipe define content-app-$fname "Show found application $fname" {name} {
puts ""
puts "* app - $name"
} $name
recipe parent content-app-$fname content-app
recipe parent content-app content
return
}
# # ## ### ##### ######## ############# #####################
return