index : static-web-server.git

ascending towards madness

author Jose Quintana <joseluisquintana20@gmail.com> 2023-06-11 21:24:28.0 +00:00:00
committer Jose Quintana <joseluisquintana20@gmail.com> 2023-06-13 22:35:08.0 +00:00:00
commit
379f88b05f019a38b1d2a73ae9b1d677028d48de [patch]
tree
34ef3b71c916f6e3118d5c3d97707448a6b9e711
parent
911a1c2d9ff4013daf6ca7261de6fc26e541c7c4
download
379f88b05f019a38b1d2a73ae9b1d677028d48de.tar.gz

docs: cross-compiling sws from source [skip ci]

https://static-web-server.net/building-from-source/#cross-compiling

Diff

 docs/content/building-from-source.md | 19 +++++++++++++++++++
 1 file changed, 19 insertions(+)

diff --git a/docs/content/building-from-source.md b/docs/content/building-from-source.md
index 2556819..4d58cd1 100644
--- a/docs/content/building-from-source.md
+++ b/docs/content/building-from-source.md
@@ -50,6 +50,25 @@ cargo run --no-default-features -- -h
cargo build --release --no-default-features
```

## Cross-compiling

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/.

Let's say, you want to cross-compile SWS from macOS to Linux. Then follow these steps.

1. Add the necessary toolchain, for example: `rustup target add x86_64-unknown-linux-gnu` or using `rustup target add x86_64-unknown-linux-musl` if a statically-linked binary is wanted.
2. Install the latest [Zig]https://github.com/ziglang/zig version via `brew install zig`
3. Install [cargo-zigbuild]https://github.com/rust-cross/cargo-zigbuild via `cargo install cargo-zigbuild`
4. Finally, just build SWS as follows:
    ```sh
    # dynamically-linked binary
    cargo zigbuild --verbose --release --target=x86_64-unknown-linux-gnu
    # or statically-linked binary
    cargo zigbuild --verbose --release --target=x86_64-unknown-linux-musl
    ```

Built binaries can be found under the corresponding toolchain directory inside `target/`.

## Building documentation from source

All HTML documentation is located in the `docs/` project's directory and is built using [Material for MkDocs]https://github.com/squidfunk/mkdocs-material.