Build Applications

Application Loop

Find the commands to check, test, run, and rebuild the study planner after a change.

Use this command sequence when you change the study planner from First Application. Check the source, run its test, and rebuild the executable you will deliver.

Run commands from the folder containing topaz.toml. It is named study-plan, or source-unavailable if you completed the rename exercise. You need topaz for source commands and your platform's Rust toolchain for a native build.

Check the project settings

The tutorial creates this topaz.toml along with src/main.tpz, src/plan.tpz, and tests/plan.tpz. Use its complete source files if you are starting a new project.

TOML
[package]
name = "study-plan"
version = "0.1.0"
language = "5.20"
entry = "src/main.tpz"

[build]
target = "native"
deterministic = true

[dependencies]
std = "5.20"

entry selects src/main.tpz. target = "native" selects an executable. After creating or changing the manifest, update the lock file.

BASH
topaz lock --root .

This writes topaz.lock. Keep the existing lock file when changing source code without changing the manifest or dependencies.

Check and test a change

BASH
topaz fmt --check --root .
topaz check --root . --locked
topaz test tests/plan.tpz --root . --locked

fmt --check reports formatting differences without editing files. check checks types and names in the entry file and its imports. Both return a successful exit status when their checks pass. The selected test prints the following line.

Output
tests/plan.tpz: test-ok

If a command fails, fix the problem before continuing. Use topaz fmt --root . to correct formatting. For type or name errors, edit the reported line. For a failed assertion, compare tests/plan.tpz with the function in src/plan.tpz. If the lock file is out of date, run the lock command above again.

Run the application

BASH
topaz run --root . --locked

With the original tutorial inputs, the output is as follows.

Output
tasks=2, remaining=25 minutes

If you changed the second task to 30 minutes, expect remaining=30 minutes. The test uses its own 25-minute input and still passes.

Rebuild and deliver

BASH
topaz build --release --root . --locked --out-dir ../study-plan-product

The build writes the following product folder next to your source folder.

study-plan-product/
├── GENERATED-OUTPUT-NOTICE.txt
├── LICENSE
├── NOTICE
├── target
│   └── release
│       └── program[.exe]
└── topaz-artifact.json

Copy the whole product folder to the deployment machine for the operating system and architecture you built for. From that folder, run ./target/release/program on Unix or .\target\release\program.exe in PowerShell. The original inputs print tasks=2, remaining=25 minutes, as above. The executable runs without Topaz or Rust.

If your application declares [capabilities.fs], also copy its data/ and prepare its writable output folders. Use the product folder as the working directory. The build does not copy application data automatically.

If Rust is missing, install the toolchain for your platform. If the output folder contains another target or modified generated files, preserve it and choose a new empty output folder.