{
  // See https://go.microsoft.com/fwlink/?LinkId=733558
  // for the documentation about the tasks.json format
  "version": "2.0.0",
  "tasks": [
    {
      "label": "cmake configure",
      "type": "shell",
      "command": "cd ${workspaceFolder} && cmake -S . -B build -G Ninja -DCMAKE_BUILD_TYPE=Release -DCMAKE_EXPORT_COMPILE_COMMANDS=ON && cmake -E copy_if_different ${workspaceFolder}/build/compile_commands.json ${workspaceFolder}/compile_commands.json",
      "problemMatcher": [],
    },
    {
      "label": "cmake build",
      "type": "shell",
      "command": "cd ${workspaceFolder} && cmake --build build",
      "problemMatcher": [],
    },
    {
      "label": "Run new build",
      "type": "shell",
      "command": "cd ${workspaceFolder} && pwd && cmake -S . -B build -G Ninja -DCMAKE_EXPORT_COMPILE_COMMANDS=ON && cmake -E copy_if_different ${workspaceFolder}/build/compile_commands.json ${workspaceFolder}/compile_commands.json && cmake --build build --target run",
      "problemMatcher": [],
      "group": {
        "kind": "build",
        "isDefault": true,
      },
      "presentation": {
        "echo": true,
        "reveal": "always",
        "focus": false,
        "panel": "dedicated",
        "showReuseMessage": true,
        "clear": true,
      },
    },
    {
      "label": "Copy new build to SD",
      "type": "shell",
      "command": "cd ${workspaceFolder} && pwd && cmake -S . -B build -G Ninja -DCMAKE_EXPORT_COMPILE_COMMANDS=ON && cmake -E copy_if_different ${workspaceFolder}/build/compile_commands.json ${workspaceFolder}/compile_commands.json && cmake --build build --target install_sd",
      "problemMatcher": [],
      "presentation": {
        "echo": true,
        "reveal": "silent",
        "focus": false,
        "panel": "dedicated",
        "showReuseMessage": true,
        "clear": false,
      },
    },
    {
      "label": "cmake debug",
      "type": "shell",
      "command": "cd ${workspaceFolder} && cmake -S . -B build-debug -G Ninja -DCMAKE_BUILD_TYPE=Debug -DCMAKE_EXPORT_COMPILE_COMMANDS=ON && cmake -E copy_if_different ${workspaceFolder}/build-debug/compile_commands.json ${workspaceFolder}/compile_commands.json && cmake --build build-debug",
      "problemMatcher": [],
    },
    {
      "label": "cmake release",
      "type": "shell",
      "command": "cd ${workspaceFolder} && cmake -S . -B build -G Ninja -DCMAKE_BUILD_TYPE=Release -DCMAKE_EXPORT_COMPILE_COMMANDS=ON && cmake -E copy_if_different ${workspaceFolder}/build/compile_commands.json ${workspaceFolder}/compile_commands.json && cmake --build build",
      "problemMatcher": [],
      "group": {
        "kind": "build",
        "isDefault": true,
      },
    },
    {
      "label": "cmake clean",
      "type": "shell",
      "command": "cd ${workspaceFolder} && if [ -d build ]; then cmake --build build --target clean; fi && if [ -d build-debug ]; then cmake --build build-debug --target clean; fi",
      "problemMatcher": [],
    },
    {
      "label": "run",
      "type": "shell",
      "isBackground": true,
      "command": "melonDS",
      "args": ["${workspaceFolder}/${workspaceFolderBasename}.nds"],
      "presentation": {
        "clear": true,
        "reveal": "always",
      },
      "problemMatcher": [],
    },
    {
      "label": "gdb-debug",
      "type": "shell",
      "dependsOn": ["cmake debug"],
      "isBackground": true,
      "command": "melonDS",
      "args": [
        "${workspaceFolder}/${workspaceFolderBasename}.nds"
      ],
      "presentation": {
        "clear": true,
        "reveal": "always",
      },
      "problemMatcher": [
        {
          "pattern": [
            {
              "regexp": ".",
              "file": 1,
              "location": 2,
              "message": 3,
            },
          ],
          "background": {
            "activeOnStart": true,
            "beginsPattern": ".",
            "endsPattern": ".",
          },
        },
      ],
    },
    {
      "label": "stop-emulation",
      "type": "shell",
      "command": "pkill",
      "args": ["--signal", "9", "melonDS"],
      "problemMatcher": [],
    },
  ],
}
