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),
gitwith submodules (git clone --recurse-submodules, orgit 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-featuresleaves 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.shalso 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>:0instead of the place in the source.
Layout
| Path | Content |
|---|---|
src/, libs/hbb_common | the RustDesk server (upstream code, kept close to upstream) |
crates/api-server | REST API server, embedded in hbbs |
crates/api-{state,utils,oauth2,s3software} | libraries of the API server |
web/console, web/rapidoc | Vue web console, API documentation |
See docs/adr/ for the reasoning behind this layout.
Known gaps
- The unit tests of
crates/api-oauth2do not compile;hbb_common’stest_nat64needs network access. s3software’s test that calls a live S3 bucket is ignored; run it explicitly with--ignored.cargo auditreports known advisories; the CI job is informational until they are triaged.