🍩 A XMake integration in Visual Studio Code #vscode
|
|
3 weeks ago | |
|---|---|---|
| .github | 1 month ago | |
| .vscode | 3 years ago | |
| assets | 1 month ago | |
| languages | 8 years ago | |
| res | 1 month ago | |
| src | 3 weeks ago | |
| test | 1 month ago | |
| .gitignore | 8 years ago | |
| .vscodeignore | 8 years ago | |
| CHANGELOG.md | 1 month ago | |
| CONTRIBUTING.md | 7 years ago | |
| LICENSE | 8 years ago | |
| README.md | 1 month ago | |
| package-lock.json | 3 weeks ago | |
| package.json | 3 weeks ago | |
| package.sh | 1 month ago | |
| publish.sh | 1 month ago | |
| tsconfig.json | 1 month ago | |
| vsc-extension-quickstart.md | 8 years ago | |
| yarn.lock | 2 years ago |
A XMake integration in Visual Studio Code.
You need install xmake first and a project with xmake.lua.
Please see xmake-github and website if you want to know more about xmake.
xmake.lua files







xmake-vscode will generate .vscode/compile_commands.json file, so you need only add it to .vscode/c_cpp_properties.json to enable IntelliSense.
The extension provides three modes for automatic generation of compile_commands.json:
You can configure this in VSCode settings with xmake.autoGenerateCompileCommands.
for example (.vscode/c_cpp_properties.json):
{
"configurations": [
{
"compileCommands": ".vscode/compile_commands.json"
}
],
"version": 4
}
These configuration settings are stored in your project's c_cpp_properties.json file. To edit this file, in VS Code, select C/C++: Edit Configurations (UI) from the Command Palette (⇧⌘P):
Please see IntelliSense for cross-compiling
Debug via launch configurations (launch.json) is accessible only with Run->Start Debugging (not F5 keybinding) or via Launch Debug command.
| attribute | type | |
|---|---|---|
| name | string | Required. Launch configuration name, as you want it to appear in the Run and Debug panel. |
| type | string | Required. Set to xmake. |
| request | string | Required. Session initiation method:launch or attach. |
| target | string | Required. XMake target. |
| env | object | Additional environment variables. {"PATH" : "some/path"} |
| args | string ❘ [string] | Command line parameters. If not defined args are taken from debuggingTargetsArguments config. |
| cwd | string | If not defined xmake will use the target directory. |
| stopAtEntry | boolean | If set to true, the debugger should stop at the entry-point of the target (ignored on attach). Default value is false. |
| terminal | string | Destination of stdio streams:
|
Example:
{
"configurations": [
{
"name": "XMake Debug",
"type": "xmake",
"request": "launch",
"target": "example",
"stopAtEntry": true
}
]
}
You can choose the debugger extension with xmake.debugConfigType, set it to:
default for cpptools debuggercodelldb for lldb debuggerYou can choose the behaviour between xmake envs and envs that are defined in launch.json
For an xmake envs that are like this {"PATH: "path/from/xmake"} and in launch.json
{"PATH": "path/from/config"}.
Default is merge.
xmake.envBehaviour set to merge, the result is: {"PATH": "path/from/xmake;path/from/config"}.xmake.envBehaviour set to erase, the result is: {"PATH": "path/from/xmake"}xmake.envBehaviour set to override, the result is: {"PATH": "path/from/config"}.XMake envs will only be replaced for the same key, if another xmake env key is present, it will be present in the final result.
We can configure them in settings.json
{
"xmake.executable": "xmake",
"xmake.logLevel": "normal",
"xmake.buildLevel": "normal",
"xmake.buildDirectory": "${workspaceRoot}/build",
"xmake.workingDirectory": "${workspaceRoot}"
}
{
"xmake.executable": "xmake",
"xmake.logLevel": "normal",
"xmake.buildLevel": "normal",
"xmake.buildDirectory": "${workspaceRoot}/build",
"xmake.installDirectory": "",
"xmake.packageDirectory": "",
"xmake.workingDirectory": "${workspaceRoot}",
"xmake.androidNDKDirectory": "",
"xmake.QtDirectory": "",
"xmake.WDKDirectory": "",
"xmake.compileCommandsDirectory": ".vscode",
"xmake.compileCommandsBackend": "clangd",
"xmake.additionalConfigArguments": [],
"xmake.runningTargetsArguments": {
"default": []
},
"xmake.debuggingTargetsArguments": {
"default": []
},
"xmake.debugConfigType": "default",
"xmake.customDebugConfig": {},
"xmake.envBehaviour": "merge",
"xmake.enableSyntaxCheck": true,
"xmake.runMode": "runOnly"
}
Control which buttons appear in the status bar:
{
"xmake.status.showProject": false,
"xmake.status.showXMake": true,
"xmake.status.showPlatform": false,
"xmake.status.showArch": false,
"xmake.status.showMode": false,
"xmake.status.showToolchain": false,
"xmake.status.showTarget": false,
"xmake.status.showBuild": true,
"xmake.status.showRun": true,
"xmake.status.showDebug": true
}
| Option | Type | Default | Description |
|---|---|---|---|
| xmake.executable | string | "xmake" | The xmake executable name / path |
| xmake.logLevel | string | "normal" | Log Level: verbose, normal, minimal |
| xmake.buildLevel | string | "normal" | Build Output Level: verbose, normal, debug |
| xmake.runMode | string | "runOnly" | Run Mode: runOnly, buildRun |
| xmake.buildDirectory | string | "${workspaceRoot}/build" | Build Output Directory |
| xmake.installDirectory | string | "" | Install Output Directory |
| xmake.packageDirectory | string | "" | Package Output Directory |
| xmake.workingDirectory | string | "${workspaceRoot}" | Project Working Directory |
| xmake.androidNDKDirectory | string | "" | Android NDK Directory |
| xmake.QtDirectory | string | "" | Qt Directory |
| xmake.WDKDirectory | string | "" | Windows Driver Kit Directory |
| xmake.compileCommandsDirectory | string | ".vscode" | compile_commands.json file directory |
| xmake.compileCommandsBackend | string | "clangd" | LSP backend for compile_commands |
| xmake.autoGenerateCompileCommands | string | "onFileChange" | Automatic generation mode: onFileChange, onBuild, disabled |
| xmake.additionalConfigArguments | array | [] | Additional config arguments, e.g. ["--cc=gcc", "--myopt=xxx"] |
| xmake.runningTargetsArguments | object | {"default": []} | Running targets arguments, e.g. {"targetName": ["args", "..."]} |
| xmake.debuggingTargetsArguments | object | {"default": []} | Debugging targets arguments |
| xmake.debugConfigType | string | "default" | Debug configuration type: default, codelldb, lldb-dap, gdb-dap |
| xmake.customDebugConfig | object | {} | Custom debugging configurations |
| xmake.envBehaviour | string | "merge" | Environment behaviour: erase, merge, override |
| xmake.enableSyntaxCheck | boolean | true | Enable Lua syntax check |
The extension provides a dedicated XMake Explorer in the Activity Bar for project management.
Access all XMake commands through the Command Palette (Ctrl+Shift+P or Cmd+Shift+P):
The extension supports VS Code tasks for XMake operations. Create a .vscode/tasks.json file:
{
"version": "2.0.0",
"tasks": [
{
"label": "XMake: Build",
"type": "xmake",
"task": "build",
"problemMatcher": ["$gcc"],
"group": {
"kind": "build",
"isDefault": true
}
},
{
"label": "XMake: Clean",
"type": "xmake",
"task": "clean",
"problemMatcher": []
},
{
"label": "XMake: Run",
"type": "xmake",
"task": "run",
"problemMatcher": []
}
]
}
build: Build the projectclean: Clean build artifactsrun: Run the targetpackage: Package the projectinstall: Install the projectconfigure: Configure the projectThe extension provides the following default key bindings:
| Key | Command | Description |
|---|---|---|
F5 |
xmake.onDebug |
Start debugging (when xmake is enabled) |
You can customize these key bindings in VS Code preferences.
The extension supports platform-specific configuration. You can use platform prefixes in your settings:
{
"xmake.executable": "xmake",
"windows.xmake.executable": "xmake.exe",
"linux.xmake.executable": "/usr/bin/xmake",
"osx.xmake.executable": "/usr/local/bin/xmake"
}
Supported platform prefixes:
windows for Windowslinux for Linuxosx for macOSXMake not found
xmake.executable setting to specify the full path to xmake executableIntelliSense not working
xmake.autoGenerateCompileCommands setting:
onFileChange to generate when xmake.lua changesonBuild to generate after buildingdisabled and use XMake: UpdateIntellisense command manuallyXMake: UpdateIntellisense command to generate compile_commands.json manually.vscode/c_cpp_properties.json references the correct compile commands fileDebugging not working
launch.json configuration has the correct target nameBuild fails
xmake.lua configuration is correctContributions are welcome! Please see CONTRIBUTING.md for guidelines.
This project is licensed under the Apache License 2.0 - see the LICENSE file for details.
If you find this extension helpful, consider supporting the project: