chromium/tools/vscode/tasks.json

{
  // Note!
  // Set the "chromeOutputDir" input string below, then run
  // "0-set_chrome_output_directory" to set the `current_link` symbolic link
  // (see below).
  "version": "2.0.0",
  "runner": "terminal",
  // The default problem matcher matches build output, which is useful for most tasks.
  "problemMatcher": [
    // Matches output from clang.
    {
      "owner": "cpp",
      "fileLocation": ["relative", "${config:chrome.outputDir}"],
      "pattern": {
        "regexp": "^(gen/.*):(\\d+):(\\d+):\\s+(warning|\\w*\\s?error):\\s+(.*)$",
        "file": 1, "line": 2, "column": 3, "severity": 4, "message": 5
      }
    },
    {
      "owner": "cpp",
      "fileLocation": ["relative", "${workspaceFolder}"],
      "pattern": {
        "regexp": "^../../(.*):(\\d+):(\\d+):\\s+(warning|\\w*\\s?error):\\s+(.*)$",
        "file": 1, "line": 2, "column": 3, "severity": 4, "message": 5
      }
    },
    // Matches output from clang-cl / msvc.
    {
      "owner": "cpp",
      "fileLocation": [
        "relative",
        "${config:chrome.outputDir}"
      ],
      "pattern": {
        "regexp": "^(gen/.*)\\((\\d+),(\\d+)\\):\\s+(warning|\\w*\\s?error):\\s+(.*)$",
        "file": 1,
        "line": 2,
        "column": 3,
        "severity": 4,
        "message": 5
      }
    },
    {
      "owner": "cpp",
      "fileLocation": [
        "relative",
        "${workspaceFolder}"
      ],
      "pattern": {
        "regexp": "^../../(.*)\\((\\d+),(\\d+)\\):\\s+(warning|\\w*\\s?error):\\s+(.*)$",
        "file": 1,
        "line": 2,
        "column": 3,
        "severity": 4,
        "message": 5
      }
    },
    {
      "owner": "cpp",
      "fileLocation": ["relative", "${config:chrome.outputDir}"],
      "pattern": {
        "regexp": "^(gen/.*?):(.*):\\s+(warning|\\w*\\s?error):\\s+(.*)$",
        "file": 1, "severity": 3, "message": 4
      }
    },
    {
      "owner": "cpp",
      "fileLocation": ["relative", "${workspaceFolder}"],
      "pattern": {
        "regexp": "^../../(.*?):(.*):\\s+(warning|\\w*\\s?error):\\s+(.*)$",
        "file": 1, "severity": 3, "message": 4
      }
    }
  ],
  "options": {
    // It's important to set the CWD to the output directory so that file paths
    // are linked correctly in the terminal output.
    "cwd": "${config:chrome.outputDir}"
  },

  "inputs": [
    {
      // See 'Set Chrome Output Directory'.
      "type": "pickString",
      "id": "chromeOutputDir",
      "description": "Chrome output directory:",
      // Configure this to point to all the output directories you use (as a
      // relative path from ${workspaceFolder}).
      "options": [
        "out/Debug",
        "out/Release"
      ]
    },
    {
      "type": "promptString",
      "id": "gtestFilter",
      "description": "Filter for 4-test_current_file_with_filter",
      "default": "*"
    }
  ],
  "tasks": [
    // Set the Chrome output directory to be used in future task runs.
    // This uses a symbolic link to remember the current output directory.
    // If you want to use this, make sure chrome.outputDir is configured to
    // point to the link created at ${workspaceFolder}/out/current_link.

    // Alternatively:
    // * If you want to be prompted for the output directory each
    //   time you run a command, replace
    //     ${config:chrome.outputDir}
    //   with
    //     ${input:chromeOutputDir}
    //   everywhere in this file.
    //
    // * If you want to have different tasks for different output directories,
    //   just create duplicate tasks and hard-code the output directory used.

    {
      "label": "0-set_chrome_output_directory",
      "command": "rm -f ${workspaceFolder}/out/current_link; ln -s ${workspaceFolder}/${input:chromeOutputDir} ${workspaceFolder}/out/current_link",
      "type": "shell",
      // The default problem matcher doesn't make sense here, so remove it.
      "problemMatcher": [],
      "options": {
        "cwd": "${workspaceFolder}"
      }
    },
    // Some general-purpose build and test tasks. These all inherit the
    // problemMatcher at the top of the file.
    {
      "label": "1-build_chrome",
      "type": "shell",
      "command": "autoninja",
      "args": ["-C", "${config:chrome.outputDir}", "chrome"],
      "group": "test"
    },
    {
      "label": "2-build_all",
      "type": "shell",
      "command": "autoninja",
      "args": ["-C", "${config:chrome.outputDir}"]
    },
    {
      "label": "3-test_current_file",
      "type": "shell",
      "command": "${workspaceFolder}/tools/autotest.py",
      "args": ["-C", "${config:chrome.outputDir}", "--run-all", "${file}"]
    },
    {
      "label": "4-test_current_file_with_filter",
      "type": "shell",
      "command": "${workspaceFolder}/tools/autotest.py",
      "args": ["-C", "${config:chrome.outputDir}", "--gtest_filter", "${input:gtestFilter}", "${file}"]
    },
    {
      "label": "5-test_current_line",
      "type": "shell",
      "command": "${workspaceFolder}/tools/autotest.py",
      "args": ["-C", "${config:chrome.outputDir}", "--line", "${lineNumber}", "${file}"]
    },
    {
      "label": "6-test_current_directory",
      "type": "shell",
      "command": "${workspaceFolder}/tools/autotest.py",
      "args": ["-C", "${config:chrome.outputDir}", "--run-all", "${fileDirname}"]
    },
    {
      "label": "7-build_current_file",
      "type": "shell",
      "command": "compile_single_file",
      "args": ["--build-dir=${config:chrome.outputDir}", "--file-path=${file}"]
    },
    // Some more specific build tasks, which hard-code the output directory.
    {
      "label": "8-build_chrome_debug",
      "type": "shell",
      "command": "autoninja",
      "args": ["-C", "${workspaceFolder}/out/Debug", "chrome"]
    },
    {
      "label": "9-build_chrome_release",
      "type": "shell",
      "command": "autoninja",
      "args": ["-C", "${workspaceFolder}/out/Release", "chrome"]
    },
    {
      "label": "10-build_test_debug",
      "type": "shell",
      "command": "autoninja",
      "args": ["-C", "${workspaceFolder}/out/Debug", "unit_tests", "components_unittests", "browser_tests", "extensions_unittests", "ash_unittests"]
    },
    {
      "label": "11-generate_compile_commands",
      "type": "shell",
      "command": "${workspaceFolder}/tools/clang/scripts/generate_compdb.py",
      "args": ["-p", "${config:chrome.outputDir}", ">", "${workspaceFolder}/compile_commands.json"]
    }
  ]
}