|
| 1 | +import { Callout } from "nextra-theme-docs"; |
| 2 | + |
1 | 3 | # Targets
|
| 4 | + |
| 5 | +Scarb packages consist of _targets_ which correspond to source files which can be compiled into a package, and the way how this package is compiled. |
| 6 | +Packages can have a built-in library target, and/or more externally defined targets. |
| 7 | +The list of targets can be configured in `Scarb.toml`. |
| 8 | +By default, if the manifest does not list any targets, Scarb will assume the library target with its default parameters. |
| 9 | + |
| 10 | +## Library |
| 11 | + |
| 12 | +The library target defines a "library" that can be used by other packages. |
| 13 | +In other words, if a package does not provide a library target, it cannot be used as a dependency. |
| 14 | +If not specified, the name of the library defaults to the name of the package. |
| 15 | +A package can have only one library target. |
| 16 | + |
| 17 | +### Sierra and CASM code generation |
| 18 | + |
| 19 | +The library target accepts following configuration parameters, with default values for the default _release_ profile: |
| 20 | + |
| 21 | +```toml |
| 22 | +[lib] |
| 23 | +sierra = true # Enable Sierra codegen. |
| 24 | +casm = false # Enable CASM codegen. |
| 25 | +``` |
| 26 | + |
| 27 | +By default, the library target builds unprocessed Sierra code in textual form for the package. |
| 28 | +When the `casm` option is enabled, Scarb can also automatically compile this Sierra code down to CASM. |
| 29 | + |
| 30 | +## External targets |
| 31 | + |
| 32 | +Scarb supports registering targets that are handled by Scarb extensions. |
| 33 | +Such targets are called _external_ and are defined in a `[[target.*]]{:toml}` array of tables. |
| 34 | + |
| 35 | +<Callout type="info"> |
| 36 | + This is not fully implemented, and we track this work in [#111](https://github.com/software-mansion/scarb/issues/111). |
| 37 | + As for now, Scarb only supports internally hardcoded targets: |
| 38 | + |
| 39 | + - [`starknet-contract`](../starknet/contract-target) |
| 40 | +</Callout> |
| 41 | + |
| 42 | +If multiple targets of the same kind are defined in the package, they all must specify unique [names](#name). |
| 43 | + |
| 44 | +## Configuring a target |
| 45 | + |
| 46 | +All of the `[lib]{:toml}` and `[[target.*]]{:toml}` sections in `Scarb.toml` support configuration options that are not target-specific and control how Scarb manages these targets. |
| 47 | +The following is an overview of the TOML settings for each target, with each field described in detail below. |
| 48 | + |
| 49 | +```toml |
| 50 | +[lib] |
| 51 | +name = "foo" # The name of the target. |
| 52 | +``` |
| 53 | + |
| 54 | +<Callout type="warning"> |
| 55 | + Scarb reserves itself a right to introduce new global configuration fields in future versions. |
| 56 | + Potentially, new parameters may end up being conflicting with ones accepted by external targets. |
| 57 | + Introducing new parameters will always be done in major Scarb version bump, and will be loudly communicated earlier. |
| 58 | +</Callout> |
| 59 | + |
| 60 | +### `name` |
| 61 | + |
| 62 | +The `name` field specifies the name of the target, which corresponds to the filename of the artifact that will be generated. |
| 63 | +If missing, this defaults to the name of the package. |
| 64 | +If multiple targets of the same kind are defined in the package, they all must specify unique names. |
0 commit comments