Skip to content

Commit

Permalink
add build (code) artifacts to main
Browse files Browse the repository at this point in the history
  • Loading branch information
twiddlingbits committed Jun 20, 2024
1 parent a563648 commit 01daac0
Show file tree
Hide file tree
Showing 80 changed files with 168 additions and 112 deletions.
2 changes: 1 addition & 1 deletion azure/docsite/api/api-c-con/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -186,7 +186,7 @@
<div role="main" class="document" itemscope="itemscope" itemtype="http://schema.org/Article">
<div class="section" itemprop="articleBody">

<h1 id="console-api-for-web-assembly-streamed-and-windowed">Console API for Web Assembly (Streamed and Windowed)</h1>
<h1 id="console-c-api-for-web-assembly-streamed-and-windowed">Console C API for Web Assembly (Streamed and Windowed)</h1>
<p>This section describes twr-wasm's method of providing and abstracting console I/O in Web Assembly Modules.</p>
<p>C character based input/output is abstracted by <code>struct IoConsole</code>. </p>
<p>Consoles can be "tty" aka "streamed", or they can be "windowed" (aka a "terminal"). </p>
Expand Down
2 changes: 1 addition & 1 deletion azure/docsite/api/api-c-d2d/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -138,7 +138,7 @@
<div role="main" class="document" itemscope="itemscope" itemtype="http://schema.org/Article">
<div class="section" itemprop="articleBody">

<h1 id="2d-draw-api-for-web-assembly">2D Draw API for Web Assembly</h1>
<h1 id="2d-draw-c-api-for-web-assembly">2D Draw C API for Web Assembly</h1>
<p>This section describes twr-wasm's C D2D API, which allows your Web Assembly module to call many of the JavaScript Canvas APIs. <a href="https://github.com/twiddlingbits/twr-wasm/blob/main/examples/balls/canvas.h">There is also a C++ canvas wrapper class</a> in the balls example.</p>
<h2 id="examples">Examples</h2>
<table>
Expand Down
3 changes: 2 additions & 1 deletion azure/docsite/api/api-c-general/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -356,7 +356,8 @@ <h2 id="twr_utf8_char_len">twr_utf8_char_len</h2>
int twr_utf8_char_len(const char *str);
</code></pre>
<h2 id="twr_utf32_to_code_page">twr_utf32_to_code_page</h2>
<p>Takes a utf32 value (aka unicode code point value), and fills in the passed character array buffer with the character encoding of the utf32 value, using the current locale's LC_CTYPE code page. </p>
<p>Takes a utf32 value (aka unicode code point value), and fills in the passed character array buffer with the character encoding of the utf32 value, using the current locale's LC_CTYPE code page. The buffer is 0 terminated.</p>
<p>Also see <code>c32rtomb</code> and <code>c16rtomb</code>.</p>
<p>For example:</p>
<pre><code>char strbuf[6]; // max size of utf-8 is 4+terminating zero. Max size of ASCII or windows 1252 is 1 + terminating zero
setlocale(LC_ALL, &quot;&quot;); // set to default locale, which will be UTF-8 encoding with local language/region
Expand Down
37 changes: 17 additions & 20 deletions azure/docsite/api/api-libc++/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -135,29 +135,26 @@
<h1 id="libc-for-web-assembly">libc++ for Web Assembly</h1>
<p>This section describes twr-wasm's support for using the standard c++ library libc++ with Web Assembly.</p>
<p>twr-wasm includes libc++ built for Web Assembly and included in the <code>twr-wasm/lib-c</code> folder.</p>
<p>You can build twr-wasm projects in C++ with or without libc++.</p>
<p>For C++ the use of libc++ is optional. That is you can build twr-wasm projects in C++ with or without libc++.</p>
<p>See the examples tests-libcxx and tests-user for examples of using libc++.</p>
<p>See the balls example for how to create a C++ Web Assembly program without the standard C++ library. The primary advantage to this approach is a bit smaller code size. You don't need to staticly link libc++.</p>
<p>twr-wasm's libc++ for Web Assembly was built with these build options:</p>
<pre><code>LIBCXX_ENABLE_LOCALIZATION=ON
LIBCXX_ENABLE_STATIC_ABI_LIBRARY=ON
LIBCXXABI_ENABLE_STATIC_UNWINDER=ON
LIBCXXABI_ENABLE_STATIC=ON
<p>Some of the key options twr-wasm's libc++ for Web Assembly was built with are these:</p>
<pre><code>DLIBCXX_ENABLE_LOCALIZATION=ON
DLIBCXX_ENABLE_UNICODE=ON
DLIBCXX_ENABLE_RTTI=ON
DLIBCXX_ENABLE_STATIC_ABI_LIBRARY=ON

