Browse Source

Website index page configure.py example

pull/951/head
Sami Vaarala 8 years ago
parent
commit
829bb07318
  1. 34
      website/guide/gettingstarted.html
  2. 18
      website/index/index.html
  3. 3
      website/style-index.css

34
website/guide/gettingstarted.html

@ -72,16 +72,38 @@ $ ./duk fib.js
<h2>Integrating Duktape into your program</h2> <h2>Integrating Duktape into your program</h2>
<p>The command line tool is simply an example of a program which embeds <p>The command line tool is simply an example of a program which embeds
Duktape. Embedding Duktape into your program is very simple: just add Duktape. Embedding Duktape into your program is very simple:</p>
<code>duktape.c</code>, <code>duktape.h</code>, and <code>duk_config.h</code>
to your build, and call the Duktape API from elsewhere in your program.</p> <ul>
<li>Run <code>duktape-N.N.N/tools/configure.py</code> to configure Duktape
for build. The result is a directory containing <code>duktape.c</code>,
<code>duktape.h</code>, and <code>duk_config.h</code>.</li>
<li>Add <code>duktape.c</code>, <code>duktape.h</code>, and <code>duk_config.h</code>
to your build, and call the Duktape API from elsewhere in your program.</li>
</ul>
<p>The Duktape distributable (duktape-N.N.N.tar.xz) <code>src/</code> directory
contains preconfigured header and source files for the Duktape default configuration
which can usually be used as is. If needed, the configuration tool allows you to customize
Duktape options, such as optimizing Duktape for low memory targets and
enable/disable features. See <a href="#compiling">Compiling</a> and
<a href="http://wiki.duktape.org/Configuring.html">Configuring Duktape for build</a>
for more details and examples.</p>
<p>The distributable contains a very simple example program, <code>hello.c</code>, <p>The distributable contains a very simple example program, <code>hello.c</code>,
which illustrates this process. Compile the test program e.g. as (see which illustrates this process. Compile the test program with the preconfigured
<a href="#compiling">Compiling</a> for compiler option suggestions):</p> Duktape header and source files e.g. as follows:</p>
<pre>
$ cd /tmp/duktape-&lt;version&gt;/
$ gcc -std=c99 -o hello -Isrc src/duktape.c examples/hello/hello.c -lm
</pre>
<p>To customize Duktape configuration use <code>configure.py</code>:</p>
<pre> <pre>
$ cd /tmp/duktape-&lt;version&gt;/ $ cd /tmp/duktape-&lt;version&gt;/
$ gcc -std=c99 -o hello -Isrc/ src/duktape.c examples/hello/hello.c -lm # Here we disable Ecmascript 6 Proxy object support
$ python2 tools/configure.py --output-directory duktape-src -UDUK_USE_ES6_PROXY
$ gcc -std=c99 -o hello -Iduktape-src duktape-src/duktape.c examples/hello/hello.c -lm
</pre> </pre>
<p>The test program creates a Duktape context and uses it to run some <p>The test program creates a Duktape context and uses it to run some

18
website/index/index.html

@ -117,9 +117,23 @@ be used. The distributable contains an example Makefile for reference.
In the simplest case:</p> In the simplest case:</p>
<pre> <pre>
$ gcc -std=c99 -o test test.c duktape.c -lm $ gcc -std=c99 -otest test.c duktape.c -lm
$ ./test $ ./test
1+2=3 <span class="index-shell-output">1+2=3</span>
</pre>
<p>To <a href="http://wiki.duktape.org/Configuring.html">customize Duktape configuration</a>,
here to disable Ecmascript 6 <code>Proxy</code> object support:</p>
<pre>
$ python2 duktape-2.0.0/tools/configure.py --output-directory src-duktape \
-UDUK_USE_ES6_PROXY
$ ls src-duktape/
<span class="index-shell-output">duk_config.h duk_source_meta.json duktape.c duktape.h</span>
$ gcc -std=c99 -otest -Isrc-duktape \
test.c src-duktape/duktape.c -lm
$ ./test
<span class="index-shell-output">1+2=3</span>
</pre> </pre>
<h1><span class="step">2</span> Initialize a context</h1> <h1><span class="step">2</span> Initialize a context</h1>

3
website/style-index.css

@ -71,3 +71,6 @@
font-size: 16pt; font-size: 16pt;
} }
.index-shell-output {
color: #555599;
}

Loading…
Cancel
Save