Hi Karlo

On Sat, 2024-11-02 at 09:13 -0700, Karlo Strize via
lists.yoctoproject.org wrote:
> Hi Adrian,
>  
> I started to work on codium ide plugin.
Cool!

> I have tested it with cmake projects and it works as expected.
Yes, that's because cmake and also meson have the compile_commands.json
generator built in. With meson it's enabled by default, with cmake we
enable this feature
here: https://git.yoctoproject.org/poky/tree/meta/classes-
recipe/cmake.bbclass#n185.

> Then I have tried devtool fallback projects (like u-boot) and I have
> a problem that devtool does the project build without me inserting
> bear tool command.
> I use bear tool for clangd indexing.

I did not use bear yet. As far as I understand, bear collects the
detailed information how the compiler gets called by replacing the real
compiler with a wrapper. Then the wrapper can write the command line
arguments into the compile_commands.json and finally call the compiler.
While this looks like a generic approach which can work for all kind of
build tools, I think that wrapping the compiler is also a bit clunky
and can lead to very tedious issues. Therefore I would prefer a
solution where the build tool has built-in support for generating the
compile_commands.json as we have it with cmake and meson.

For the kernel and the u-boot recipes that seams to be possible:
 * 
https://github.com/torvalds/linux/blob/master/scripts/clang-tools/gen_compile_commands.py
 * https://github.com/u-boot/u-boot/blob/master/scripts/gen_compile_commands.py
   That looks like we can use these scripts which are available as make
   targets out of the box.

Did you already look at these scripts and understand how they work? I'm
not sure if they work only if clang is used to build the kernel. That
would be an issue for now. But clang will probably make it into oe-core
until next release. That would also allow to improve the kernel scripts
to support clang as a kernel compiler as well.

If the kernel recipes support creating the compile database the devtool
ide-sdk fallback mode should provide what you are expecting. This can
be a first step.

But handling recipes with the ide-sdk fallback mode is not ideal.
Handling the recipes in a build-tool specific way leads to a much
better user experience. To add support for recipes using the kbuild
framework (u-boot, kernel) we could:
 * Add another elif case for them to this
   if: https://git.yoctoproject.org/poky/tree/scripts/lib/devtool/ide_s
   dk.py#n377.
   elif bb.data.inherits_class('cml1', recipe_d):
   Then these recipes are no longer handled by the fallback mode of
   ide-sdk
 * Then we can recommend a Makefile vscode plugin
   like 
https://marketplace.visualstudio.com/items?itemName=ms-vscode.makefile-tools
    or something more open source if you like.
   Having a plugin like that allows to configure the plugin for cross-
   compilation with Yocto's tool-chain.
   Alternative we could generate some task which call make with the
   right configuration. But this is usually a bit clunky as well.


For the kernel but also in general it would probably also be very
useful to have a devshell like terminal configuration available in
VSCode. I need to think about this and probably discuss it with the
VSCode experts who develop
https://marketplace.visualstudio.com/items?itemName=yocto-project.yocto-bitbake


Regards,
Adrian





> When I try to run a build task that has already bear tool command
> inserted in tasks.json (because of the ide_codium.py), the indexation
> doesn't work because the build isn't run (its already cached).
> I can get around ti by calling clean task or by calling devtool ide-
> sdk with --skip-bitbake flag.
> I didn't like this extra step so I tried to do some hacking in
> ide_sdk.py.
> I know that ide_sdk.py should be IDE agnostic and not have "if
> codium" statements, but I just wanted to do some quick and dirty work
> to achieve the necessary index functionality.
> I have managed to get the indexation working because of the bear tool
> command insertion in bb_cmd variable, but do_package task breaks.
> If I remove all the code related to the "if codium", the do_package
> finishes successfully.
> Can you give me some inputs where my hacking code is breaking the
> do_package task?
> In attachment is my current work in progress patch and the do_package
> log.
>  
> Best regards,
> Karlo Strize
> 
> 
> 

-=-=-=-=-=-=-=-=-=-=-=-
Links: You receive all messages sent to this group.
View/Reply Online (#64204): https://lists.yoctoproject.org/g/yocto/message/64204
Mute This Topic: https://lists.yoctoproject.org/mt/109085158/21656
Mute #github:https://lists.yoctoproject.org/g/yocto/mutehashtag/github
Group Owner: yocto+ow...@lists.yoctoproject.org
Unsubscribe: https://lists.yoctoproject.org/g/yocto/unsub 
[arch...@mail-archive.com]
-=-=-=-=-=-=-=-=-=-=-=-

Reply via email to