LIBCXX_ENABLE_FILESYSTEM=OFF
LIBCXX_ENABLE_TIME_ZONE_DATABASE=OFF
LIBCXX_ENABLE_MONOTONIC_CLOCK=OFF
LIBCXX_ENABLE_RANDOM_DEVICE=OFF
LIBCXX_ENABLE_UNICODE=OFF
LIBCXX_ENABLE_WIDE_CHARACTERS=OFF
LIBCXX_ENABLE_EXCEPTIONS=OFF
LIBCXXABI_ENABLE_EXCEPTIONS=OFF
LIBCXX_ENABLE_RTTI=OFF
LIBCXX_ENABLE_THREADS=OFF
LIBCXXABI_ENABLE_THREADS=OFF
LIBCXXABI_HAS_PTHREAD_API=OFF
LIBCXX_ENABLE_SHARED=OFF
LIBCXXABI_ENABLE_SHARED=OFF
DCMAKE_BUILD_TYPE=Release
DCMAKE_CXX_STANDARD=20

DLIBCXX_ENABLE_EXCEPTIONS=OFF
DLIBCXX_ENABLE_THREADS=OFF
DLIBCXX_ENABLE_SHARED=OFF
DLIBCXX_ENABLE_WIDE_CHARACTERS=OFF
DLIBCXX_ENABLE_FILESYSTEM=OFF
DLIBCXX_ENABLE_TIME_ZONE_DATABASE=OFF
DLIBCXX_ENABLE_MONOTONIC_CLOCK=OFF
DLIBCXX_ENABLE_RANDOM_DEVICE=OFF
</code></pre>

