# Variant configuration

Similar to conda-forge, emscripten-forge keeps a global pin / variant file: [`variant.yaml`](https://github.com/emscripten-forge/recipes/blob/emscripten-6x/variant.yaml).
It is passed to `rattler-build` with `-m variant.yaml` and follows the [rattler-build variant configuration](https://rattler-build.prefix.dev/latest/variants/) format.

The file serves two primary purposes:

1. Globally pin package versions used across recipes.
2. Select compilers and related toolchain settings per platform.

## Global pins

Package pins are specified as:

```yaml
# ...
numpy:
- '2.5'
openblas:
- 0.3.*
openssl:
- 3.5
zlib:
- 1.3
zlib-static:
- 1.3
# ...
```

When a recipe depends on a package without a version constraint, rattler-build applies the pin from `variant.yaml`.

Therefore, recipes should omit the version constraint and rely on the global pin instead of writing

```yaml
requirements:
  host:
  - zlib 1.3
  run:
  - zlib 1.3
```

Prefer:

```yaml
requirements:
  host:
  - zlib
  run:
  - zlib
```

When both shared and static flavours exist, keep their pins in sync (for example `zlib` / `zlib-static`).

conda-forge's pinning lives in [`conda-forge-pinning`](https://github.com/conda-forge/conda-forge-pinning-feedstock/blob/main/recipe/conda_build_config.yaml). Emscripten-forge maintains its own `variant.yaml` to include emscripten-specific toolchain entries.

## Variants

When a key lists more than one value, rattler-build builds one package variant for each entry. For example, R packages are built against multiple `r_base` versions:

```yaml
r_base:
- 4.5.3
- 4.6.1
```

A recipe that depends on `r_base` without a hard-coded version then expands into two builds:

```yaml
requirements:
  build:
  - cross-r-base ==${{ r_base }}
  host:
  - r-base ==${{ r_base }}
```

Other multi-value keys in `variant.yaml` follow the same pattern, such as `wasm_jspi` for optional JSPI builds.

## Compilers

The `variant.yaml` file sets the emscripten and flang compiler versions used by recipes:

```yaml
c_compiler_version:
- if: emscripten
  then:
  - 6.0.8

cxx_compiler_version:
- if: emscripten
  then:
  - 6.0.8

fortran_compiler_version:
- if: emscripten
  then:
  - 23.1
```

See the full entries in [`variant.yaml`](https://github.com/emscripten-forge/recipes/blob/emscripten-6x/variant.yaml).
