<!doctype html>
<html lang="en">
<head>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1">
<title>docs/content/building-from-source.md - fork/static-web-server @ allow-symlink</title>
<meta name="description" content="docs/content/building-from-source.md in fork/static-web-server at allow-symlink.">
<meta property="og:title" content="docs/content/building-from-source.md - fork/static-web-server @ allow-symlink">
<meta property="og:description" content="docs/content/building-from-source.md in fork/static-web-server at allow-symlink.">
<meta property="og:type" content="website">
<meta property="og:site_name" content="git.julia.blue">
<link rel="stylesheet" href="/css/style.css?v=62">
<script type="module" src="/js/main.js?v=62"></script>
</head>
<body>
<main data-ref="allow-symlink" data-tip="4414610fe1b0370ff0ac415e9367548840584710">
<noscript>
  <div class="callout">
    <p>
      hey! this is a static git repo viewer. commit diffs, file history,
      older commits and other revisions won't load without javascript.
    </p>
    <p>
      you are still able to view source files on branch/tag tips,
      but the experience is degraded.
    </p>
  </div>
</noscript>
<header class="repo"><div>
<h1>fork/static-web-server</h1>
</div>
<pre class="clone">git clone https://git.julia.blue/fork/static-web-server</pre>
</header>
<p class="snapshot-commit"><span class="commit-author">Jose Quintana</span><span class="commit-message" data-commit="0b128b9feb30bc9a7a53a14543958dc92304e17f">Update dependencies 2026-03-24 and bump up Rust to 1.88.0 (#641)</span><span class="snapshot-sha sha" data-commit="0b128b9feb30bc9a7a53a14543958dc92304e17f">0b128b9</span><time datetime="2026-03-24T18:00:12+01:00" title="2026-03-24 18:00:12 +0100">2026-03-24</time></p>
<header class="topbar"><details class="switcher"><summary>allow-symlink</summary><div class="menu"><strong>branches</strong><a class="current" href="/fork/static-web-server/ref/allow-symlink/">allow-symlink</a><a class="all" href="/fork/static-web-server/refs">all refs →</a></div></details><nav class="crumbs"><a href="/fork/static-web-server/">static-web-server</a> / <a href="/fork/static-web-server/ref/allow-symlink/tree/docs/">docs</a> / <a href="/fork/static-web-server/ref/allow-symlink/tree/docs/content/">content</a> / <span class="cur">building-from-source.md</span></nav>
<span class="view-stats"><span>5.9 KiB</span><span>144 lines</span></span><span class="actions"><a class="raw" href="/fork/static-web-server/raw/37c31386aa420be1ed8552e530b3032d38bed839/docs/content/building-from-source.md">raw</a></span></header>
<div class="markdown-view"><input type="radio" name="markdown-view" id="markdown-rendered" checked><label for="markdown-rendered">rendered</label><input type="radio" name="markdown-view" id="markdown-code"><label for="markdown-code">code</label><section class="readme rendered"><h1>Building from Source</h1>
<p>Follow these instructions to either build <strong><code>SWS</code></strong> project from the source or the HTML documentation.</p>
<h2>Building project from source</h2>
<p>If you want to build <strong>SWS</strong> from the source, make sure to install Rust <a href="https://blog.rust-lang.org/2025/06/26/Rust-1.88.0/">1.88.0</a> or newer (or nightly) along with <a href="https://rust-lang.github.io/rustup/concepts/toolchains.html">the toolchain(s)</a> of your preference.</p>
<p>Then clone the repository and use <a href="https://doc.rust-lang.org/cargo/">Cargo</a> to build the project from the source.</p>
<pre class="language-bash"><a-f>git</a-f> clone https://github.com/static-web-server/static-web-server.git
<a-f>cd</a-f> static-web-server
<a-f>cargo</a-f> build <a-co>--release</a-co></pre>
<p>Finally, the release binary should be available at <code>target/release/static-web-server</code> or under your toolchain directory chosen.</p>
<p>!!! info "Don't use the project's <code>Makefile</code>"</p>
<pre><code>Please don't use the project's `Makefile` since it's only intended for development and some on-demand tasks.
</code></pre>
<h2>Cargo features</h2>
<p>When building from the source, all features are enabled by default.
However, you can disable just the ones you don't need from the lists below.</p>
<table><thead><tr><th>Feature</th><th>Description</th></tr></thead><tbody>
<tr><td><strong>Default</strong></td><td></td></tr>
<tr><td><code>default</code></td><td>Activates the default features by omission.</td></tr>
<tr><td><code>all</code></td><td>Activates all available features including the <code>experimental</code> feature. This is the default feature used when building SWS binaries.</td></tr>
<tr><td><code>experimental</code></td><td>Activates all SWS experimental features. Make sure to also provide the required <code>RUSTFLAGS</code> if the feature requires so.</td></tr>
<tr><td><a href="/fork/static-web-server/ref/allow-symlink/blob/docs/content/features/http2-tls.md"><strong>HTTP2/TLS</strong></a></td><td></td></tr>
<tr><td><code>http2</code></td><td>Activates the HTTP2 and TLS feature.</td></tr>
<tr><td><a href="/fork/static-web-server/ref/allow-symlink/blob/docs/content/features/compression.md"><strong>Compression</strong></a></td><td></td></tr>
<tr><td><code>compression</code></td><td>Activates auto-compression with all supported algorithms.</td></tr>
<tr><td><code>compression-brotli</code></td><td>Activates auto-compression with only the <code>brotli</code> algorithm.</td></tr>
<tr><td><code>compression-deflate</code></td><td>Activates auto-compression with only the <code>deflate</code> algorithm.</td></tr>
<tr><td><code>compression-gzip</code></td><td>Activates auto-compression with only the <code>gzip</code> algorithm.</td></tr>
<tr><td><code>compression-zstd</code></td><td>Activates auto-compression with only the <code>zstd</code> algorithm.</td></tr>
<tr><td><a href="/fork/static-web-server/ref/allow-symlink/blob/docs/content/features/directory-listing.md"><strong>Directory Listing</strong></a></td><td></td></tr>
<tr><td><code>directory-listing</code></td><td>Activates the directory listing feature.</td></tr>
<tr><td><a href="/fork/static-web-server/ref/allow-symlink/blob/docs/content/features/basic-authentication.md"><strong>Basic Authorization</strong></a></td><td></td></tr>
<tr><td><code>basic-auth</code></td><td>Activates the Basic HTTP Authorization Schema feature.</td></tr>
<tr><td><a href="/fork/static-web-server/ref/allow-symlink/blob/docs/content/features/error-pages.md#fallback-page-for-use-with-client-routers"><strong>Fallback Page</strong></a></td><td></td></tr>
<tr><td><code>fallback-page</code></td><td>Activates the Fallback Page feature.</td></tr>
</tbody></table>
<h3>Disable all default features</h3>
<p>For example, if you want to run or build SWS without the default features like <code>compression</code>, <code>http2</code>, etc then just try:</p>
<pre class="language-bash"><a-c># run</a-c>
<a-f>cargo</a-f> run <a-co>--no-default-features</a-co> <a-co>--</a-co> <a-co>-h</a-co>

<a-c># build</a-c>
<a-f>cargo</a-f> build <a-co>--release</a-co> <a-co>--no-default-features</a-co>

<a-c># or build including all features (example)</a-c>
<a-pr>RUSTFLAGS</a-pr>=<a-s>&quot;--cfg tokio_unstable&quot;</a-s> \
    <a-f>cargo</a-f> build <a-co>-vv</a-co> <a-co>--release</a-co> <a-co>--features</a-co> all </pre>
<h2>Cross-compiling</h2>
<p>If you want to cross-compile SWS then consider using <a href="https://github.com/ziglang/zig">Zig</a> as <a href="https://andrewkelley.me/post/zig-cc-powerful-drop-in-replacement-gcc-clang.html">linker</a> for <a href="https://actually.fyi/posts/zig-makes-rust-cross-compilation-just-work/">easier cross compiling</a>.</p>
<p>Let's say, you want to cross-compile SWS from macOS to Linux. Then follow these steps.</p>
<ol>
<li>Add the necessary toolchain, for example just type: <code>rustup target add x86_64-unknown-linux-gnu</code> or <code>rustup target add x86_64-unknown-linux-musl</code> if a statically-linked binary is wanted.</li>
<li>Install the latest <a href="https://github.com/ziglang/zig">Zig</a> version via <code>brew install zig</code></li>
<li>Install <a href="https://github.com/rust-cross/cargo-zigbuild">cargo-zigbuild</a> via <code>cargo install cargo-zigbuild</code></li>
<li>Finally, build SWS as follows:<pre class="language-bash"><a-c># dynamically-linked binary</a-c>
<a-f>cargo</a-f> zigbuild <a-co>--verbose</a-co> <a-co>--release</a-co> <a-co>--target=x86_64-unknown-linux-gnu</a-co>
<a-c># or statically-linked binary</a-c>
<a-f>cargo</a-f> zigbuild <a-co>--verbose</a-co> <a-co>--release</a-co> <a-co>--target=x86_64-unknown-linux-musl</a-co></pre>
</li>
</ol>
<p>Built binaries can be found under the corresponding toolchain directory inside <code>target/</code>.</p>
<h2>Testing</h2>
<pre class="language-bash"><a-c># run tests for default features</a-c>
<a-f>cargo</a-f> test

<a-c># run all tests without default features</a-c>
<a-f>cargo</a-f> test <a-co>--tests</a-co> <a-co>--no-default-features</a-co>

<a-c># or run tests for all features including experimental ones</a-c>
<a-pr>RUSTFLAGS</a-pr>=<a-s>&quot;--cfg tokio_unstable&quot;</a-s> <a-f>cargo</a-f> test <a-co>--features</a-co> all

<a-c># or run specific tests</a-c>
<a-f>cargo</a-f> test <a-co>--test</a-co> rewrites</pre>
<h2>Building documentation from source</h2>
<p>All HTML documentation is located in the <code>docs/</code> project's directory and is built using <a href="https://github.com/squidfunk/mkdocs-material">Material for MkDocs</a>.</p>
<p>It's only necessary to have <a href="https://www.docker.com/get-started/">Docker</a> installed.</p>
<h3>Building documentation</h3>
<p>By default the docs will be built in the <code>/tmp/docs</code> directory, to do so follow these steps.</p>
<pre class="language-bash"><a-f>git</a-f> clone https://github.com/static-web-server/static-web-server.git
<a-f>cd</a-f> static-web-server
<a-f>mkdir</a-f> /tmp/docs
<a-f>docker</a-f> run <a-co>-it</a-co> <a-co>--rm</a-co> \
    <a-co>-v</a-co> <a-o>$</a-o><a-pr>PWD</a-pr>/docs:/docs \
    <a-co>-v</a-co> /tmp/docs:/tmp/docs squidfunk/mkdocs-material build</pre>
<p>!!! tip "Output the docs in a different directory"</p>
<pre><code>If you want to output the docs in a different directory then append the `--site-dir=/new/dir/path/` argument to the *"squidfunk/mkdocs-material"* `build` command and make sure to provide the new directory path.
</code></pre>
<h3>Development server</h3>
<p>If you want to improve the documentation then run the built-in development server via <code>docs/docker-compose.yml</code>.</p>
<pre class="language-bash"><a-f>git</a-f> clone https://github.com/static-web-server/static-web-server.git
<a-f>cd</a-f> static-web-server
<a-f>docker-compose</a-f> <a-co>-f</a-co> docs/docker-compose.yml up</pre>
<p>Now the server will be available at <code>localhost:8000</code></p>
<h2>Formatting Markdown files</h2>
<p>This project makes use of <a href="https://mdformat.readthedocs.io/en/stable/">mdformat</a> to format Markdown files.
The CI job <code>devel-project-docs</code> checks that all Markdown files are formatted correctly.</p>
<p>To format documentation changes, you can run <code>mdformat</code> manually using <a href="https://docs.astral.sh/uv/getting-started/installation/">uv</a>:</p>
<pre class="language-bash"><a-f>uvx</a-f> <a-co>--python</a-co> <a-s>&quot;&gt;=3.13&quot;</a-s> <a-co>--with</a-co> mdformat-mkdocs mdformat ./*.md docs/</pre>
</section><div class="code-panel"><pre class="code src language-markdown"><span class="code-line"><a class="ln" id="L1" href="#L1">1</a><span class="code-text"><a-p>#</a-p> <a-tt>Building from Source</a-tt></span><span class="code-break">
</span></span><span class="code-line"><a class="ln" id="L2" href="#L2">2</a><span class="code-text"></span><span class="code-break">
</span></span><span class="code-line"><a class="ln" id="L3" href="#L3">3</a><span class="code-text">Follow these instructions to either build **`SWS`** project from the source or the HTML documentation.</span><span class="code-break">
</span></span><span class="code-line"><a class="ln" id="L4" href="#L4">4</a><span class="code-text"></span><span class="code-break">
</span></span><span class="code-line"><a class="ln" id="L5" href="#L5">5</a><span class="code-text"><a-p>##</a-p> <a-tt>Building project from source</a-tt></span><span class="code-break">
</span></span><span class="code-line"><a class="ln" id="L6" href="#L6">6</a><span class="code-text"></span><span class="code-break">
</span></span><span class="code-line"><a class="ln" id="L7" href="#L7">7</a><span class="code-text">If you want to build **SWS** from the source, make sure to install Rust [1.88.0](https://blog.rust-lang.org/2025/06/26/Rust-1.88.0/) or newer (or nightly) along with [the toolchain(s)](https://rust-lang.github.io/rustup/concepts/toolchains.html) of your preference.</span><span class="code-break">
</span></span><span class="code-line"><a class="ln" id="L8" href="#L8">8</a><span class="code-text"></span><span class="code-break">
</span></span><span class="code-line"><a class="ln" id="L9" href="#L9">9</a><span class="code-text">Then clone the repository and use [Cargo](https://doc.rust-lang.org/cargo/) to build the project from the source.</span><span class="code-break">
</span></span><span class="code-line"><a class="ln" id="L10" href="#L10">10</a><span class="code-text"></span><span class="code-break">
</span></span><span class="code-line"><a class="ln" id="L11" href="#L11">11</a><span class="code-text"><a-p>```</a-p><a-tl>sh</a-tl></span><span class="code-break">
</span></span><span class="code-line"><a class="ln" id="L12" href="#L12">12</a><span class="code-text"><a-p>git clone https://github.com/static-web-server/static-web-server.git</a-p></span><span class="code-break">
</span></span><span class="code-line"><a class="ln" id="L13" href="#L13">13</a><span class="code-text"><a-p>cd static-web-server</a-p></span><span class="code-break">
</span></span><span class="code-line"><a class="ln" id="L14" href="#L14">14</a><span class="code-text"><a-p>cargo build --release</a-p></span><span class="code-break">
</span></span><span class="code-line"><a class="ln" id="L15" href="#L15">15</a><span class="code-text"><a-p>```</a-p></span><span class="code-break">
</span></span><span class="code-line"><a class="ln" id="L16" href="#L16">16</a><span class="code-text"></span><span class="code-break">
</span></span><span class="code-line"><a class="ln" id="L17" href="#L17">17</a><span class="code-text"><a-p>Finally, the release binary should be available at `target/release/static-web-server` or under your toolchain directory chosen.</a-p></span><span class="code-break">
</span></span><span class="code-line"><a class="ln" id="L18" href="#L18">18</a><span class="code-text"></span><span class="code-break">
</span></span><span class="code-line"><a class="ln" id="L19" href="#L19">19</a><span class="code-text"><a-p>!!! info &quot;Don&#39;t use the project&#39;s `Makefile`&quot;</a-p></span><span class="code-break">
</span></span><span class="code-line"><a class="ln" id="L20" href="#L20">20</a><span class="code-text"></span><span class="code-break">
</span></span><span class="code-line"><a class="ln" id="L21" href="#L21">21</a><span class="code-text"><a-tl>    Please don&#39;t use the project&#39;s `Makefile` since it&#39;s only intended for development and some on-demand tasks.</a-tl></span><span class="code-break">
</span></span><span class="code-line"><a class="ln" id="L22" href="#L22">22</a><span class="code-text"></span><span class="code-break">
</span></span><span class="code-line"><a class="ln" id="L23" href="#L23">23</a><span class="code-text"><a-p>## </a-p><a-tt>Cargo features</a-tt></span><span class="code-break">
</span></span><span class="code-line"><a class="ln" id="L24" href="#L24">24</a><span class="code-text"></span><span class="code-break">
</span></span><span class="code-line"><a class="ln" id="L25" href="#L25">25</a><span class="code-text"><a-p>When building from the source, all features are enabled by default.</a-p></span><span class="code-break">
</span></span><span class="code-line"><a class="ln" id="L26" href="#L26">26</a><span class="code-text"><a-p>However, you can disable just the ones you don&#39;t need from the lists below.</a-p></span><span class="code-break">
</span></span><span class="code-line"><a class="ln" id="L27" href="#L27">27</a><span class="code-text"></span><span class="code-break">
</span></span><span class="code-line"><a class="ln" id="L28" href="#L28">28</a><span class="code-text"><a-p>| Feature | Description |</a-p></span><span class="code-break">
</span></span><span class="code-line"><a class="ln" id="L29" href="#L29">29</a><span class="code-text"><a-p>| -- | -- |</a-p></span><span class="code-break">
</span></span><span class="code-line"><a class="ln" id="L30" href="#L30">30</a><span class="code-text"><a-p>| **Default** |  |</a-p></span><span class="code-break">
</span></span><span class="code-line"><a class="ln" id="L31" href="#L31">31</a><span class="code-text"><a-p>| `default` | Activates the default features by omission. |</a-p></span><span class="code-break">
</span></span><span class="code-line"><a class="ln" id="L32" href="#L32">32</a><span class="code-text"><a-p>| `all` | Activates all available features including the `experimental` feature. This is the default feature used when building SWS binaries. |</a-p></span><span class="code-break">
</span></span><span class="code-line"><a class="ln" id="L33" href="#L33">33</a><span class="code-text"><a-p>| `experimental` | Activates all SWS experimental features. Make sure to also provide the required `RUSTFLAGS` if the feature requires so. |</a-p></span><span class="code-break">
</span></span><span class="code-line"><a class="ln" id="L34" href="#L34">34</a><span class="code-text"><a-p>| [**HTTP2/TLS**](./features/http2-tls.md) |  |</a-p></span><span class="code-break">
</span></span><span class="code-line"><a class="ln" id="L35" href="#L35">35</a><span class="code-text"><a-p>| `http2` | Activates the HTTP2 and TLS feature. |</a-p></span><span class="code-break">
</span></span><span class="code-line"><a class="ln" id="L36" href="#L36">36</a><span class="code-text"><a-p>| [**Compression**](./features/compression.md) |  |</a-p></span><span class="code-break">
</span></span><span class="code-line"><a class="ln" id="L37" href="#L37">37</a><span class="code-text"><a-p>| `compression` | Activates auto-compression with all supported algorithms. |</a-p></span><span class="code-break">
</span></span><span class="code-line"><a class="ln" id="L38" href="#L38">38</a><span class="code-text"><a-p>| `compression-brotli` | Activates auto-compression with only the `brotli` algorithm. |</a-p></span><span class="code-break">
</span></span><span class="code-line"><a class="ln" id="L39" href="#L39">39</a><span class="code-text"><a-p>| `compression-deflate` | Activates auto-compression with only the `deflate` algorithm. |</a-p></span><span class="code-break">
</span></span><span class="code-line"><a class="ln" id="L40" href="#L40">40</a><span class="code-text"><a-p>| `compression-gzip` | Activates auto-compression with only the `gzip` algorithm. |</a-p></span><span class="code-break">
</span></span><span class="code-line"><a class="ln" id="L41" href="#L41">41</a><span class="code-text"><a-p>| `compression-zstd` | Activates auto-compression with only the `zstd` algorithm. |</a-p></span><span class="code-break">
</span></span><span class="code-line"><a class="ln" id="L42" href="#L42">42</a><span class="code-text"><a-p>| [**Directory Listing**](./features/directory-listing.md) |  |</a-p></span><span class="code-break">
</span></span><span class="code-line"><a class="ln" id="L43" href="#L43">43</a><span class="code-text"><a-p>| `directory-listing` | Activates the directory listing feature. |</a-p></span><span class="code-break">
</span></span><span class="code-line"><a class="ln" id="L44" href="#L44">44</a><span class="code-text"><a-p>| [**Basic Authorization**](./features/basic-authentication.md) |  |</a-p></span><span class="code-break">
</span></span><span class="code-line"><a class="ln" id="L45" href="#L45">45</a><span class="code-text"><a-p>| `basic-auth` | Activates the Basic HTTP Authorization Schema feature. |</a-p></span><span class="code-break">
</span></span><span class="code-line"><a class="ln" id="L46" href="#L46">46</a><span class="code-text"><a-p>| [**Fallback Page**](./features/error-pages.md#fallback-page-for-use-with-client-routers) |  |</a-p></span><span class="code-break">
</span></span><span class="code-line"><a class="ln" id="L47" href="#L47">47</a><span class="code-text"><a-p>| `fallback-page` | Activates the Fallback Page feature. |</a-p></span><span class="code-break">
</span></span><span class="code-line"><a class="ln" id="L48" href="#L48">48</a><span class="code-text"></span><span class="code-break">
</span></span><span class="code-line"><a class="ln" id="L49" href="#L49">49</a><span class="code-text"><a-p>### </a-p><a-tt>Disable all default features</a-tt></span><span class="code-break">
</span></span><span class="code-line"><a class="ln" id="L50" href="#L50">50</a><span class="code-text"></span><span class="code-break">
</span></span><span class="code-line"><a class="ln" id="L51" href="#L51">51</a><span class="code-text"><a-p>For example, if you want to run or build SWS without the default features like `compression`, `http2`, etc then just try:</a-p></span><span class="code-break">
</span></span><span class="code-line"><a class="ln" id="L52" href="#L52">52</a><span class="code-text"></span><span class="code-break">
</span></span><span class="code-line"><a class="ln" id="L53" href="#L53">53</a><span class="code-text"><a-p>```</a-p><a-tl>sh</a-tl></span><span class="code-break">
</span></span><span class="code-line"><a class="ln" id="L54" href="#L54">54</a><span class="code-text"><a-p># run</a-p></span><span class="code-break">
</span></span><span class="code-line"><a class="ln" id="L55" href="#L55">55</a><span class="code-text"><a-p>cargo run --no-default-features -- -h</a-p></span><span class="code-break">
</span></span><span class="code-line"><a class="ln" id="L56" href="#L56">56</a><span class="code-text"></span><span class="code-break">
</span></span><span class="code-line"><a class="ln" id="L57" href="#L57">57</a><span class="code-text"><a-p># build</a-p></span><span class="code-break">
</span></span><span class="code-line"><a class="ln" id="L58" href="#L58">58</a><span class="code-text"><a-p>cargo build --release --no-default-features</a-p></span><span class="code-break">
</span></span><span class="code-line"><a class="ln" id="L59" href="#L59">59</a><span class="code-text"></span><span class="code-break">
</span></span><span class="code-line"><a class="ln" id="L60" href="#L60">60</a><span class="code-text"><a-p># or build including all features (example)</a-p></span><span class="code-break">
</span></span><span class="code-line"><a class="ln" id="L61" href="#L61">61</a><span class="code-text"><a-p>RUSTFLAGS=&quot;--cfg tokio_unstable&quot; \</a-p></span><span class="code-break">
</span></span><span class="code-line"><a class="ln" id="L62" href="#L62">62</a><span class="code-text"><a-p>    cargo build -vv --release --features all </a-p></span><span class="code-break">
</span></span><span class="code-line"><a class="ln" id="L63" href="#L63">63</a><span class="code-text"><a-p>```</a-p></span><span class="code-break">
</span></span><span class="code-line"><a class="ln" id="L64" href="#L64">64</a><span class="code-text"></span><span class="code-break">
</span></span><span class="code-line"><a class="ln" id="L65" href="#L65">65</a><span class="code-text"><a-p>## </a-p><a-tt>Cross-compiling</a-tt></span><span class="code-break">
</span></span><span class="code-line"><a class="ln" id="L66" href="#L66">66</a><span class="code-text"></span><span class="code-break">
</span></span><span class="code-line"><a class="ln" id="L67" href="#L67">67</a><span class="code-text"><a-p>If you want to cross-compile SWS then consider using [Zig](https://github.com/ziglang/zig) as [linker](https://andrewkelley.me/post/zig-cc-powerful-drop-in-replacement-gcc-clang.html) for [easier cross compiling](https://actually.fyi/posts/zig-makes-rust-cross-compilation-just-work/).</a-p></span><span class="code-break">
</span></span><span class="code-line"><a class="ln" id="L68" href="#L68">68</a><span class="code-text"></span><span class="code-break">
</span></span><span class="code-line"><a class="ln" id="L69" href="#L69">69</a><span class="code-text"><a-p>Let&#39;s say, you want to cross-compile SWS from macOS to Linux. Then follow these steps.</a-p></span><span class="code-break">
</span></span><span class="code-line"><a class="ln" id="L70" href="#L70">70</a><span class="code-text"></span><span class="code-break">
</span></span><span class="code-line"><a class="ln" id="L71" href="#L71">71</a><span class="code-text"><a-p>1. Add the necessary toolchain, for example just type: `rustup target add x86_64-unknown-linux-gnu` or `rustup target add x86_64-unknown-linux-musl` if a statically-linked binary is wanted.</a-p></span><span class="code-break">
</span></span><span class="code-line"><a class="ln" id="L72" href="#L72">72</a><span class="code-text"><a-p>2. Install the latest [Zig](https://github.com/ziglang/zig) version via `brew install zig`</a-p></span><span class="code-break">
</span></span><span class="code-line"><a class="ln" id="L73" href="#L73">73</a><span class="code-text"><a-p>3. Install [cargo-zigbuild](https://github.com/rust-cross/cargo-zigbuild) via `cargo install cargo-zigbuild`</a-p></span><span class="code-break">
</span></span><span class="code-line"><a class="ln" id="L74" href="#L74">74</a><span class="code-text"><a-p>4. Finally, build SWS as follows:</a-p></span><span class="code-break">
</span></span><span class="code-line"><a class="ln" id="L75" href="#L75">75</a><span class="code-text"><a-p>   </a-p><a-tl> ```sh</a-tl></span><span class="code-break">
</span></span><span class="code-line"><a class="ln" id="L76" href="#L76">76</a><span class="code-text"><a-p>   </a-p><a-tl> # dynamically-linked binary</a-tl></span><span class="code-break">
</span></span><span class="code-line"><a class="ln" id="L77" href="#L77">77</a><span class="code-text"><a-p>   </a-p><a-tl> cargo zigbuild --verbose --release --target=x86_64-unknown-linux-gnu</a-tl></span><span class="code-break">
</span></span><span class="code-line"><a class="ln" id="L78" href="#L78">78</a><span class="code-text"><a-p>   </a-p><a-tl> # or statically-linked binary</a-tl></span><span class="code-break">
</span></span><span class="code-line"><a class="ln" id="L79" href="#L79">79</a><span class="code-text"><a-p>   </a-p><a-tl> cargo zigbuild --verbose --release --target=x86_64-unknown-linux-musl</a-tl></span><span class="code-break">
</span></span><span class="code-line"><a class="ln" id="L80" href="#L80">80</a><span class="code-text"><a-p>    ```</a-p></span><span class="code-break">
</span></span><span class="code-line"><a class="ln" id="L81" href="#L81">81</a><span class="code-text"></span><span class="code-break">
</span></span><span class="code-line"><a class="ln" id="L82" href="#L82">82</a><span class="code-text"><a-p>Built binaries can be found under the corresponding toolchain directory inside `target/`.</a-p></span><span class="code-break">
</span></span><span class="code-line"><a class="ln" id="L83" href="#L83">83</a><span class="code-text"></span><span class="code-break">
</span></span><span class="code-line"><a class="ln" id="L84" href="#L84">84</a><span class="code-text"><a-p>## </a-p><a-tt>Testing</a-tt></span><span class="code-break">
</span></span><span class="code-line"><a class="ln" id="L85" href="#L85">85</a><span class="code-text"></span><span class="code-break">
</span></span><span class="code-line"><a class="ln" id="L86" href="#L86">86</a><span class="code-text"><a-p>```</a-p><a-tl>sh</a-tl></span><span class="code-break">
</span></span><span class="code-line"><a class="ln" id="L87" href="#L87">87</a><span class="code-text"><a-p># run tests for default features</a-p></span><span class="code-break">
</span></span><span class="code-line"><a class="ln" id="L88" href="#L88">88</a><span class="code-text"><a-p>cargo test</a-p></span><span class="code-break">
</span></span><span class="code-line"><a class="ln" id="L89" href="#L89">89</a><span class="code-text"></span><span class="code-break">
</span></span><span class="code-line"><a class="ln" id="L90" href="#L90">90</a><span class="code-text"><a-p># run all tests without default features</a-p></span><span class="code-break">
</span></span><span class="code-line"><a class="ln" id="L91" href="#L91">91</a><span class="code-text"><a-p>cargo test --tests --no-default-features</a-p></span><span class="code-break">
</span></span><span class="code-line"><a class="ln" id="L92" href="#L92">92</a><span class="code-text"></span><span class="code-break">
</span></span><span class="code-line"><a class="ln" id="L93" href="#L93">93</a><span class="code-text"><a-p># or run tests for all features including experimental ones</a-p></span><span class="code-break">
</span></span><span class="code-line"><a class="ln" id="L94" href="#L94">94</a><span class="code-text"><a-p>RUSTFLAGS=&quot;--cfg tokio_unstable&quot; cargo test --features all</a-p></span><span class="code-break">
</span></span><span class="code-line"><a class="ln" id="L95" href="#L95">95</a><span class="code-text"></span><span class="code-break">
</span></span><span class="code-line"><a class="ln" id="L96" href="#L96">96</a><span class="code-text"><a-p># or run specific tests</a-p></span><span class="code-break">
</span></span><span class="code-line"><a class="ln" id="L97" href="#L97">97</a><span class="code-text"><a-p>cargo test --test rewrites</a-p></span><span class="code-break">
</span></span><span class="code-line"><a class="ln" id="L98" href="#L98">98</a><span class="code-text"><a-p>```</a-p></span><span class="code-break">
</span></span><span class="code-line"><a class="ln" id="L99" href="#L99">99</a><span class="code-text"></span><span class="code-break">
</span></span><span class="code-line"><a class="ln" id="L100" href="#L100">100</a><span class="code-text"><a-p>## </a-p><a-tt>Building documentation from source</a-tt></span><span class="code-break">
</span></span><span class="code-line"><a class="ln" id="L101" href="#L101">101</a><span class="code-text"></span><span class="code-break">
</span></span><span class="code-line"><a class="ln" id="L102" href="#L102">102</a><span class="code-text"><a-p>All HTML documentation is located in the `docs/` project&#39;s directory and is built using [Material for MkDocs](https://github.com/squidfunk/mkdocs-material).</a-p></span><span class="code-break">
</span></span><span class="code-line"><a class="ln" id="L103" href="#L103">103</a><span class="code-text"></span><span class="code-break">
</span></span><span class="code-line"><a class="ln" id="L104" href="#L104">104</a><span class="code-text"><a-p>It&#39;s only necessary to have [Docker](https://www.docker.com/get-started/) installed.</a-p></span><span class="code-break">
</span></span><span class="code-line"><a class="ln" id="L105" href="#L105">105</a><span class="code-text"></span><span class="code-break">
</span></span><span class="code-line"><a class="ln" id="L106" href="#L106">106</a><span class="code-text"><a-p>### </a-p><a-tt>Building documentation</a-tt></span><span class="code-break">
</span></span><span class="code-line"><a class="ln" id="L107" href="#L107">107</a><span class="code-text"></span><span class="code-break">
</span></span><span class="code-line"><a class="ln" id="L108" href="#L108">108</a><span class="code-text"><a-p>By default the docs will be built in the `/tmp/docs` directory, to do so follow these steps.</a-p></span><span class="code-break">
</span></span><span class="code-line"><a class="ln" id="L109" href="#L109">109</a><span class="code-text"></span><span class="code-break">
</span></span><span class="code-line"><a class="ln" id="L110" href="#L110">110</a><span class="code-text"><a-p>```</a-p><a-tl>sh</a-tl></span><span class="code-break">
</span></span><span class="code-line"><a class="ln" id="L111" href="#L111">111</a><span class="code-text"><a-p>git clone https://github.com/static-web-server/static-web-server.git</a-p></span><span class="code-break">
</span></span><span class="code-line"><a class="ln" id="L112" href="#L112">112</a><span class="code-text"><a-p>cd static-web-server</a-p></span><span class="code-break">
</span></span><span class="code-line"><a class="ln" id="L113" href="#L113">113</a><span class="code-text"><a-p>mkdir /tmp/docs</a-p></span><span class="code-break">
</span></span><span class="code-line"><a class="ln" id="L114" href="#L114">114</a><span class="code-text"><a-p>docker run -it --rm \</a-p></span><span class="code-break">
</span></span><span class="code-line"><a class="ln" id="L115" href="#L115">115</a><span class="code-text"><a-p>    -v $PWD/docs:/docs \</a-p></span><span class="code-break">
</span></span><span class="code-line"><a class="ln" id="L116" href="#L116">116</a><span class="code-text"><a-p>    -v /tmp/docs:/tmp/docs squidfunk/mkdocs-material build</a-p></span><span class="code-break">
</span></span><span class="code-line"><a class="ln" id="L117" href="#L117">117</a><span class="code-text"><a-p>```</a-p></span><span class="code-break">
</span></span><span class="code-line"><a class="ln" id="L118" href="#L118">118</a><span class="code-text"></span><span class="code-break">
</span></span><span class="code-line"><a class="ln" id="L119" href="#L119">119</a><span class="code-text"><a-p>!!! tip &quot;Output the docs in a different directory&quot;</a-p></span><span class="code-break">
</span></span><span class="code-line"><a class="ln" id="L120" href="#L120">120</a><span class="code-text"></span><span class="code-break">
</span></span><span class="code-line"><a class="ln" id="L121" href="#L121">121</a><span class="code-text"><a-tl>    If you want to output the docs in a different directory then append the `--site-dir=/new/dir/path/` argument to the *&quot;squidfunk/mkdocs-material&quot;* `build` command and make sure to provide the new directory path.</a-tl></span><span class="code-break">
</span></span><span class="code-line"><a class="ln" id="L122" href="#L122">122</a><span class="code-text"></span><span class="code-break">
</span></span><span class="code-line"><a class="ln" id="L123" href="#L123">123</a><span class="code-text"><a-p>### </a-p><a-tt>Development server</a-tt></span><span class="code-break">
</span></span><span class="code-line"><a class="ln" id="L124" href="#L124">124</a><span class="code-text"></span><span class="code-break">
</span></span><span class="code-line"><a class="ln" id="L125" href="#L125">125</a><span class="code-text"><a-p>If you want to improve the documentation then run the built-in development server via `docs/docker-compose.yml`.</a-p></span><span class="code-break">
</span></span><span class="code-line"><a class="ln" id="L126" href="#L126">126</a><span class="code-text"></span><span class="code-break">
</span></span><span class="code-line"><a class="ln" id="L127" href="#L127">127</a><span class="code-text"><a-p>```</a-p><a-tl>sh</a-tl></span><span class="code-break">
</span></span><span class="code-line"><a class="ln" id="L128" href="#L128">128</a><span class="code-text"><a-p>git clone https://github.com/static-web-server/static-web-server.git</a-p></span><span class="code-break">
</span></span><span class="code-line"><a class="ln" id="L129" href="#L129">129</a><span class="code-text"><a-p>cd static-web-server</a-p></span><span class="code-break">
</span></span><span class="code-line"><a class="ln" id="L130" href="#L130">130</a><span class="code-text"><a-p>docker-compose -f docs/docker-compose.yml up</a-p></span><span class="code-break">
</span></span><span class="code-line"><a class="ln" id="L131" href="#L131">131</a><span class="code-text"><a-p>```</a-p></span><span class="code-break">
</span></span><span class="code-line"><a class="ln" id="L132" href="#L132">132</a><span class="code-text"></span><span class="code-break">
</span></span><span class="code-line"><a class="ln" id="L133" href="#L133">133</a><span class="code-text"><a-p>Now the server will be available at `localhost:8000`</a-p></span><span class="code-break">
</span></span><span class="code-line"><a class="ln" id="L134" href="#L134">134</a><span class="code-text"></span><span class="code-break">
</span></span><span class="code-line"><a class="ln" id="L135" href="#L135">135</a><span class="code-text"><a-p>## </a-p><a-tt>Formatting Markdown files</a-tt></span><span class="code-break">
</span></span><span class="code-line"><a class="ln" id="L136" href="#L136">136</a><span class="code-text"></span><span class="code-break">
</span></span><span class="code-line"><a class="ln" id="L137" href="#L137">137</a><span class="code-text"><a-p>This project makes use of [mdformat](https://mdformat.readthedocs.io/en/stable/) to format Markdown files.</a-p></span><span class="code-break">
</span></span><span class="code-line"><a class="ln" id="L138" href="#L138">138</a><span class="code-text"><a-p>The CI job `devel-project-docs` checks that all Markdown files are formatted correctly.</a-p></span><span class="code-break">
</span></span><span class="code-line"><a class="ln" id="L139" href="#L139">139</a><span class="code-text"></span><span class="code-break">
</span></span><span class="code-line"><a class="ln" id="L140" href="#L140">140</a><span class="code-text"><a-p>To format documentation changes, you can run `mdformat` manually using [uv](https://docs.astral.sh/uv/getting-started/installation/):</a-p></span><span class="code-break">
</span></span><span class="code-line"><a class="ln" id="L141" href="#L141">141</a><span class="code-text"></span><span class="code-break">
</span></span><span class="code-line"><a class="ln" id="L142" href="#L142">142</a><span class="code-text"><a-p>```</a-p><a-tl>sh</a-tl></span><span class="code-break">
</span></span><span class="code-line"><a class="ln" id="L143" href="#L143">143</a><span class="code-text"><a-p>uvx --python &quot;&gt;=3.13&quot; --with mdformat-mkdocs mdformat ./*.md docs/</a-p></span><span class="code-break">
</span></span><span class="code-line"><a class="ln" id="L144" href="#L144">144</a><span class="code-text"><a-p>```</a-p></span></span></pre></div></div>
</main>
</body>
</html>
