Command-line tools
This topic is not available in the selected language or version. Showing the start of this section.
Commands assume xen is on PATH. From a distribution directory, substitute ./bin/xen; from the repository, use compiler/dist/xen.
| Command | Purpose |
|---|---|
xen version or xen --version | Show the installed version |
xen check file.xen | Find errors before execution |
xen run file.xen | Run immediately |
xen build file.xen -o app | Make a standalone executable |
xen test [file.xen or directory or std.module] | Run tests |
Successful check and build commands produce no output. Without -o, build writes a.out in the working directory. An existing output file is overwritten. run uses the current working directory and standard input/output, removing its temporary executable when the program exits.
Program arguments
Section titled “Program arguments”xen run word_count.xen -- input.txtxen build word_count.xen -o word-count./word-count input.txtBefore -- are Xen options; after it are your program’s arguments. Read them with std.env.args() or arg_count() and arg(index). The first argument has index 0; the executable name is excluded. An invalid arg index is a runtime error.
Choose the execution environment
Section titled “Choose the execution environment”The default target is your installed Xen compiler’s Linux architecture. check, build, run, and test accept --target=x86_64-linux and --target=aarch64-linux. arm64-linux is an alias for the latter.
xen build hello.xen --target=aarch64-linux -o hello-arm64Run the output on a compatible Linux machine. Selecting another CPU does not automatically make it executable on the current machine. AArch64 support is experimental and validation on physical devices is ongoing. macOS and Windows are unsupported.
Select tests
Section titled “Select tests”xen test searches the current directory. Narrow names with --filter text. See testing.
Optional build options
Section titled “Optional build options”Normal programs can use the defaults. For blocks you explicitly mark as #scope[opt] { ... }, build, run, and test use --opt=basic by default. Disable it with --opt=off. Unmarked code is unaffected.
--opt-report prints application information to stderr. --opt-cache=directory stores a build cache in that directory. Both require basic and are unavailable for check. These options are optional when learning and using the language.
Exit status and help
Section titled “Exit status and help”| Status | Meaning |
|---|---|
0 | Success |
1 | Code, runtime, or test error, or no matching tests |
2 | Invalid command usage |
run propagates the program’s exit status. Panics and ordinary runtime errors usually exit 1. There is no separate --help option. Running xen without arguments prints usage to stderr and exits 2.