16. Several programs per app, app-local crates#
An app folder builds one GUI program from src/main.rs. apps/NAME/BINS adds further
programs, one line each -- name, entry file, cli (console program without a style) or gui:
bc-server server/main.rs cli
bc-agent agent/main.rs cli
bcctl ctl/main.rs cli
They are built with the app (build/<target>/bc-server[.exe]), started with
python build_rs.py run BackupCraft --bin bc-server -- --data D, and packaged next to the GUI
program (tools/package.py). Code that several programs share goes into app-local crates,
apps/NAME/crates/<crate>/lib.rs: they are built, linted (#![no_std],
#![forbid(unsafe_code)]) and linked like the library crates, and their dependencies are the
crates their sources name.
Every program of the app gets the app's name for its folders (config:// ...), its assets
(app://) and its manifest (apps/NAME/PERMISSIONS; a program may have its own
apps/NAME/PERMISSIONS.<bin>, docs/PERMISSIONS.md "Every program of the app").
Console programs use rt::main!(run()) instead of ui::run (it installs the manifest before
run), write with plat::write_stdout / write_stderr and read arguments with
plat::args() / plat::arg_value. For background
services, plat::service::run_service(name, run) runs under the Windows service control
manager (and as a plain process elsewhere), install / start / stop / uninstall / state
manage the Windows service or the systemd unit, and stop_requested() tells the program to
finish.