[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[PATCH] add Visual Studio Code configuration
From: |
Paolo Bonzini |
Subject: |
[PATCH] add Visual Studio Code configuration |
Date: |
Wed, 12 May 2021 06:09:06 -0400 |
Add configurations to build files with Visual Studio Code and
to retrieve the search path for headers from the compile_commands.json
file.
Using this configuration requires installing the Meson extension and
using a build subdirectory that matches the one configured in the
Meson extension itself.
Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
---
.vscode/c_cpp_properties.json | 13 +++++++++++++
.vscode/settings.json | 11 +++++++++++
.vscode/tasks.json | 23 +++++++++++++++++++++++
scripts/rebuild.py | 22 ++++++++++++++++++++++
4 files changed, 69 insertions(+)
create mode 100644 .vscode/c_cpp_properties.json
create mode 100644 .vscode/settings.json
create mode 100644 .vscode/tasks.json
create mode 100755 scripts/rebuild.py
diff --git a/.vscode/c_cpp_properties.json b/.vscode/c_cpp_properties.json
new file mode 100644
index 0000000000..43f5fc1b4d
--- /dev/null
+++ b/.vscode/c_cpp_properties.json
@@ -0,0 +1,13 @@
+{
+ "configurations": [
+ {
+ "name": "qemu",
+ "includePath": [ "${default}",
"${workspaceFolder}/linux-headers/**", "${workspaceFolder}/include/**",
"${workspaceFolder}/+build/**"],
+ "compileCommands":
"${workspaceFolder}/${config:mesonbuild.buildFolder}/compile_commands.json",
+ "intelliSenseMode": "linux-gcc-x64",
+ "cStandard": "c11",
+ "cppStandard": "c++14"
+ }
+ ],
+ "version": 4
+}
diff --git a/.vscode/settings.json b/.vscode/settings.json
new file mode 100644
index 0000000000..efbbb4f88b
--- /dev/null
+++ b/.vscode/settings.json
@@ -0,0 +1,11 @@
+{
+ "files.associations": {
+ "*.mak": "makefile",
+ "*.c.inc": "c",
+ "*.h.inc": "c",
+ "*.json": "python",
+ "*.rst.inc": "restructuredtext",
+ "*.vert": "glsl",
+ "*.frag": "glsl"
+ }
+}
diff --git a/.vscode/tasks.json b/.vscode/tasks.json
new file mode 100644
index 0000000000..362821043e
--- /dev/null
+++ b/.vscode/tasks.json
@@ -0,0 +1,23 @@
+{
+ "version": "2.0.0",
+ "tasks": [
+ {
+ "type": "cppbuild",
+ "label": "C/C++: build active file with
compile_commands.json",
+ "command": "python3",
+ "args": [
+ "${workspaceFolder}/scripts/rebuild.py",
"${file}"
+ ],
+ "options": {
+ "cwd":
"${workspaceFolder}/${config:mesonbuild.buildFolder}"
+ },
+ "problemMatcher": [
+ "$gcc"
+ ],
+ "group": {
+ "kind": "build",
+ "isDefault": true
+ }
+ }
+ ]
+}
diff --git a/scripts/rebuild.py b/scripts/rebuild.py
new file mode 100755
index 0000000000..e35e08f42d
--- /dev/null
+++ b/scripts/rebuild.py
@@ -0,0 +1,22 @@
+#! /usr/bin/env python3
+#
+# Author: Paolo Bonzini <pbonzini@redhat.com>
+#
+# This program compiles the input files using commands from the
+# compile_commands.json file. (Unlike Make/ninja, the _source_
+# file is passed to the program rather than the targe). It is
+# mostly intended to be called from editors.
+
+import os
+import sys
+import json
+
+with open('compile_commands.json') as f:
+ cc_json = json.load(f)
+
+paths = set((os.path.relpath(i) for i in sys.argv[1:]))
+for i in cc_json:
+ if i['file'] in paths:
+ os.chdir(i['directory'])
+ print(i['command'])
+ os.system(i['command'])
--
2.26.2
- [PATCH] add Visual Studio Code configuration,
Paolo Bonzini <=