凡科做商品网站的教学视频,福田建网站,苏州网站推广工具,百度网盘下载官网Visual Studio Code (VSCode)是一个轻量级但功能强大的源代码编辑器#xff0c;可在桌面上运行#xff0c;适用于Windows#xff0c;macOS和Linux。 它内置了对JavaScript#xff0c;TypeScript和Node.js的支持#xff0c;并具有丰富的其他语言(如C#xff0c;C#xff… Visual Studio Code (VSCode)是一个轻量级但功能强大的源代码编辑器可在桌面上运行适用于WindowsmacOS和Linux。 它内置了对JavaScriptTypeScript和Node.js的支持并具有丰富的其他语言(如CCJavaPythonPHPGo)和运行时(如.NET和Unity)的扩展生态系统。使用这些介绍性视频开始使用VSCode开始您的旅程:https://code.visualstudio.com/docs/getstarted/introvideos本文介绍如何使用VSCode进行PostgreSQL开发环境准备安装VSCode1. 下载VSCode根据用户环境下载合适的VSCode版本下载地址:https://code.visualstudio.com/download2. 安装VSCode根据提示进行安装安装C/C编程语言支持安装C/C编程语言支持(C/C for Visual Studio Code)微软的C/C扩展**提供了对Visual Studio Code的C/C支持以便在WindowsLinux和macOS上使用VS Code进行C和C开发。Note: C Intellisense也可以使用根据个人喜欢选择。可以在VSCode内的Extension中搜索C/C找到目标插件后进行安装。下载PostgreSQL源代码Git下载最新PG代码确保您的计算机上安装了Git。Git的使用帮助网上随处可见这里就不赘述了。 $ cd sandbox $ git clone https://github.com/postgres/postgres.git $ cd postgres ## 一般更改代码都在特定的Branch上进行 $ git checkout -b FEATTURE-NAME $ EDIT YOUR CODE $ git commit -a $ git diff --patience master my-feature ../my-feature.patch下载对应版本的PG代码 (Optional) https://www.postgresql.org/ftp/source/运行VSCode 1.打开源代码目录 菜单 File -- Open 打开对应的目录比如 ~/sandbox/postgres 2.配置命令 有许多工具来自动执行诸如lintingbuild打包测试或部署软件系统之类的任务。 比如TypeScript编译器再比如ESLint和TSLint这样的linters以及MakeAntGulpJakeRake和MSBuild等build系统。这些工具主要是通过命令行来运行的并在内部软件开发过程(编辑编译测试和调试)内自动执行任务。 鉴于它们在开发生命周期中的重要性能够运行工具并从VS Code中分析其结果非常有帮助。VSCode中的任务可以配置为运行脚本和启动进程以便可以在VSCode中使用许多现有工具而无需输入命令行或编写新代码。工作区或文件夹特定任务是从工作区的.vscode文件夹中的tasks.json文件配置的。2.1 打开 View -- Command Palette输入 Task: , 选择 Tasks: Configure Task 2.2 选择 Create tasks.json file from template 2.3 选择 Others Example to run the arbitrary external command 2.4 现在开始编辑 task.json 文件到微软网站上 https://go.microsoft.com/fwlink/?LinkId733558查看关于 task.json 的格式文档注意 请根据个人需要编辑下面的任务配置文件{// See https://go.microsoft.com/fwlink/?LinkId733558// for the documentation about the tasks.json formatversion: 2.0.0,presentation : { reveal: always },tasks: [ {label: Configure,type: shell,command: ./configure --enable-depend --enable-cassert --enable-debug,problemMatcher: [$eslint-compact ] }, {label: Make All,type: shell,command: make -j4 all,problemMatcher: [$eslint-compact ] }, {label: Make Clean All,type: shell,command: make clean,problemMatcher: [$eslint-compact ] }, {label: Make Install,type: shell,command: make install } ]} 3.运行所配制的命令打开 View -- Command Palette -- Tasks: Run Task选择对应的 Configure、Make 或者 make install 命令来进行PostgreSQL的编译等任务。 NOTE 可以配置一些快捷方式来方便工作使用VS Code调试PostgreSQL这里以Mac环境下为例进行说明1.使用LLDB调试LLDB是XCode下默认的调试工具它和GDB有很多类似之处如果你对GDB熟悉使用LLDB不存在什么问题。这里是LLDB和GDB的一个命令对比(https://lldb.llvm.org/use/map.html)注意 如果你的开发环境是Linux请使用apt-get/yum 之间安装lldb在VS Code中调试PG打开lauch.json菜单 View - Command Palette输入launch选择 Debug: Open launch.json 选择 C (GDB/LLDB 编辑launch.json文件注意根据你的PG环境修改下面 args里面的路径{// Use IntelliSense to learn about possible attributes.// Hover to view descriptions of existing attributes.// For more information, visit: https://go.microsoft.com/fwlink/?linkid830387version: 0.2.0,configurations: [ {name: (lldb) pg Launch,type: cppdbg,request: launch,program: ${workspaceFolder}/src/backend/postgres,args: [-D, /Users/grantzhou/pgdata/data],stopAtEntry: false,cwd: ${workspaceFolder},environment: [],externalConsole: true,MIMode: lldb }, {name: (lldb) pg Launch help,type: cppdbg,request: launch,program: ${workspaceFolder}/src/backend/postgres,args: [--help, ],stopAtEntry: false,cwd: ${workspaceFolder},environment: [],externalConsole: true,MIMode: lldb }, {name: (lldb) Launch,type: cppdbg,request: attach,program: ${workspaceFolder}/src/backend/postgres,MIMode: lldb } ]} 开始调试1. 打开调试选项卡(或者 F5) 2. 调试当调试会话开始后, 上面会出现调试工具栏. Continue/Pause F5 Step Over F10 Step Into F11 Step Out ⇧F11 Restart ⇧⌘F5 Stop ⇧F52.使用GDB调试 (Mac上不推荐使用)注意在最新版的Mac上gdb 最新版本8.2的安装和执行非常的繁琐并且存在很多无法工作且需要降级到8.0版本的情况这里不推荐使用。MAC上安装GDB与GCC一样安装GDB的最简单方法是通过Homebrew。 在终端窗口中运行命令 brew install gdb并等待它完成。注意我们需要对GDB可执行文件进行代码签名从而可以根据调试器的需要控制其他进程。对gdb进行代码签名在Keychain中创建一个新证书1. 打开 Keychain Access 程序2. 菜单选择 Certificate Assistant -- Create a Certificate a. 确保Identity Type设置为Self Signed Root b. 将证书类型更改为代码签名 c. 选中“覆盖默认值”复选框 d. 选择 “Continue” (在弹出提示中再次单击继续)。 e. 在下一个页面 Security Number 1, Validity Period 3650 (最长 20 年) f. 点击继续 g. 一直继续直到让你选择保存位置。选择System h. 根据提示输入密码Done3. 回到 Keychain Access 主窗口选择左侧边栏中的System keychain然后从列表中选择新创建的证书右键选择 Get Info并设置为永远信任。 签名1. 重新启动Taskgate access-control服务使用Activity Monitor服务) 2. 点击Quit并等待其退出并重新显示在Activity Monitor中 (最多等待一到两分钟)3. 签名完成调试签名问题codesign -fs gdbcert /usr/local/bin/gdbRestart your mac and enablecsrutil enable --without debugsudo killall taskgated# Monitor logslog stream --predicate process taskgated OR (process kernel AND eventMessage CONTAINS macOSTaskPolicy) --info其他1. PostgreSQL后端主流程初次PG开发人员建议多看一下 https://www.postgresql.org/developer/backend2.Wiki.postgresql.org的开发人员部分 (如何进行代码贡献) https://wiki.postgresql.org/wiki/Developer_and_Contributor_Resources3. 新手从这里开始 https://wiki.postgresql.org/wiki/So,_you_want_to_be_a_developer%3F常用VS Code功能内置快捷键参考Windows系统 https://code.visualstudio.com/shortcuts/keyboard-shortcuts-windows.pdfLinux系统 https://code.visualstudio.com/shortcuts/keyboard-shortcuts-linux.pdfMac系统 https://code.visualstudio.com/shortcuts/keyboard-shortcuts-macos.pdf配置自定义快捷键VSCode提供了很多定制功能包括快捷键的定制。注意如果您安装了许多扩展程序或者已经自定义了键盘快捷键则有时会出现键绑定冲突其中相同的键盘快捷键映射到多个命令。 这可能会导致一些奇怪的现象比如当您在编辑器中切换文件时时常会导致进入和超出当前编辑范围的问题 File Preferences Keyboard Shortcuts (Windows) Code Preferences Keyboard Shortcuts (MacOS)结束语本篇日志只是为了让大家对如何使用VS Code开始PG编程有个初步的了解。希望感兴趣的朋友 Enjoy VS Code, Enjoy PostgreSQL developmentPostgreSQL中文社区欢迎广大技术人员投稿投稿邮箱presspostgres.cn