Artifact 9b7eb5b94a881a1d875905724e12ba2f2795c8bf:
Wiki page
[
Make minimal vanillawish binary] by
chw
2020-10-24 05:30:13.
D 2020-10-24T05:30:13.802
L Make\sminimal\svanillawish\sbinary
U chw
W 1775
<h2>How to make a minimal vanillawish binary ...</h2>
... out of a running [vanillawish]? The same technique can be used with [undroidwish], too.
<verbatim>
# we're working in a temp directory ...
file delete -force -- tmpdir[pid]
# extract everything from current binary
file copy [info nameofexecutable] tmpdir[pid]
# remove unwanted stuff from tmpdir[pid]
# ... TODO (adapt it to your requirements)
# here let's keep the bare minimum
apply {keep {
foreach name [glob -tails -dir tmpdir[pid] *] {
if {$name in $keep} {
continue
}
file delete -force -- [file join tmpdir[pid] $name]
}
}} [list tcl8.6 tk8.6 sdl2tk8.6]
# the app directory to place our own stuff
file mkdir [file join tmpdir[pid] app]
# add app code to tmpdir[pid]/app, at least a main.tcl
# is required which provides the entry point
# ... TODO (example given)
apply {name {
set f [open $name w]
# a very small app ...
puts $f "button .b -text {Press Me} -command exit ; pack .b"
close $f
}} [file join tmpdir[pid] app main.tcl]
# rebuild a new binary, stripping the temp directory in all file names
if {$tcl_platform(platform) eq "windows"} {
zipfs::mkimg myapp.exe tmpdir[pid] tmpdir[pid]
} else {
zipfs::mkimg myapp tmpdir[pid] tmpdir[pid]
}
# remove the temp directory
file delete -force -- tmpdir[pid]
# try to start the new binary if it is a wish
# otherwise stdin would be needed and we can't
# run in background.
if {[info command winfo] eq "winfo"} {
if {$tcl_platform(platform) eq "windows"} {
catch {exec [file join [pwd] myapp.exe] < NUL: &}
} else {
catch {exec [file join [pwd] myapp] < /dev/null &}
}
}
# done
exit
</verbatim>
Z e5f09c68a374b3004c436700d9293d2b