sdx

Artifact [04794b95fc]
Login

Artifact 04794b95fcd36c4187f86bee7870416505edafaa:

Wiki page [howto] by aspect 2017-10-24 22:05:47.
D 2017-10-24T22:05:47.339
L howto
N text/x-markdown
P ff14c05dd823b06ceb3a98dc582b68a9510099fa
U aspect
W 3086
<h2>Customising a Tclkit</h2>

<p>You will need <tt>sdx.kit</tt> from the front page of this repo.  See <a href="tclkits">tclkits</a> for sources of pre-built kits</p>

<pre>
# grab a tclkit
curl -O http://www.rkeene.org/devel/kitcreator/kitbuild/nightly/tclkit-fossil_trunk-linux-amd64

# make a copy of tclkit to run sdx with
cp tclkit-fossil_trunk-linux-amd64 tclkit
chmod +x tclkit

# extract the vfs
./tclkit sdx.kit extract tclkit-fossil_trunk-linux-amd64

# add some code
echo 'puts "Hello, Tclkit"' >> tclkit-fossil_trunk-linux-amd64.vfs/boot.tcl

# sync changes back to tclkit
./tclkit sdx.kit sync tclkit-fossil_trunk-linux-amd64 tclkit-fossil_trunk-linux-amd64.vfs
</pre>

<p><tt>boot.tcl</tt> is run on tclkit startup.  Since there is no <tt>main.tcl</tt>, the tclkit will give you a Tcl shell.</p>


<h2>Wrapping an Application</h2>

Tclkits look for <tt>main.tcl</tt> to launch an application on startup.

<pre>
# grab a tclkit
curl -O http://www.rkeene.org/devel/kitcreator/kitbuild/nightly/tclkit-fossil_trunk-linux-amd64

# make a copy of tclkit to run sdx with
cp tclkit-fossil_trunk-linux-amd64 tclkit
chmod +x tclkit

# create your application
mkdir myapp.vfs
echo 'puts "Hello, Starkit!"' > myapp/main.tcl

# wrap it!
./tclkit sdx.kit wrap myapp -runtime tclkit-fossil_trunk-linux-amd64
</pre>

<p>Share the new executable <tt>myapp</tt> with your friends!</p>

<h2>Wrapping a simple script for multiple platforms</h2>

<p>This section introduces <b>qwrap</b> for single-script applications, and using <b>non-native runtimes</b> (eg: building Windows kits on Linux).</p>

<p>Create your script:</p>

<pre>
 $ mkdir hello
 $ cd hello
 $ echo > hello.tcl "
package require Tk
pack [button .b -text Hello -command exit]
"
</pre>

<p>Download the required bits:</p>

<pre>
 $ wget -O sdx.kit https://chiselapp.com/user/aspect/repository/sdx/uv/sdx-20110317.kit
 $ wget -O tclkit.exe http://www.rkeene.org/devel/kitcreator/kitbuild/nightly/tclkit-8.6.7-win64-amd64-xcompile
 $ wget -O tclkit http://www.rkeene.org/devel/kitcreator/kitbuild/nightly/tclkit-8.6.7-linux-amd64
 $ chmod +x tclkit
</pre>

<p>Wrap for Windows:</p>

<pre>
 $ ./tclkit sdx.kit qwrap hello.tcl -runtime tclkit.exe
 $ mv hello hello.exe
</pre>

<p>For native kits, remember <i>the tclkit that runs sdx cannot be the same tclkit that is used for -runtime</i> .. so make a copy:</p>

<pre>
 $ cp tclkit tclkit-linux
 $ ./tclkit sdx.kit qwrap hello.tcl -runtime tclkit-linux 
 $ ./hello
</pre>


<h2>More!</h2>

<p>The above steps are easily elaborated to ...</p>

<ul>
<li>wrap for different architectures</li>
<li>add further libraries (including native ones) (protip: use <a href="http://teaparty.rkeene.org/fossil/index"><tt>teapot-client</tt></a> to fetch them)</li>
<li>include custom assets in your kits</li>
<li>wrap <tt>sdx.kit</tt> to make it a standalone executable</li>
<li>put <tt>tclkit<tt> and <tt>sdx</tt> in your <tt>$PATH</tt></li>
<li>.. (almost) anything you can imagine!</li>
</ul>
Z 2463f35977df209d0a98b182ad3522d6