chromium macos vscode

https://chromium.googlesource.com/chromium/src/+/105.0.5195.127/tools/vscode

https://source.chromium.org/chromium/chromium/src/+/main:tools/vscode/

一直以来都很少用vscode

了解下这几个配置的意思

 

launch.json

{
  "version": "0.2.0",
  "configurations": [
    {
      "name": "Chrome Debug",
      "type": "cppdbg", // "cppdbg" for GDB/LLDB, "cppvsdbg" for Windows Visual Studio debugger
      "request": "launch",
      "targetArchitecture": "x64", //targetArchitecture 被设置为 "x64" 或 "arm"。这表示相应的调试会话将用于调试 x86-64 架构(64 位)或 ARM 架构的目标程序。具体的架构值取决于目标平台和架构。
      "program": "${workspaceRoot}/out/Debug/chrome",
      "args": [], // Optional command line args
      "preLaunchTask": "8-build_chrome_debug", //preLaunchTask 有助于在启动调试之前自动执行构建任务,以确保调试器使用的是最新的可执行文件。这对于避免手动构建代码并确保调试环境的一致性非常有帮助。
      "stopAtEntry": false, // false 是调试配置中的一个属性设置,表示在启动调试会话时是否在程序的入口处停止执行。如果设置为 true,则在程序启动时会立即停止,等待用户手动触发单步执行或其他调试操作。
      "cwd": "${workspaceRoot}/out/Debug/", //当前工作目录
      "environment": [], //"environment" 是调试配置中的一个属性,用于设置调试器执行时的环境变量。
      "externalConsole": true, //"externalConsole" 是调试配置中的一个属性,用于指定在启动调试时是否使用外部控制台。在给定的 JSON 配置中,"externalConsole": true 表示启动调试时会使用外部控制台。
      "setupCommands": [ //"setupCommands" 是调试配置中的一个属性,用于指定在启动调试器之前要执行的设置命令。这些命令通常是针对特定的调试器,用于配置调试器的行为或加载特定的调试脚本。
        {
          "description": "Enable pretty printing for gdb",
          "text": "-enable-pretty-printing"
        },
        {
          "description": "Load Chromium gdb configuration",
          "text": "-interpreter-exec console \"source -v ${workspaceRoot}/tools/gdb/gdbinit\""
        },
        {
          "description": "Load Blink gdb configuration",
          "text": "-interpreter-exec console \"python import sys; sys.path.insert(0, '${workspaceRoot}/third_party/blink/tools/gdb'); import blink\""
        }
      ]
    },
//"setupCommands" 包含了三个命令,分别用于启用 GDB 的漂亮打印、加载 Chromium 的 GDB 配置以及加载 Blink 的 GDB 配置。这些命令在启动调试器之前被执行,以确保调试器以正确的方式配置和加载必要的调试脚本。这对于特定项目或框架的调试器配置非常有用。 {
"name": "Chrome Release", "type": "cppdbg", // "cppdbg" for GDB/LLDB, "cppvsdbg" for Windows Visual Studio debugger "request": "launch", "targetArchitecture": "x64", "program": "${workspaceRoot}/out/Release/chrome", "args": [], // Optional command line args "preLaunchTask": "9-build_chrome_release", "stopAtEntry": false, "cwd": "${workspaceRoot}/out/Release/", "environment": [], "externalConsole": true }, { "name": "Custom Test Debug", "type": "cppdbg", // "cppdbg" for GDB/LLDB, "cppvsdbg" for Windows Visual Studio debugger "request": "launch", "targetArchitecture": "x64", "program": "${workspaceRoot}/out/Debug/unit_tests", "args": [ "--gtest_filter=*", "--single-process-tests", "--ui-test-action-max-timeout=1000000", "--test-launcher-timeout=1000000" ], "preLaunchTask": "10-build_test_debug", "stopAtEntry": false, "cwd": "${workspaceRoot}/out/Debug/", "environment": [], "externalConsole": true }, { "name": "Attach Debug", "type": "cppdbg", // "cppdbg" for GDB/LLDB, "cppvsdbg" for Windows Visual Studio debugger "request": "launch", "targetArchitecture": "x64", "program": "${workspaceRoot}/out/Debug/chrome", "args": [ "--remote-debugging-port=2224" ], "stopAtEntry": false, "cwd": "${workspaceRoot}/out/Debug/", "environment": [], "externalConsole": false }, { // Must be running before launching: out/Debug/bin/chrome_public_apk gdb --ide "name": "Attach Android", "type": "cppdbg", // "cppdbg" for GDB/LLDB, "cppvsdbg" for Windows Visual Studio debugger "request": "launch", "targetArchitecture": "arm", "program": "/tmp/adb-gdb-support-${env:USER}/app_process", "miDebuggerPath": "/tmp/adb-gdb-support-${env:USER}/gdb", "miDebuggerServerAddress": "ignored", "cwd": "${workspaceRoot}", "customLaunchSetupCommands": [ { "text": "-interpreter-exec console \"source -v /tmp/adb-gdb-support-${env:USER}/gdbinit\"" } ], "launchCompleteCommand": "None", } ] }

 

settings.js{  // Suggested vscode default settings for simplifying initial setup. These

// settings are hoped to be convenient and helpful for those beginning to use
  // vscode with Chrome. Please modify and change as necessary.
  // All settings are optional, but some more "optional" settings at the end
  // are disabled by default. Feel free to enable them.
  // Default tab size of 2, for consistency with internal codebase.
  "editor.tabSize": 2, // 默认制表符大小为2,以与内部代码库一致。
  // Do not figure out tab size from opening a file.
  "editor.detectIndentation": false, // 不要从打开文件中推断制表符大小。
  // Add a line at 80 characters. 
  "editor.rulers": [80], // 在80个字符处添加一条竖线。
  // Forces LF instead of "auto" which uses CRLF on Windows.
  "files.eol": "\n", // 强制使用 LF 而不是 "auto",在 Windows 上使用 CRLF。
  // Trim tailing whitespace on save.
  "files.trimTrailingWhitespace": true, // 保存时去除尾随空格。
  // Insert trimmed final new line.
  "files.insertFinalNewline": true, // 插入去除的最终换行符。
  "files.trimFinalNewlines": true,
  "files.associations": {
    // Adds xml syntax highlighting for grd files.
    "*.grd" : "xml", // 为 grd 文件添加 XML 语法高亮。
    // Optional: .gn and .gni are not JavaScript, but at least it gives some
    // approximate syntax highlighting. Ignore the linter warnings!
    // There's an extension for these files, excluding the linter headaches.
    // https://marketplace.visualstudio.com/items?itemName=npclaudiu.vscode-gn
    "*.gni" : "javascript",
    "*.gn" : "javascript"
  },
  "files.exclude": {
    // Ignore build output folders.
    "out*/**": true // 忽略构建输出文件夹。
  },
  "files.watcherExclude": {
    // Don't watch out*/ and third_party/ for changes to fix an issue
    // where vscode doesn't notice that files have changed.
    // https://github.com/Microsoft/vscode/issues/3998
    // There is currently another issue that requires a leading **/ for
    // watcherExlude. Beware that this pattern might affect other out* folders
    // like src/cc/output/.
    "**/out*/**": true,
    "**/third_party/**": true
// 不要监视 out*/ 和 third_party/ 的更改,以解决一个问题, // 即 VSCode 不会注意到文件已更改的问题。 // https://github.com/Microsoft/vscode/issues/3998 // 目前存在另一个问题,需要一个前导 **/ 用于 watcherExclude。注意,这个模式可能影响其他 out* 文件夹,比如 src/cc/output/。
}, // Wider author column for annotator extension. // https://marketplace.visualstudio.com/items?itemName=ryu1kn.annotator "annotator.annotationColumnWidth": "24em", // Annotator 扩展的宽作者列。 // C++ clang format settings. |workspaceFolder| is assumed to be Chromium's // src/ directory. "C_Cpp.clang_format_path": "${workspaceFolder}/third_party/depot_tools/clang-format", // C++ clang 格式设置。假设 |workspaceFolder| 是 Chromium 的 src/ 目录。 "C_Cpp.clang_format_sortIncludes": true, "editor.formatOnSave": true, "editor.formatOnSaveMode": "modifications", // Optional: Highlight current line at the left of the editor. // "editor.renderLineHighlight": "gutter", // Optional: Don't automatically add closing brackets. It gets in the way. // "editor.autoClosingBrackets": "never", // Optional: Enable a tiny 30k feet view of your doc. // "editor.minimap.enabled": true, // "editor.minimap.maxColumn": 80, // "editor.minimap.renderCharacters": false, // Optional: Don't continuously fetch remote changes. //"git.autofetch": false, // Optional: Do not open files in 'preview' mode. Opening a new file in can // replace an existing one in preview mode, which can be confusing. //"workbench.editor.enablePreview": false, // Optional: Same for files opened from quick open (Ctrl+P). //"workbench.editor.enablePreviewFromQuickOpen": false, }

 

tasks.json

{
  // Note!
  // Set the value used for ${config:chrome.outputDir} in your settings.json
  // file with a line like:
  //   "chrome.outputDir": "/path/to/chromium/src/out/current_link",
  // Then run "0-set_chrome_output_directory" to set the `current_link`
// 注意!
// 使用类似以下行的 "settings.json" 文件中的 ${config:chrome.outputDir} 值设置
// "chrome.outputDir": "/path/to/chromium/src/out/current_link",
// 然后运行 "0-set_chrome_output_directory" 来设置 `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", "${workspaceRoot}"], "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", "${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" ] }, { "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 ${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 -C ${config:chrome.outputDir} chrome", "group": "test" }, { "label": "2-build_all", "type": "shell", "command": "autoninja -C ${config:chrome.outputDir}" }, { "label": "3-test_current_file", "type": "shell", "command": "${workspaceFolder}/tools/autotest.py -C ${config:chrome.outputDir} --run-all ${file}" }, { "label": "4-test_current_file_with_filter", "type": "shell", "command": "${workspaceFolder}/tools/autotest.py -C ${config:chrome.outputDir} --gtest_filter ${input:gtestFilter} ${file}" }, { "label": "5-test_current_line", "type": "shell", "command": "${workspaceFolder}/tools/autotest.py -C ${config:chrome.outputDir} --line ${lineNumber} ${file}" }, { "label": "6-test_current_directory", "type": "shell", "command": "${workspaceFolder}/tools/autotest.py -C ${config:chrome.outputDir} --run-all ${fileDirname}" }, { "label": "7-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": "8-build_chrome_debug", "type": "shell", "command": "autoninja -C ${workspaceFolder}/out/Debug chrome" }, { "label": "9-build_chrome_release", "type": "shell", "command": "autoninja -C ${workspaceFolder}/out/Release chrome" }, { "label": "10-build_test_debug", "type": "shell", "command": "autoninja -C ${workspaceFolder}/out/Debug unit_tests components_unittests browser_tests" }, { "label": "11-generate_compile_commands", "type": "shell", "command": "${workspaceFolder}/tools/clang/scripts/generate_compdb.py -p ${config:chrome.outputDir} > ${workspaceFolder}/compile_commands.json" } ] }
  • version: 配置文件版本。
  • runner: 指定任务运行器为终端。
  • problemMatcher: 用于匹配构建输出中的警告和错误。
  • options: 一些通用选项,例如将当前工作目录设置为输出目录。
  • inputs: 用户输入配置,用于在运行任务时提供值。
  • tasks: 具体的任务配置,包括构建、测试等。
posted @ 2024-01-03 11:51  冰糖葫芦很乖  阅读(164)  评论(0编辑  收藏  举报