zig开发环境配置

环境

vscode

ext install tiehuis.zig
ext install AugusteRame.zls-vscode

创建项目

mkdir demo; cd demo
zig init-exe

交叉编译

zig build -target xxx
zig tatgets

vscode

launch.json

{
  "version": "0.2.0",
  "configurations": [
    {
      "name": "debug",
      "type": "cppdbg",
      "request": "launch",
      "program": "${workspaceFolder}/main",
      "args": [],
      "stopAtEntry": false,
      "cwd": "${workspaceFolder}",
      "environment": [],
      "preLaunchTask": "debug_build",
      "externalConsole": false
    }
  ]
}

tasks.json

{
  "version": "2.0.0",
  "tasks": [
    {
      "label": "debug_build",
      "type": "shell",
      "command": "zig build-exe src/main.zig"
    },
    {
      "label": "release_build",
      "type": "shell",
      "command": "zig build-exe src/main.zig -O ReleaseSmall"
    }
  ]
}
posted @ 2022-12-21 10:01  自由出土文物  阅读(308)  评论(0编辑  收藏  举报