public inbox for openembedded-core@lists.openembedded.org
 help / color / mirror / Atom feed
From: adrian.freihofer@gmail.com
To: Enguerrand de Ribaucourt
	<enguerrand.de-ribaucourt@savoirfairelinux.com>,
	 openembedded-core@lists.openembedded.org
Subject: Re: [PATCH 6/6] devtool: code: Provide a generic C++ configuration
Date: Fri, 16 Feb 2024 00:15:57 +0100	[thread overview]
Message-ID: <f7c4c010962369b7199921c975792a658bd8c439.camel@gmail.com> (raw)
In-Reply-To: <20240215170422.659073-7-enguerrand.de-ribaucourt@savoirfairelinux.com>

On Thu, 2024-02-15 at 18:04 +0100, Enguerrand de Ribaucourt wrote:
> By default, the cpptools VSCode extension will use the host's headers
> and flags for linting. This results in a lot of include errors and
> misleading definitions. Even though this generic configuration
> doesn't
> include all the depenendencies, it is a proper fallback for recipe
> classes we do not accurately cover, with at least the right sysroot.
> 
> Additionally, ide-sdk automatically detects and provides a
> launch.json
> configuration for autotools recipes so we should recommend the C++
> extensions for them.
> 
> If the recipe is of another class (like Python), then the
> configuration
> will be generated but probably useless to the user. We'd need a
> mecanism
> to know if the recipe contains C/C++ but I'm not aware of any
> class-agnostic way to do it.
> ---
>  scripts/lib/devtool/ide_plugins/ide_code.py | 25 ++++++++++++-------
> --
>  scripts/lib/devtool/ide_sdk.py              |  3 +++
>  2 files changed, 18 insertions(+), 10 deletions(-)
> 
> diff --git a/scripts/lib/devtool/ide_plugins/ide_code.py
> b/scripts/lib/devtool/ide_plugins/ide_code.py
> index 7b683c74086..51cf2c8a736 100644
> --- a/scripts/lib/devtool/ide_plugins/ide_code.py
> +++ b/scripts/lib/devtool/ide_plugins/ide_code.py
> @@ -157,31 +157,33 @@ class IdeVSCode(IdeBase):
>          IdeBase.update_json_file(
>              self.dot_code_dir(modified_recipe), settings_file,
> settings_dict)
>  
> +    def __vscode_extensions_generic(self, modified_recipe,
> recommendations):
Here is a condition needed. This is only valid for some C/C++ recipes.
But now these extensions are also installed e.g. for Rust, Go, Python
which is wrong.

> +        recommendations += [
> +            "ms-vscode.cpptools",
> +            "ms-vscode.cpptools-extension-pack",
> +            "ms-vscode.cpptools-themes"
> +        ]
> +
>      def __vscode_extensions_cmake(self, modified_recipe,
> recommendations):
>          if modified_recipe.build_tool is not BuildTool.CMAKE:
>              return
>          recommendations += [
>              "twxs.cmake",
> -            "ms-vscode.cmake-tools",
> -            "ms-vscode.cpptools",
> -            "ms-vscode.cpptools-extension-pack",
> -            "ms-vscode.cpptools-themes"
> +            "ms-vscode.cmake-tools"
>          ]
>  
>      def __vscode_extensions_meson(self, modified_recipe,
> recommendations):
>          if modified_recipe.build_tool is not BuildTool.MESON:
>              return
>          recommendations += [
> -            'mesonbuild.mesonbuild',
> -            "ms-vscode.cpptools",
> -            "ms-vscode.cpptools-extension-pack",
> -            "ms-vscode.cpptools-themes"
> +            'mesonbuild.mesonbuild'
>          ]
>  
>      def vscode_extensions(self, modified_recipe):
>          recommendations = []
>          self.__vscode_extensions_cmake(modified_recipe,
> recommendations)
>          self.__vscode_extensions_meson(modified_recipe,
> recommendations)
> +        self.__vscode_extensions_generic(modified_recipe,
> recommendations)
>          extensions_file = 'extensions.json'
>          IdeBase.update_json_file(
>              self.dot_code_dir(modified_recipe), extensions_file,
> {"recommendations": recommendations})
> @@ -194,8 +196,11 @@ class IdeVSCode(IdeBase):
>              properties_dict["configurationProvider"] = "ms-
> vscode.cmake-tools"
>          elif modified_recipe.build_tool is BuildTool.MESON:
>              properties_dict["configurationProvider"] =
> "mesonbuild.mesonbuild"
> -        else:  # no C/C++ build
> -            return
Same issue as above: There are many recipes were a C/C++ compiler
configuration is wrong. As a next step we might add e.g.
  elif autotools
    ...
  else
    return