</div>
Expand Down
16 changes: 8 additions & 8 deletions azure/docsite/gettingstarted/compiler-opts/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -55,13 +55,13 @@
</li>
<li class="toctree-l1 current"><a class="reference internal current" href="./">Compiler, Linker, Memory</a>
<ul class="current">
<li class="toctree-l2"><a class="reference internal" href="#clang-with-c">clang with C</a>
<li class="toctree-l2"><a class="reference internal" href="#c-clang-compiler-options-targeting-wasm">C clang Compiler Options Targeting WASM</a>
</li>
<li class="toctree-l2"><a class="reference internal" href="#clang-with-c_1">clang with C++</a>
<li class="toctree-l2"><a class="reference internal" href="#c-clang-compiler-options-targeting-wasm_1">C++ clang Compiler Options Targeting WASM</a>
</li>
<li class="toctree-l2"><a class="reference internal" href="#linking">linking</a>
<li class="toctree-l2"><a class="reference internal" href="#wasm-ld-linker-options">wasm-ld Linker Options</a>
</li>
<li class="toctree-l2"><a class="reference internal" href="#memory">Memory</a>
<li class="toctree-l2"><a class="reference internal" href="#memory-options-for-web-assembly">Memory Options for Web Assembly</a>
</li>
</ul>
</li>
Expand Down Expand Up @@ -143,20 +143,20 @@
<h1 id="compiling-linking-and-memory-options">Compiling, Linking, and Memory Options</h1>
<p>This section described how to use clang to compile C/C++ code for Web Assembly, and how to link your files into a .wasm module.</p>
<p>twr-wasm lets you use clang directly, without a wrapper. This section describes the needed clang compile options and the wasm-ld link options. You can also take a look at the <a href="../../examples/examples-overview/">example makefiles</a>.</p>
<h2 id="clang-with-c">clang with C</h2>
<h2 id="c-clang-compiler-options-targeting-wasm">C clang Compiler Options Targeting WASM</h2>
<p>When compiling C code with clang for use with wasm and twr-wasm, use these clang options:</p>
<pre><code> --target=wasm32 -nostdinc -nostdlib -isystem ../../include
</code></pre>
<p>-isystem should point to the folder <code>twr-wasm/include</code>. The option line above uses a relative link to <code>include</code> that works if your project is a sub folder in the <code>examples</code> folder.</p>
<p>If you installed using npm, then includes are at <code>node_modules/twr-wasm/include</code> (see the <a href="../installation/">installation note on npm</a>).</p>
<p>You will also need to link to <code>twr.a</code> (explained in the linking section below).</p>
<h2 id="clang-with-c_1">clang with C++</h2>
<h2 id="c-clang-compiler-options-targeting-wasm_1">C++ clang Compiler Options Targeting WASM</h2>
<p>When compiling C++ code with clang for use with wasm and twr-wasm, use these clang options:</p>
<pre><code> --target=wasm32 -fno-exceptions -fno-rtti -nostdlibinc -nostdinc -nostdlib -isystem ../../include
</code></pre>
<p>You will also need to link to <code>twr.a</code> and <code>libc++.a</code> (explained in the linking section below).</p>
<p>Be sure to adjust the path to <code>twr.a</code>, <code>libc++.a</code>, and the <code>include</code> folder as needed (see above note in the C section).</p>
<h2 id="linking">linking</h2>
<h2 id="wasm-ld-linker-options">wasm-ld Linker Options</h2>
<p>Use the wasm-ld linker directly with twr-wasm.</p>
<p>All of the twr-wasm functions are staticly linked from the library <code>lib-c/twr.a</code>. There is also a version ( <code>lib-c/twrd.a</code> ) of twr-wasm library available with debug symbols. One of these two static libraries should be added to the list of files to link (normally this is <code>twr.a</code>). Both versions are built with asserts enabled. <code>twr.a</code> is built with <code>-O3</code>. <code>twrd.a</code> is built with <code>-g -O0</code>.</p>
<p>To use <code>libc++</code>, link to <code>libc++.a</code> (see the tests-libcxx example makefile).</p>
Expand All @@ -169,7 +169,7 @@ <h2 id="linking">linking</h2>
<p><strong>If Using twrWasmModuleAsync:</strong></p>
<pre><code>--no-entry --shared-memory --no-check-features --initial-memory=&lt;size&gt; --max-memory=&lt;size&gt;
</code></pre>
<h2 id="memory">Memory</h2>
<h2 id="memory-options-for-web-assembly">Memory Options for Web Assembly</h2>
<p>You set the memory size for your module (<code>WebAssembly.Memory</code>) using <code>wasm-ld</code> options as follows (this examples sets your wasm memory to 1MB). The memory size should be a multiple of 64*1024 (64K) chunks.</p>
<p>if using <code>twrWasmModule</code>:</p>
<pre><code>--initial-memory=1048576 --max-memory=1048576
Expand Down
18 changes: 9 additions & 9 deletions azure/docsite/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -54,9 +54,9 @@
</li>
<li class="toctree-l2"><a class="reference internal" href="#on-github">On Github</a>
</li>
<li class="toctree-l2"><a class="reference internal" href="#version-20-vs-10">Version 2.0 vs. 1.0</a>
<li class="toctree-l2"><a class="reference internal" href="#version-2-vs-1">Version 2 vs. 1</a>
</li>
<li class="toctree-l2"><a class="reference internal" href="#version-200-limitations">Version 2.0.0 Limitations</a>
<li class="toctree-l2"><a class="reference internal" href="#version-2-limitations">Version 2 Limitations</a>
</li>
<li class="toctree-l2"><a class="reference internal" href="#post-feedback">Post Feedback</a>
</li>
Expand Down Expand Up @@ -150,7 +150,7 @@
<div class="section" itemprop="articleBody">

