Commands
A command is an object that defines a process. This is just like in your operating system, where you define a command, then spawn it to produce a process.
type Command = { // The command line arguments to pass to the executable. args: Array<tg.Template>; // A checksum to verify the command's output. If provided, the runtime will allow the build to directly access the network. checksum: tg.Checksum | undefined; // The environment variables to set for the executable. env: Array<tg.Template>; // The executable to run. executable: tg.Artifact | undefined; // A triple that identifies the command's runtime. host: string;};
A command is created with the tg.command function.
export default tg.command(() => { return "Hello, world!";});
Passing a closure to tg.command() creates a command whose runtime is js. This is currently only supported in export statements.
In order to create commands with a different runtime, you will rarely use tg.command() because the environment will be empty. Instead, you can use the $ tagged template function from std to create a command with a shell and some common utilities, and then build it and await its output.
import { $ } from "std";let output = await $`${sdk}/bin/gcc -o $OUTPUT ${main}`;
Triples
A triple is a string that identifies a machine. It specifies the machine's architecture, and optionally includes its vendor, operating system, and additional details about the environment.
Runtimes
A runtime is an internal component of Tangram that runs a process. There are currently runtimes for processes whose hosts are the following triples:
- aarch64-darwin
- aarch64-linux
- js
- x86_64-darwin
- x86_64-linux
The Linux runtimes use features of the Linux kernel features including namespaces, chroot, cgroups, and seccomp-bpf to isolate runs.