Targets
A target is an object that defines a build.
type Target = { // The command line arguments to pass to the executable. args: Array<tg.Template>; // A checksum to verify the target'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 target's runtime. host: string;};
A target is created with the tg.target function.
export default tg.target(() => { return "Hello, world!";});
Passing a closure to tg.target() creates a target whose runtime is js. This is currently only supported in export statements.
In order to create targets with a different runtime, you will rarely use tg.target() because the environment will be empty. Instead, you can use the $ tagged template function from std to create a target 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 build. There are currently runtimes for builds whose targets 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-bfp to isolate builds.