0

Update example vscode tasks

- Try to make the tasks more general purpose.
  * Add mechanism to switch output directories. Most
    tasks will work with this value.
  * Add tasks to run tests for the current file or directory
    instead of pre-determined targets.
- Try to simplify it.
  * Remove some parameters which are defaults
  * Move pattern matches to top-level, to avoid duplicates.

Change-Id: Ifff15bc264be510c0859e4adcce7b996349ac343
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2402189
Reviewed-by: Chase Phillips <cmp@chromium.org>
Commit-Queue: Chase Phillips <cmp@chromium.org>
Cr-Commit-Position: refs/heads/master@{#805872}
This commit is contained in:
Dan Harrington
2020-09-10 19:47:08 +00:00
committed by Commit Bot
parent 8d80e246b3
commit b426cf9b18
3 changed files with 123 additions and 247 deletions

@ -259,12 +259,12 @@ in the Explorer tab) is chromium/src. If this is not the case, replace any
references to ${workspaceFolder} with the path to chromium/src.
### Tasks
Next, we'll tell VS Code how to compile our code and how to read warnings and
errors from the build output. Open the file
[//tools/vscode/tasks.json5](/tools/vscode/tasks.json5). This will provide 5
tasks to do basic things. You might have to adjust the commands to your
situation and needs. To use these settings wholesale, enter the following
command into your terminal:
Next, we'll tell VS Code how to compile our code, run tests, and to read
warnings and errors from the build output. Open the file
[//tools/vscode/tasks.json5](/tools/vscode/tasks.json5). This will provide tasks
to do basic things. You might have to adjust the commands to your situation and
needs. To use these settings wholesale, enter the following command into your
terminal:
```
$ cp tools/vscode/tasks.json5 .vscode/tasks.json
```

@ -8,7 +8,7 @@
"targetArchitecture": "x64",
"program": "${workspaceRoot}/out/Debug/chrome",
"args": [], // Optional command line args
"preLaunchTask": "1-build_chrome_debug",
"preLaunchTask": "6-build_chrome_debug",
"stopAtEntry": false,
"cwd": "${workspaceRoot}/out/Debug/",
"environment": [],
@ -35,7 +35,7 @@
"targetArchitecture": "x64",
"program": "${workspaceRoot}/out/Release/chrome",
"args": [], // Optional command line args
"preLaunchTask": "2-build_chrome_release",
"preLaunchTask": "7-build_chrome_release",
"stopAtEntry": false,
"cwd": "${workspaceRoot}/out/Release/",
"environment": [],
@ -53,7 +53,7 @@
"--ui-test-action-max-timeout=1000000",
"--test-launcher-timeout=1000000"
],
"preLaunchTask": "5-build_test_debug",
"preLaunchTask": "8-build_test_debug",
"stopAtEntry": false,
"cwd": "${workspaceRoot}/out/Debug/",
"environment": [],

@ -1,259 +1,135 @@
{
// Note!
// You can set the value used for ${config:chrome.outputDir} in your settings.json
// file with a line like:
// "chrome.outputDir": "/path/to/chromium/src/out/Debug",
"version": "2.0.0",
"runner": "terminal",
// The default problem matcher matches build output, which is useful for most tasks.
"problemMatcher": [
{
"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", "${workspaceRoot}"],
"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", "${workspaceRoot}"],
"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.
"options": [
"/path/to/chromium/src/out/pc",
"/path/to/chromium/src/out/Debug",
"/path/to/chromium/src/out/Debug_x86"
]
}
],
"tasks": [
{
"label": "1-build_chrome_debug",
"type": "shell",
"command": "autoninja -C out/Debug chrome",
"group": "test",
"presentation": {
"echo": true,
"reveal": "always"
},
"problemMatcher": [
// 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.
{
"owner": "cpp",
"fileLocation": ["relative", "${workspaceRoot}/out/Debug"],
"pattern": {
"regexp": "^(gen/.*):(\\d+):(\\d+):\\s+(warning|\\w*\\s?error):\\s+(.*)$",
"file": 1, "line": 2, "column": 3, "severity": 4, "message": 5
"label": "0-set_chrome_output_directory",
"command": "rm -f ${workspaceFolder}/out/current_link; ln -s ${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.
{
"owner": "cpp",
"fileLocation": ["relative", "${workspaceRoot}"],
"pattern": {
"regexp": "^../../(.*):(\\d+):(\\d+):\\s+(warning|\\w*\\s?error):\\s+(.*)$",
"file": 1, "line": 2, "column": 3, "severity": 4, "message": 5
}
"label": "1-build_chrome",
"type": "shell",
"command": "autoninja -C ${config:chrome.outputDir} chrome",
"group": "test"
},
{
"owner": "cpp",
"fileLocation": ["relative", "${workspaceRoot}/out/Debug"],
"pattern": {
"regexp": "^(gen/.*?):(.*):\\s+(warning|\\w*\\s?error):\\s+(.*)$",
"file": 1, "severity": 3, "message": 4
}
"label": "2-build_all",
"type": "shell",
"command": "autoninja -C ${config:chrome.outputDir}"
},
{
"owner": "cpp",
"fileLocation": ["relative", "${workspaceRoot}"],
"pattern": {
"regexp": "^../../(.*?):(.*):\\s+(warning|\\w*\\s?error):\\s+(.*)$",
"file": 1, "severity": 3, "message": 4
}
}]
},
{
"label": "2-build_chrome_release",
"type": "shell",
"command": "ninja -C out/Release -j 2000 chrome",
"group": "build",
"presentation": {
"echo": true,
"reveal": "always"
},
"problemMatcher": [
{
"owner": "cpp",
"fileLocation": ["relative", "${workspaceRoot}/out/Release"],
"pattern": {
"regexp": "^(gen/.*):(\\d+):(\\d+):\\s+(warning|\\w*\\s?error):\\s+(.*)$",
"file": 1, "line": 2, "column": 3, "severity": 4, "message": 5
}
"label": "3-test_current_file",
"type": "shell",
"command": "${workspaceFolder}/tools/autotest.py -C ${config:chrome.outputDir} --run_all ${file}"
},
{
"owner": "cpp",
"fileLocation": ["relative", "${workspaceRoot}"],
"pattern": {
"regexp": "^../../(.*):(\\d+):(\\d+):\\s+(warning|\\w*\\s?error):\\s+(.*)$",
"file": 1, "line": 2, "column": 3, "severity": 4, "message": 5
}
"label": "4-test_current_directory",
"type": "shell",
"command": "${workspaceFolder}/tools/autotest.py -C ${config:chrome.outputDir} --run_all ${fileDirname}"
},
{
"owner": "cpp",
"fileLocation": ["relative", "${workspaceRoot}/out/Release"],
"pattern": {
"regexp": "^(gen/.*?):(.*):\\s+(warning|\\w*\\s?error):\\s+(.*)$",
"file": 1, "severity": 3, "message": 4
}
"label": "5-build_current_file",
"type": "shell",
"command": "compile_single_file --build-dir=${config:chrome.outputDir} --file-path=${file}"
},
// Some more specific build tasks, which hard-code the output directory.
{
"label": "6-build_chrome_debug",
"type": "shell",
"command": "autoninja -C ${workspaceFolder}/out/Debug chrome"
},
{
"owner": "cpp",
"fileLocation": ["relative", "${workspaceRoot}"],
"pattern": {
"regexp": "^../../(.*?):(.*):\\s+(warning|\\w*\\s?error):\\s+(.*)$",
"file": 1, "severity": 3, "message": 4
}
}]
},
{
"label": "3-build_all_debug",
"type": "shell",
"command": "autoninja -C out/Debug",
"presentation": {
"echo": true,
"reveal": "always"
},
"problemMatcher": [
{
"owner": "cpp",
"fileLocation": ["relative", "${workspaceRoot}/out/Debug"],
"pattern": {
"regexp": "^(gen/.*):(\\d+):(\\d+):\\s+(warning|\\w*\\s?error):\\s+(.*)$",
"file": 1, "line": 2, "column": 3, "severity": 4, "message": 5
}
"label": "7-build_chrome_release",
"type": "shell",
"command": "autoninja -C ${workspaceFolder}/out/Release chrome"
},
{
"owner": "cpp",
"fileLocation": ["relative", "${workspaceRoot}"],
"pattern": {
"regexp": "^../../(.*):(\\d+):(\\d+):\\s+(warning|\\w*\\s?error):\\s+(.*)$",
"file": 1, "line": 2, "column": 3, "severity": 4, "message": 5
}
},
{
"owner": "cpp",
"fileLocation": ["relative", "${workspaceRoot}/out/Debug"],
"pattern": {
"regexp": "^(gen/.*?):(.*):\\s+(warning|\\w*\\s?error):\\s+(.*)$",
"file": 1, "severity": 3, "message": 4
}
},
{
"owner": "cpp",
"fileLocation": ["relative", "${workspaceRoot}"],
"pattern": {
"regexp": "^../../(.*?):(.*):\\s+(warning|\\w*\\s?error):\\s+(.*)$",
"file": 1, "severity": 3, "message": 4
}
}]
},
{
"label": "4-build_all_release",
"type": "shell",
"command": "ninja -C out/Release -j 2000",
"presentation": {
"echo": true,
"reveal": "always"
},
"problemMatcher": [
{
"owner": "cpp",
"fileLocation": ["relative", "${workspaceRoot}/out/Release"],
"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", "${workspaceRoot}"],
"pattern": {
"regexp": "^../../(.*):(\\d+):(\\d+):\\s+(warning|\\w*\\s?error):\\s+(.*)$",
"file": 1, "line": 2, "column": 3, "severity": 4, "message": 5
}
},
{
"owner": "cpp",
"fileLocation": ["relative", "${workspaceRoot}/out/Release"],
"pattern": {
"regexp": "^(gen/.*?):(.*):\\s+(warning|\\w*\\s?error):\\s+(.*)$",
"file": 1, "severity": 3, "message": 4
}
},
{
"owner": "cpp",
"fileLocation": ["relative", "${workspaceRoot}"],
"pattern": {
"regexp": "^../../(.*?):(.*):\\s+(warning|\\w*\\s?error):\\s+(.*)$",
"file": 1, "severity": 3, "message": 4
}
}]
},
{
"label": "5-build_test_debug",
"type": "shell",
"command": "autoninja -C out/Debug unit_tests components_unittests browser_tests",
"presentation": {
"echo": true,
"reveal": "always"
},
"problemMatcher": [
{
"owner": "cpp",
"fileLocation": ["relative", "${workspaceRoot}/out/Debug"],
"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", "${workspaceRoot}"],
"pattern": {
"regexp": "^../../(.*):(\\d+):(\\d+):\\s+(warning|\\w*\\s?error):\\s+(.*)$",
"file": 1, "line": 2, "column": 3, "severity": 4, "message": 5
}
},
{
"owner": "cpp",
"fileLocation": ["relative", "${workspaceRoot}/out/Debug"],
"pattern": {
"regexp": "^(gen/.*?):(.*):\\s+(warning|\\w*\\s?error):\\s+(.*)$",
"file": 1, "severity": 3, "message": 4
}
},
{
"owner": "cpp",
"fileLocation": ["relative", "${workspaceRoot}"],
"pattern": {
"regexp": "^../../(.*?):(.*):\\s+(warning|\\w*\\s?error):\\s+(.*)$",
"file": 1, "severity": 3, "message": 4
}
}]
},
{
"label": "6-build_current_file",
"type": "shell",
"command": "compile_single_file --build-dir=out/Debug --file-path=${file}",
"presentation": {
"echo": true,
"reveal": "always"
},
"problemMatcher": [
{
"owner": "cpp",
"fileLocation": ["relative", "${workspaceRoot}/out/Debug"],
"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", "${workspaceRoot}"],
"pattern": {
"regexp": "^../../(.*):(\\d+):(\\d+):\\s+(warning|\\w*\\s?error):\\s+(.*)$",
"file": 1, "line": 2, "column": 3, "severity": 4, "message": 5
}
},
{
"owner": "cpp",
"fileLocation": ["relative", "${workspaceRoot}/out/Debug"],
"pattern": {
"regexp": "^(gen/.*?):(.*):\\s+(warning|\\w*\\s?error):\\s+(.*)$",
"file": 1, "severity": 3, "message": 4
}
},
{
"owner": "cpp",
"fileLocation": ["relative", "${workspaceRoot}"],
"pattern": {
"regexp": "^../../(.*?):(.*):\\s+(warning|\\w*\\s?error):\\s+(.*)$",
"file": 1, "severity": 3, "message": 4
}
}]
}]
"label": "8-build_test_debug",
"type": "shell",
"command": "autoninja -C ${workspaceFolder}/out/Debug unit_tests components_unittests browser_tests"
}
]
}