Re: [PATCH v2 5/5] devtool: code: Provide a generic C++ configuration

Enguerrand de Ribaucourt
2024-02-20T09:27:44Z

Hi Adrian,

Thanks for your review.

Yes it doesn't makes a lot of sense to keep this patch compared to the
specific support you are working on. It was especially useful for
recipes using plain oe_runmake or CC/CXX outside of a class. But we
can't distinguish these recipes from others classes like python/bash
that would not make use of this C++ configuration.

I'll drop this patch and try to figure out if I can also fix the
debugging configuration without a source map (PATH v2 3/5). It would
rather indicate that the wrong binary is being deployed for some workspaces.

On 20/02/2024 10:20, adrian.freihofer@gmail.com wrote:
> Hi Enguerrand
>
> I would really like to stay on the path with tests. This patch changes
> code which is covered by tests without tests. Lets develop the
> autotools support as a separate patch series.
>
> There are three parts needed:
> - Extend the cpp-example with autotools support (already on my branch)
> - What your patch does
> - Extend the oe-selftest suite to cover also the autotools support.
>
> On Mon, 2024-02-19 at 17:55 +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.
>>
>> Recipes which use C/C++ without a build system are not covered by
>> this
>> patch.
>>
>> Signed-off-by: Enguerrand de Ribaucourt
>> <enguerrand.de-ribaucourt@savoirfairelinux.com>
>> ---
>>  scripts/lib/devtool/ide_plugins/__init__.py |  3 +++
>>  scripts/lib/devtool/ide_plugins/ide_code.py | 27 +++++++++++++------
>> --
>>  scripts/lib/devtool/ide_sdk.py              |  5 ++++
>>  3 files changed, 25 insertions(+), 10 deletions(-)
>>
>> diff --git a/scripts/lib/devtool/ide_plugins/__init__.py
>> b/scripts/lib/devtool/ide_plugins/__init__.py
>> index 3371b242640..59e90663908 100644
>> --- a/scripts/lib/devtool/ide_plugins/__init__.py
>> +++ b/scripts/lib/devtool/ide_plugins/__init__.py
>> @@ -21,6 +21,7 @@ class BuildTool(Enum):
>>      UNDEFINED = auto()
>>      CMAKE = auto()
>>      MESON = auto()
>> +    AUTOTOOLS = auto()
>>
>>      @property
>>      def is_c_ccp(self):
>> @@ -28,6 +29,8 @@ class BuildTool(Enum):
>>              return True
>>          if self is BuildTool.MESON:
>>              return True
>> +        if self is BuildTool.AUTOTOOLS:
>> +            return True
>>          return False
>>
>>
>> diff --git a/scripts/lib/devtool/ide_plugins/ide_code.py
>> b/scripts/lib/devtool/ide_plugins/ide_code.py
>> index 7b683c74086..0942fde8196 100644
>> --- a/scripts/lib/devtool/ide_plugins/ide_code.py
>> +++ b/scripts/lib/devtool/ide_plugins/ide_code.py
>> @@ -157,31 +157,35 @@ class IdeVSCode(IdeBase):
>>          IdeBase.update_json_file(
>>              self.dot_code_dir(modified_recipe), settings_file,
>> settings_dict)
>>
>> -    def __vscode_extensions_cmake(self, modified_recipe,
>> recommendations):
>> -        if modified_recipe.build_tool is not BuildTool.CMAKE:
>> +    def __vscode_extensions_generic(self, modified_recipe,
>> recommendations):
>> +        if not modified_recipe.build_tool.is_c_ccp:
>>              return
>>          recommendations += [
>> -            "twxs.cmake",
>> -            "ms-vscode.cmake-tools",
>>              "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"
>> +        ]
>> +
>>      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 +198,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
>
> else return is still required.
>
> Adrian
>
>
>> +        elif modified_recipe.build_tool.is_c_ccp:
>> +            # 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 f292edbe25c..6313daa8700 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')
>> @@ -380,6 +383,8 @@ class RecipeModified:
>>              self.extra_oemeson = recipe_d.getVar('EXTRA_OEMESON')
>>              self.meson_cross_file =
>> recipe_d.getVar('MESON_CROSS_FILE')
>>              self.build_tool = BuildTool.MESON
>> +        elif bb.data.inherits_class('autotools', recipe_d):
>> +            self.build_tool = BuildTool.AUTOTOOLS
>>
>>          # Recipe ID is the identifier for IDE config sections
>>          self.recipe_id = self.bpn + "-" + self.package_arch
>

--
Savoir-faire Linux
Enguerrand de Ribaucourt
Consultant en logiciel libre / Ingénieur systèmes embarqués | Rennes, Fr
Bureau
(+33) 9 72 46 89 80 (606#)
Site web <https://www.savoirfairelinux.com/> | Blog
<https://blog.savoirfairelinux.com/fr-ca/> | Jami <https://jami.net/>

Messages de confidentialité : Ce courriel (de même que les fichiers
joints) est strictement réservé à l'usage de la personne ou de l'entité
à qui il est adressé et peut contenir de l'information privilégiée et
confidentielle. Toute divulgation, distribution ou copie de ce courriel
est strictement prohibée. Si vous avez reçu ce courriel par erreur,
veuillez nous en aviser sur-le-champ, détruire toutes les copies et le
supprimer de votre système informatique.