Skip to main content

Module web

Module web 

Source
Expand description

web [--release] [--<feature>...]: builds the game’s binary (crate::project::Web) for wasm32-unknown-unknown and packages it with the web shell into the project’s web.dist folder: the page (web/index.html, with the game’s title and binary written in), the vendored JS loaders (web/mq_js_bundle.js, and web/sapp_jsutils.js with web/quad-storage.js for localStorage) and the engine’s own plugins (web/gamepad.js for controllers, web/page-files.js for the files the page hands the game, and the rest). The shell is built into this tool; see web/README.md, which also says how a game’s binary gets the link argument these plugins need. Each --<feature> turns on a feature of the game’s package that web.features lists (a debug build’s tools, say). The game’s music tracks (.ogg in web.music, not embedded) are copied beside the page into a folder of the same name, which exists even when there are none; its voice clips (web.voice, .ogg and .ron) are copied the same way when there is such a folder.

Every build also writes NOTICES.txt beside the page (notices): the crates compiled in, the shell’s files (SHELL_NOTICES) and the game’s own license texts.

A build is made whole in a staging folder beside web.dist, then replaces everything in web.dist, so nothing of an older build stays and a failed build leaves the last one as it was. The folder itself stays, so a server running in it keeps serving. A web.dist that holds the project, a source of the build or a repository is refused.

Structs§

Options
Parsed web arguments.

Functions§

copy_tree
Copies the files under src that keep accepts to the same places under dst (made if missing), folders included. Returns how many files were copied.
parse_args
Parses the arguments after web: --release and a --<feature> for each feature rules list, each at most once, in any order. The error is the usage line.
run
Builds and packages the web build, returning a one-line summary on success. game is what the project adds to NOTICES.txt (its own license texts, notices::game_texts); the crates compiled in and the shell’s files are found here. A crate with no license text found is named in a warning.
shell_works
The shell’s files as works of NOTICES.txt, in the shell’s order.
target_dir
The folder cargo builds the project at root into: CARGO_TARGET_DIR when it is set (from root, if relative), else target beside the workspace’s manifest, since a project may be one folder of a bigger workspace (cargo locate-project --workspace), else root/target.
usage
The usage line, with command as the tool’s name.
workspace_root
The root of the workspace the project at root builds in: the folder of cargo locate-project --workspace’s manifest, else root.