{
  "$schema": "https://json-schema.org/draft/2020-12/schema",
  "$id": "https://simantic.com/schema/simantic.json",
  "title": "simantic.json",
  "type": "object",
  "properties": {
    "$schema": {
      "description": "The JSON Schema this file follows, for editors: https://simantic.com/schema/simantic.json.",
      "type": "string",
      "maxLength": 256
    },
    "name": {
      "description": "The project's name, unique in the repository: letters, digits, dot, underscore and hyphen, up to 64. The folder's name when left out.",
      "type": "string",
      "pattern": "^[A-Za-z0-9._-]{1,64}$"
    },
    "mcu": {
      "type": "string",
      "minLength": 1,
      "maxLength": 64,
      "description": "The microcontroller the firmware is for, as the simulator names it: STM32F401RE, RP2040, ESP32-C3. An order code such as STM32F401RET6 is accepted. The only required field."
    },
    "build": {
      "type": "object",
      "properties": {
        "system": {
          "description": "The build system, which picks the command the reviewer runs: cubemx-make (an STM32CubeMX Makefile, built with the image's Arm toolchain), make, cmake, pico-sdk, esp-idf or zephyr. When neither system nor command is given, the reviewer detects the build system in the directory.",
          "type": "string",
          "enum": [
            "cubemx-make",
            "make",
            "cmake",
            "pico-sdk",
            "esp-idf",
            "zephyr"
          ]
        },
        "command": {
          "description": "A command to build with instead of the build system's own, run in a shell in the build directory, with args after it. The build must leave an ELF under the directory, or name it in elf.",
          "type": "string",
          "minLength": 1,
          "maxLength": 2000
        },
        "dir": {
          "type": "string",
          "minLength": 1,
          "maxLength": 256,
          "description": "The directory to build in, relative to this file's; this file's own directory when left out. It must stay inside the repository."
        },
        "args": {
          "description": "Arguments added to the build command: make variables, -D defines for cmake's configure step, or anything after a custom command.",
          "maxItems": 50,
          "type": "array",
          "items": {
            "type": "string",
            "minLength": 1,
            "maxLength": 500
          }
        },
        "target": {
          "description": "The ESP-IDF target (idf.py set-target), such as esp32c3.",
          "type": "string",
          "minLength": 1,
          "maxLength": 64
        },
        "board": {
          "description": "The pico-sdk PICO_BOARD, or the Zephyr board given to west build -b.",
          "type": "string",
          "minLength": 1,
          "maxLength": 64
        },
        "elf": {
          "type": "string",
          "minLength": 1,
          "maxLength": 256,
          "description": "The ELF the build produces, relative to the build directory, such as build/app.elf. When left out, the newest .elf under the directory after the build is taken."
        }
      },
      "additionalProperties": false,
      "description": "How the firmware is built. Left out, the reviewer detects the build system from the directory."
    },
    "toolchain": {
      "type": "object",
      "properties": {
        "arm-gnu": {
          "type": "string",
          "pattern": "^v?\\d[\\w.-]{0,31}$",
          "description": "The Arm GNU Toolchain (arm-none-eabi-gcc) version, such as 14.3."
        },
        "pico-sdk": {
          "type": "string",
          "pattern": "^v?\\d[\\w.-]{0,31}$",
          "description": "The pico-sdk version, such as 2.1."
        },
        "zephyr": {
          "type": "string",
          "pattern": "^v?\\d[\\w.-]{0,31}$",
          "description": "The Zephyr version, such as 4.4."
        },
        "esp-idf": {
          "type": "string",
          "pattern": "^v?\\d[\\w.-]{0,31}$",
          "description": "The ESP-IDF version, such as 5.4."
        }
      },
      "additionalProperties": false,
      "description": "The toolchain versions the project builds with, as prefixes (14.3 matches 14.3.1). The reviewer has one version of each and checks these against it: a difference is a note in the review, never a refusal."
    },
    "simulate": {
      "type": "object",
      "properties": {
        "seconds": {
          "description": "Simulated seconds a run lasts when the reviewer names no other length; at most 120.",
          "type": "number",
          "exclusiveMinimum": 0,
          "maximum": 120
        },
        "board": {
          "type": "string",
          "minLength": 1,
          "maxLength": 256,
          "description": "A .board file laid over the chip in every run (parts on its buses), relative to the build directory."
        },
        "expect": {
          "description": "Texts the firmware prints on a UART when it boots, which a smoke run should show.",
          "maxItems": 20,
          "type": "array",
          "items": {
            "type": "string",
            "minLength": 1,
            "maxLength": 200
          }
        }
      },
      "additionalProperties": false,
      "description": "Defaults for the reviewer's simulation runs of this project."
    }
  },
  "required": [
    "mcu"
  ],
  "additionalProperties": false,
  "description": "A Simantic project: one firmware image, built from the folder this file is in. The PR reviewer reads it to know the MCU, how to build and where the ELF is; a repository may hold one per project."
}