<h1 id="twr-wasm-easy-cc-web-assembly-modules">twr-wasm - Easy C/C++ Web Assembly Modules</h1>
<p><strong>Documentation for twr-wasm Version 2.0.6</strong></p>
<p><strong>Documentation for twr-wasm Version 2.1.0</strong></p>
<p>twr-wasm is a simple, lightweight and easy to use library for building C/C++ Web Assembly code directly with clang. It solves some common use cases with less work than the more feature rich emscripten. </p>
<p>twr-wasm is easy to understand, and has some cool features. You can input and print streaming character i/o to a <code>&lt;div&gt;</code> tag, use a <code>&lt;canvas&gt;</code> element as an ANSI terminal, or use a C/C++ 2D drawing api (that is compatible with JavaScript Canvas APIs) to draw to a <code>&lt;canvas&gt;</code> element. You can run blocking C/C++. </p>
<p>twr-wasm allows you to run C/C++ code in a web browser. Legacy code, libraries, full applications, or single functions can be integrated with JavaScript and Typescript.</p>
Expand Down Expand Up @@ -235,17 +235,17 @@ <h2 id="view-live-web-assembly-demos">View Live Web Assembly Demos</h2>
</table>
<h2 id="on-github">On Github</h2>
<p><a href="https://github.com/twiddlingbits/twr-wasm">https://github.com/twiddlingbits/twr-wasm</a></p>
<h2 id="version-20-vs-10">Version 2.0 vs. 1.0</h2>
<h2 id="version-2-vs-1">Version 2 vs. 1</h2>
<ul>
<li>libc++ for wasm/clang is now available</li>
<li>libc++ built for Web Assembly is included</li>
<li>most of the standard C library is now implemented</li>
<li>instructions for source level debugging</li>
<li>instructions for Web Assembly C/C++ source level debugging</li>
<li>version of library with debug symbols provided</li>
<li>locale, UTF-8, and windows-1252 support</li>
</ul>
<h2 id="version-200-limitations">Version 2.0.0 Limitations</h2>
<h2 id="version-2-limitations">Version 2 Limitations</h2>
<ul>
<li>libc++ not built with threads, rtti, exceptions, unicode, or wide char support</li>
<li>libc++ not built with exceptions enabled</li>
<li>some standard C library functions are not 100% implemented</li>
<li>Designed to work with a browser. Not tested with or designed to work with node.js </li>
<li>Not all of compile-rt is ported (but most bits you need are)</li>
Expand Down Expand Up @@ -310,5 +310,5 @@ <h2 id="post-feedback">Post Feedback</h2>

<!--
MkDocs version : 1.5.3
Build Date UTC : 2024-06-19 01:14:15.102291+00:00
Build Date UTC : 2024-06-20 21:18:48.005091+00:00
-->
10 changes: 5 additions & 5 deletions azure/docsite/more/debugging/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -130,12 +130,12 @@
<div role="main" class="document" itemscope="itemscope" itemtype="http://schema.org/Article">
<div class="section" itemprop="articleBody">

<h1>Debugging</h1>
<h1>Debugging Web Assembly</h1>
<p>This section describes some tips for debugging your Web Assembly (asm) program.</p>
<h2>Debug & Release libs</h2>
<h2>Debug and Release libraries</h2>
<p>There are release (twr.a) and debug (twrd.a) versions of the twr-wasm C library. See the examples for use of both. The "debug" version has debug symbols enabled and is built with <code>-O0</code>. The "release" version has no debug symbols and optimization is set to <code>-O3</code>. Both have asserts enabled. In general, you should use the "release" version unless you wish to step through the twr-wasm source -- in which case use the "debug" version.</p>
<p>libc++.a is not built with debug symbols.</p>
<h2>C/C++ Source Level Debugging</h2>
<h2>Source Level Debugging Web Assembly C/C++ </h2>
<p>In order to enable C/C++ source debugging with wasm and clang, do the following:</p>
<ol>
<li>Use Chrome</li>
Expand All @@ -148,15 +148,15 @@ <h2>C/C++ Source Level Debugging</h2>
<li>you need to ensure that the web server/browser can find the source code</li>
<li>also see <a href="https://github.com/twiddlingbits/twr-wasm/blob/main/examples/readme.md">Example Readme</a></li>
</ol>
<h2>Useful Functions</h2>
<h2>Useful twr-wasm Debug Functions</h2>

<p>Use <code>twr_conlog</code> to print 'printf' style to the JavaScript console from C (reference is elsewhere in this doc.)</p>
<pre><code>#include &quot;twr-wasm.h&quot;

twr_conlog(&quot;hello 99 in hex: %x&quot;,99);
</code></pre>
<p>Use <code>twrWasmModule.divLog()</code> to print to a div inside JavaScript code (reference is elsewhere in this doc.)</p>
<h2>Testing Without a Web Server</h2>
<h2>Testing Web Assembly Without a Web Server</h2>

<p>Note: If you use this technique, you will not be able to get the c/C++ DevTool chrome extension to run, and so source level debugging won't work.</p>
<p>You can execute and debug JavaScript with wasm from local files without an HTTP server. It might be helpful to download the twr-wasm source code from github when you do this (so you can step through the twr-wasm typescript code as needed).</p>
Expand Down
2 changes: 1 addition & 1 deletion azure/docsite/search/search_index.json

Large diffs are not rendered by default.

Loading

0 comments on commit 01daac0

Please sign in to comment.