but we cannot add a general else statement here.

> +        else:  
> +            # Provide a generic linting configuration
> +            # We provide a C++ configuration with the proper sysroot
> +            properties_dict["compilerPath"] =
> os.path.join(modified_recipe.staging_bindir_toolchain,
> modified_recipe.cxx.split()[0])
> +            properties_dict["compilerArgs"] =
> modified_recipe.cxx.split()[1:]
>  
>          properties_dicts = {
>              "configurations": [
> diff --git a/scripts/lib/devtool/ide_sdk.py
> b/scripts/lib/devtool/ide_sdk.py
> index 1e36f2b2093..c82b150a83e 100755
> --- a/scripts/lib/devtool/ide_sdk.py
> +++ b/scripts/lib/devtool/ide_sdk.py
> @@ -345,6 +345,7 @@ class RecipeModified:
>          self.base_libdir = recipe_d.getVar('base_libdir')
>          self.bblayers = recipe_d.getVar('BBLAYERS').split()
>          self.bpn = recipe_d.getVar('BPN')
> +        self.cxx = recipe_d.getVar('CXX')
>          self.d = recipe_d.getVar('D')
>          self.fakerootcmd = recipe_d.getVar('FAKEROOTCMD')
>          self.fakerootenv = recipe_d.getVar('FAKEROOTENV')
> @@ -361,6 +362,8 @@ class RecipeModified:
>              recipe_d.getVar('RECIPE_SYSROOT'))
>          self.recipe_sysroot_native = os.path.realpath(
>              recipe_d.getVar('RECIPE_SYSROOT_NATIVE'))
> +        self.staging_bindir_toolchain = os.path.realpath(
> +            recipe_d.getVar('STAGING_BINDIR_TOOLCHAIN'))
>          self.staging_incdir = os.path.realpath(
>              recipe_d.getVar('STAGING_INCDIR'))
>          self.strip_cmd = recipe_d.getVar('STRIP')


  reply	other threads:[~2024-02-15 23:16 UTC|newest]

Thread overview: 12+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2024-02-15 17:04 [PATCH 0/6] devtool: ide: Improve VSCode support Enguerrand de Ribaucourt
2024-02-15 17:04 ` [PATCH 1/6] devtool: ide: Fix topdir exception for fallback mode Enguerrand de Ribaucourt
2024-02-15 23:02   ` adrian.freihofer
2024-02-15 17:04 ` [PATCH 2/6] devtool: ide_sdk: Use bitbake's python3 for generated scripts Enguerrand de Ribaucourt
2024-02-15 17:04 ` [PATCH 3/6] devtool: code: Add source mapping for debug source files Enguerrand de Ribaucourt
2024-02-15 23:21   ` adrian.freihofer
2024-02-15 17:04 ` [PATCH 4/6] devtool: ide: vscode: Configure read-only files Enguerrand de Ribaucourt
2024-02-15 17:04 ` [PATCH 5/6] meson: use absolute cross-compiler paths Enguerrand de Ribaucourt
2024-02-15 17:04 ` [PATCH 6/6] devtool: code: Provide a generic C++ configuration Enguerrand de Ribaucourt
2024-02-15 23:15   ` adrian.freihofer [this message]
2024-02-15 17:11 ` [OE-core] [PATCH 0/6] devtool: ide: Improve VSCode support Richard Purdie
2024-02-15 22:38   ` Peter Kjellerstedt

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=f7c4c010962369b7199921c975792a658bd8c439.camel@gmail.com \
    --to=adrian.freihofer@gmail.com \
    --cc=enguerrand.de-ribaucourt@savoirfairelinux.com \
    --cc=openembedded-core@lists.openembedded.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