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')
-=-=-=-=-=-=-=-=-=-=-=- Links: You receive all messages sent to this group. View/Reply Online (#195729): https://lists.openembedded.org/g/openembedded-core/message/195729 Mute This Topic: https://lists.openembedded.org/mt/104376747/21656 Group Owner: openembedded-core+ow...@lists.openembedded.org Unsubscribe: https://lists.openembedded.org/g/openembedded-core/unsub [arch...@mail-archive.com] -=-=-=-=-=-=-=-=-=-=-=-