qemu-devel
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [PATCH] add Visual Studio Code configuration


From: Paolo Bonzini
Subject: Re: [PATCH] add Visual Studio Code configuration
Date: Wed, 12 May 2021 20:16:59 +0200
User-agent: Mozilla/5.0 (X11; Linux x86_64; rv:78.0) Gecko/20100101 Thunderbird/78.8.1

On 12/05/21 13:08, Philippe Mathieu-Daudé wrote:
--- /dev/null
+++ b/.vscode/c_cpp_properties.json
@@ -0,0 +1,13 @@
+{
+    "configurations": [
+        {
+            "name": "qemu",
+            "includePath": [ "${default}", "${workspaceFolder}/linux-headers/**", 
"${workspaceFolder}/include/**", "${workspaceFolder}/+build/**"],

Not sure about +build... This produces:

Oops, should be ${workspaceFolder}/${config:mesonbuild.buildFolder}/**.

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",

When opening .json I get many:

"true" is not defined (Pylance reportUndefinedVariable)
"false" is not defined (Pylance reportUndefinedVariable)

I'll remove this then.

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

Typo "target"

+# 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'])


I got these warnings:

[5/12/2021, 12:24:04 PM]
"${workspaceFolder}/builddir/compile_commands.json" could not be found.
'includePath' from c_cpp_properties.json in folder 'qemu' will be used
instead.

"builddir" must be your mesonbuild.buildFolder. You must first run "configure" manually in that directory (or adjust the configuration of the Meson extension if that's what you prefer).

Once you do that, Ctrl+Shift+B works.

Paolo




reply via email to

[Prev in Thread] Current Thread [Next in Thread]