From: Paolo Bonzini <pbonzini@redhat.com>
To: "Philippe Mathieu-Daudé" <philmd@redhat.com>, qemu-devel@nongnu.org
Cc: eesposit@redhat.com
Subject: Re: [PATCH] add Visual Studio Code configuration
Date: Wed, 12 May 2021 20:16:59 +0200 [thread overview]
Message-ID: <786362f4-4881-6bb7-2eaa-a7f876555f9e@redhat.com> (raw)
In-Reply-To: <68f9e434-352d-e98c-9bd1-2fd291d2d9be@redhat.com>
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
prev parent reply other threads:[~2021-05-12 18:22 UTC|newest]
Thread overview: 5+ messages / expand[flat|nested] mbox.gz Atom feed top
2021-05-12 10:09 [PATCH] add Visual Studio Code configuration Paolo Bonzini
2021-05-12 11:02 ` Peter Maydell
2021-05-12 18:29 ` Paolo Bonzini
2021-05-12 11:08 ` Philippe Mathieu-Daudé
2021-05-12 18:16 ` Paolo Bonzini [this message]
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=786362f4-4881-6bb7-2eaa-a7f876555f9e@redhat.com \
--to=pbonzini@redhat.com \
--cc=eesposit@redhat.com \
--cc=philmd@redhat.com \
--cc=qemu-devel@nongnu.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).