Keyboard shortcuts

Press ← or → to navigate between chapters

Press S or / to search in the book

Press ? to show this help

Press Esc to hide this help

Building from source

How to build and test from a checkout. For your own binaries and packages see Custom builds; for running a server, Deploying a server.

Requirements

  • Rust (stable), a C toolchain (libsodium is built from source), git with submodules (git clone --recurse-submodules, or git submodule update --init)
  • Node.js 20 and npm, only to build the web console and the API documentation

Build and test

# the sqlx macros check queries against a database at compile time
export DATABASE_URL=sqlite://$(pwd)/db_v2.sqlite3

cargo build --workspace --locked
cargo test  --workspace --exclude oauth2 --locked -- --skip test_nat64

cargo build also builds web/console and web/rapidoc with npm and embeds the result into the API server. To build without Node.js, set SCTGDESK_SKIP_WEB_BUILD=1: the console and API docs are then placeholders.

A smaller binary

hbbs is about 33 MB for a MIPS router, and a router has little flash. What makes it smaller:

  • The web console and the JavaScript of the API documentation are embedded compressed (gzip, done by crates/api-server/build.rs): the server sends them as they are to the browsers that accept gzip and decompresses for the others. The 5 MB source map of the API documentation is not embedded.
  • The Cargo feature s3 (on by default) brings the AWS SDK, which signs the download links of the clients and weighs about 2 MB of code. cargo build --no-default-features leaves it out: the S3 settings can still be edited and validated, but the download links answer that S3 is not built in.
  • packaging/openwrt/build-mips.sh also compiles for size (opt-level = "z", no debug formatting text, no file and line of the panics): see the comments of the script. The log lines of such a build show <redacted>:0 instead of the place in the source.

Layout

PathContent
src/, libs/hbb_commonthe RustDesk server (upstream code, kept close to upstream)
crates/api-serverREST API server, embedded in hbbs
crates/api-{state,utils,oauth2,s3software}libraries of the API server
web/console, web/rapidocVue web console, API documentation

See docs/adr/ for the reasoning behind this layout.

Known gaps

  • The unit tests of crates/api-oauth2 do not compile; hbb_common’s test_nat64 needs network access.
  • s3software’s test that calls a live S3 bucket is ignored; run it explicitly with --ignored.
  • cargo audit reports known advisories; the CI job is informational until they are triaged.