{
  "$schema": "https://json-schema.org/draft/2020-12/schema",
  "$id": "https://catalog.lintel.tools/schemas/schemastore/spack-toolchains-yaml/latest.json",
  "title": "Spack toolchain configuration file schema",
  "x-lintel": {
    "source": "https://raw.githubusercontent.com/spack/schemas/refs/heads/main/schemas/toolchains.json",
    "sourceSha256": "a250bcfefae67fb596208ad8b85e79990b8403dd0d6b82681c57ebf946ce167e",
    "fileMatch": [
      "**/*spack/**/toolchains.yaml"
    ],
    "parsers": [
      "yaml"
    ]
  },
  "type": "object",
  "properties": {
    "toolchains": {
      "type": "object",
      "default": {},
      "description": "Define named compiler sets (toolchains) that group compiler constraints under a single user-defined name for easy reference with specs like %my_toolchain",
      "additionalProperties": {
        "description": "Named toolchain definition that can be referenced in specs to apply a complex set of compiler choices for C, C++, and Fortran",
        "oneOf": [
          {
            "type": "string",
            "description": "Simple toolchain alias containing a spec string directly"
          },
          {
            "type": "array",
            "description": "List of conditional compiler constraints and specifications that define the toolchain behavior",
            "items": {
              "type": "object",
              "description": "Individual toolchain entry with a spec constraint and optional condition for when it applies",
              "properties": {
                "spec": {
                  "type": "string",
                  "description": "Spec constraint to apply such as compiler selection (%c=llvm), flags (cflags=-O3), or other virtual dependencies (%mpi=openmpi)"
                },
                "when": {
                  "type": "string",
                  "description": "Condition that determines when this spec constraint is applied, typically checking for language dependencies like %c, %cxx, %fortran, or other virtual packages like %mpi"
                }
              }
            }
          }
        ],
        "default": []
      }
    }
  },
  "additionalProperties": false
}
