diff options
author | Adrian Freihofer <adrian.freihofer@gmail.com> | 2025-01-20 08:16:19 +0100 |
---|---|---|
committer | Richard Purdie <richard.purdie@linuxfoundation.org> | 2025-01-29 10:41:59 +0000 |
commit | 5a38f96a33d75a120dba4f2e6157189a140ccb38 (patch) | |
tree | 64a31887f474d24eb93fa0c1cd0e8032e24a027a | |
parent | 2a8ea9790c30ec426110bbb06e41c7c02267af1b (diff) | |
download | poky-5a38f96a33d75a120dba4f2e6157189a140ccb38.tar.gz |
sdk-manual: extensible.rst: devtool ide-sdk improve
The devtool ide-sdk section is reformulated to be independent of the
eSDK installer. In fact, ide-sdk does not even support the execution
of an installer-based setup.
This reformulation is also a preparation for moving the devtool
documentation to a dedicated devtool section which is independent from
the eSDK documentation.
It should be clarified that devtool ide-sdk starts the SDK directly
from the bitbake environment. It is therefore an alternative to
bitbake -c populate_sdk_ext and installing an SDK installer.
A warning is added that explains some workarounds for some nasty
behavior of VSCode when running it in a bitbake environment.
(From yocto-docs rev: 287817f33688d61f7a71c056bfa5c645edb4fc4e)
Signed-off-by: Adrian Freihofer <adrian.freihofer@siemens.com>
Reviewed-by: Antonin Godard <antonin.godard@bootlin.com>
Signed-off-by: Antonin Godard <antonin.godard@bootlin.com>
Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org>
-rw-r--r-- | documentation/sdk-manual/extensible.rst | 210 |
1 files changed, 151 insertions, 59 deletions
diff --git a/documentation/sdk-manual/extensible.rst b/documentation/sdk-manual/extensible.rst index 1cb1bb47c2..8483951bef 100644 --- a/documentation/sdk-manual/extensible.rst +++ b/documentation/sdk-manual/extensible.rst | |||
@@ -178,7 +178,7 @@ Running the Extensible SDK Environment Setup Script | |||
178 | Once you have the SDK installed, you must run the SDK environment setup | 178 | Once you have the SDK installed, you must run the SDK environment setup |
179 | script before you can actually use the SDK. | 179 | script before you can actually use the SDK. |
180 | 180 | ||
181 | When using a SDK directly in a Yocto build, you will find the script in | 181 | When using an SDK directly in a Yocto build, you will find the script in |
182 | ``tmp/deploy/images/qemux86-64/`` in your :term:`Build Directory`. | 182 | ``tmp/deploy/images/qemux86-64/`` in your :term:`Build Directory`. |
183 | 183 | ||
184 | When using a standalone SDK installer, this setup script resides in | 184 | When using a standalone SDK installer, this setup script resides in |
@@ -622,28 +622,91 @@ command: | |||
622 | decide you do not want to proceed with your work. If you do use this | 622 | decide you do not want to proceed with your work. If you do use this |
623 | command, realize that the source tree is preserved. | 623 | command, realize that the source tree is preserved. |
624 | 624 | ||
625 | ``devtool ide-sdk`` configures IDEs for the extensible SDK | 625 | ``devtool ide-sdk`` configures IDEs and bootstraps SDKs |
626 | ---------------------------------------------------------- | 626 | ------------------------------------------------------- |
627 | 627 | ||
628 | ``devtool ide-sdk`` automatically configures IDEs to use the extensible SDK. | 628 | The ``devtool ide-sdk`` command can provide an IDE configuration for IDEs when |
629 | To make sure that all parts of the extensible SDK required by the generated | 629 | working on the source code of one or more recipes. |
630 | IDE configuration are available, ``devtool ide-sdk`` uses BitBake in the | 630 | Depending on the programming language, and the build system used by the recipe, |
631 | background to bootstrap the extensible SDK. | 631 | the tools required for cross-development and remote debugging are different. |
632 | For example: | ||
632 | 633 | ||
633 | The extensible SDK supports two different development modes. | 634 | - A C/C++ project usually uses CMake or Meson. |
634 | ``devtool ide-sdk`` supports both of them: | ||
635 | 635 | ||
636 | #. *Modified mode*: | 636 | - A Python project uses setuptools or one of its successors. |
637 | |||
638 | - A Rust project uses Cargo. | ||
639 | |||
640 | Also, the IDE plugins needed for the integration of a build system with the | ||
641 | IDE and the corresponding settings are usually specific to these build-systems. | ||
642 | To hide all these details from the user, ``devtool ide-sdk`` does two things: | ||
643 | |||
644 | - It generates any kind of SDK needed for cross-development and remote | ||
645 | debugging of the specified recipes. | ||
646 | |||
647 | - It generates the configuration for the IDE (and the IDE plugins) for using | ||
648 | the cross-toolchain and remote debugging tools provided by the SDK directly | ||
649 | from the IDE. | ||
650 | |||
651 | For supported build systems the configurations generated by ``devtool ide-sdk`` | ||
652 | combine the advantages of the ``devtool modify`` based workflow | ||
653 | (see :ref:`using_devtool`) with the advantages of the simple Environment Setup | ||
654 | script based workflow (see :ref:`running_the_ext_sdk_env`) provided by Yocto's | ||
655 | SDK or eSDK: | ||
656 | |||
657 | - The source code of the recipe is in the workspace created by | ||
658 | ``devtool modify`` or ``devtool add``. | ||
659 | Using ``devtool build``, ``devtool build-image``, | ||
660 | ``devtool deploy-target`` or ``bitbake`` is possible. | ||
661 | Also ``devtool ide-sdk`` can be used to update the SDK and the IDE | ||
662 | configuration at any time. | ||
637 | 663 | ||
638 | By default ``devtool ide-sdk`` generates IDE configurations for recipes in | 664 | - ``devtool ide-sdk`` aims to support multiple programming languages and |
639 | workspaces created by ``devtool modify`` or ``devtool add`` as described in | 665 | multiple IDEs natively. "Natively" means that the IDE is configured to call |
640 | :ref:`using_devtool`. This mode creates IDE configurations with support for | 666 | the build tool (e.g. ``cmake`` or ``meson``) directly. This has several |
641 | advanced features, such as deploying the binaries to the remote target | 667 | advantages. |
642 | device and performing remote debugging sessions. The generated IDE | 668 | First of all, it is usually much faster to call for example ``cmake`` than |
643 | configurations use the per recipe sysroots as Bitbake does internally. | 669 | ``devtool build``. |
670 | It also allows to benefit from the very good integration that IDEs like | ||
671 | VSCode offer for tools like CMake or GDB. | ||
672 | |||
673 | However, supporting many programming languages and multiple | ||
674 | IDEs is quite an elaborate and constantly evolving thing. Support for IDEs | ||
675 | is therefore implemented as plugins. Plugins can also be provided by | ||
676 | optional layers. | ||
644 | 677 | ||
645 | In order to use the tool, a few settings are needed. As a starting example, | 678 | So much about the introduction to the default mode of ``devtool sdk-ide`` which |
646 | the following lines of code can be added to the ``local.conf`` file:: | 679 | is called the "modified" mode because it uses the workspace created by |
680 | ``devtool modify`` and the per recipe :term:`Sysroots <Sysroot>` of BitBake. | ||
681 | |||
682 | For some recipes and use cases, this default behavior of ``devtool ide-sdk`` | ||
683 | with full ``devtool`` and ``bitbake`` integration might not be suitable. | ||
684 | To offer full feature parity with the SDK and the eSDK, ``devtool ide-sdk`` has | ||
685 | a second mode called "shared" mode. | ||
686 | If ``devtool ide-sdk`` is called with the ``--mode=shared`` option, it | ||
687 | bootstraps an SDK directly from the BitBake environment, which offers the same | ||
688 | Environment Setup script as described in :ref:`running_the_ext_sdk_env`. | ||
689 | In addition to the (e)SDK installer-based setup, the IDE gets configured | ||
690 | to use the shared :term:`Sysroots <Sysroot>` and the tools from the SDK. | ||
691 | ``devtool ide-sdk --mode=shared`` is basically a wrapper for the setup of the | ||
692 | extensible SDK as described in :ref:`setting_up_ext_sdk_in_build`. | ||
693 | |||
694 | The use of ``devtool ide-sdk`` is an alternative to using one of the SDK | ||
695 | installers. | ||
696 | ``devtool ide-sdk`` allows the creation of SDKs that offer all the | ||
697 | functionality of the SDK and the eSDK installers. Compared to the installers, | ||
698 | however, the SDK created with ``devtool ide-sdk`` is much more flexible. | ||
699 | For example, it is very easy to change the :term:`MACHINE` in the | ||
700 | ``local.conf`` file, update the layer meta data and then regenerate the SDK. | ||
701 | |||
702 | Let's take a look at an example of how to use ``devtool ide-sdk`` in each of | ||
703 | the two modes: | ||
704 | |||
705 | #. *Modified mode*: | ||
706 | |||
707 | In order to use the ``devtool ide-sdk``, a few settings are needed. As a | ||
708 | starting example, the following lines of code can be added to the | ||
709 | ``local.conf`` file:: | ||
647 | 710 | ||
648 | # Build the companion debug file system | 711 | # Build the companion debug file system |
649 | IMAGE_GEN_DEBUGFS = "1" | 712 | IMAGE_GEN_DEBUGFS = "1" |
@@ -675,9 +738,13 @@ The extensible SDK supports two different development modes. | |||
675 | 738 | ||
676 | $ devtool ide-sdk my-recipe core-image-minimal --target root@192.168.7.2 | 739 | $ devtool ide-sdk my-recipe core-image-minimal --target root@192.168.7.2 |
677 | 740 | ||
678 | The command requires an image recipe (``core-image-minimal`` for this example) | 741 | The command requires an image recipe (``core-image-minimal`` for this |
679 | that is used to create the SDK. This firmware image should also be installed | 742 | example) that is used to create the SDK. |
680 | on the target device. It is possible to pass multiple package recipes. | 743 | This firmware image should also be installed on the target device. |
744 | It is possible to pass multiple package recipes:: | ||
745 | |||
746 | $ devtool ide-sdk my-recipe-1 my-recipe-2 core-image-minimal --target root@192.168.7.2 | ||
747 | |||
681 | ``devtool ide-sdk`` tries to create an IDE configuration for all package | 748 | ``devtool ide-sdk`` tries to create an IDE configuration for all package |
682 | recipes. | 749 | recipes. |
683 | 750 | ||
@@ -687,9 +754,9 @@ The extensible SDK supports two different development modes. | |||
687 | 754 | ||
688 | For example, a CMake preset is created for a recipe that inherits | 755 | For example, a CMake preset is created for a recipe that inherits |
689 | :ref:`ref-classes-cmake`. In the case of VSCode, CMake presets are supported | 756 | :ref:`ref-classes-cmake`. In the case of VSCode, CMake presets are supported |
690 | by the CMake Tools plugin. This is an example of how the build | 757 | by the CMake Tools plugin. This is an example of how the build configuration |
691 | configuration used by ``bitbake`` is exported to an IDE configuration that | 758 | used by ``bitbake`` is exported to an IDE configuration that gives exactly |
692 | gives exactly the same build results. | 759 | the same build results. |
693 | 760 | ||
694 | Support for remote debugging with seamless integration into the IDE is | 761 | Support for remote debugging with seamless integration into the IDE is |
695 | important for a cross-SDK. ``devtool ide-sdk`` automatically generates the | 762 | important for a cross-SDK. ``devtool ide-sdk`` automatically generates the |
@@ -702,23 +769,54 @@ The extensible SDK supports two different development modes. | |||
702 | running on the target device, it is essential that the image built by | 769 | running on the target device, it is essential that the image built by |
703 | ``devtool ide-sdk`` is running on the target device. | 770 | ``devtool ide-sdk`` is running on the target device. |
704 | 771 | ||
705 | ``devtool ide-sdk`` aims to support multiple programming languages and | ||
706 | multiple IDEs natively. "Natively" means that the IDE is configured to call | ||
707 | the build tool (e.g. CMake or Meson) directly. This has several advantages. | ||
708 | First of all, it is much faster than ``devtool build``, but it also allows | ||
709 | to use the very good integration of tools like CMake or GDB in VSCode and | ||
710 | other IDEs. However, supporting many programming languages and multiple | ||
711 | IDEs is quite an elaborate and constantly evolving thing. Support for IDEs | ||
712 | is therefore implemented as plugins. Plugins can also be provided by | ||
713 | optional layers. | ||
714 | |||
715 | The default IDE is VSCode. Some hints about using VSCode: | 772 | The default IDE is VSCode. Some hints about using VSCode: |
716 | 773 | ||
717 | - To work on the source code of a recipe an instance of VSCode is started in | 774 | - VSCode can be used to work on the BitBake recipes or the application |
718 | the recipe's workspace. Example:: | 775 | source code. |
776 | Usually there is one instance of VSCode running in the folder where the | ||
777 | BitBake recipes are. This instance has the | ||
778 | `Yocto Project BitBake plugin <https://marketplace.visualstudio.com/items?itemName=yocto-project.yocto-bitbake>`_ | ||
779 | running. | ||
780 | |||
781 | .. warning:: | ||
782 | |||
783 | Some VSCode plugins (Python, BitBake and others) need a reasonable | ||
784 | configuration to work as expected. Otherwise, some plugins try to | ||
785 | index the build directory of BitBake, which keeps your system quite | ||
786 | busy until an out of memory exception stops this nonsense. | ||
787 | Other plugins, such as the BitBake plugin, do not behave as expected. | ||
788 | |||
789 | To work around such issues, the ``oe-init-build-env`` script creates | ||
790 | an initial ``.vscode/settings.json`` file if ``code`` can be found | ||
791 | and the ``.vscode`` folder does not yet exist. | ||
792 | It is best to run ``oe-init-build-env`` once before starting VSCode. | ||
793 | An alternative approach is to use a build folder outside the layers, | ||
794 | e.g. ``oe-init-build-env ../build``. | ||
795 | |||
796 | The BitBake plugin also offers to create devtool workspaces and run | ||
797 | ``devtool ide-sdk`` with a few mouse clicks. | ||
798 | Of course, issuing commands in the terminal works as well. | ||
799 | |||
800 | - To work on the source code of a recipe another instance of VSCode is | ||
801 | started in the recipe's workspace. Example:: | ||
719 | 802 | ||
720 | code build/workspace/sources/my-recipe | 803 | code build/workspace/sources/my-recipe |
721 | 804 | ||
805 | This instance of VSCode uses plugins that are useful for the development | ||
806 | of the application. ``devtool ide-sdk`` generates the necessary | ||
807 | ``extensions.json``, ``settings.json``, ``tasks.json``and ``launch.json`` | ||
808 | configuration files for all the involved plugins. | ||
809 | |||
810 | When the source code folder present in the workspace folder is opened in | ||
811 | VSCode for the first time, a pop-up message recommends installing the | ||
812 | required plugins. | ||
813 | After accepting the installation of the plugins, working with the source | ||
814 | code or some debugging tasks should work as usual with VSCode. | ||
815 | |||
816 | Starting the VSCode instances in the recipe workspace folders can also be | ||
817 | done by a mouse click on the recipe workspaces in the first VSCode | ||
818 | instance. | ||
819 | |||
722 | - To work with CMake press ``Ctrl + Shift + p``, type ``cmake``. This will | 820 | - To work with CMake press ``Ctrl + Shift + p``, type ``cmake``. This will |
723 | show some possible commands like selecting a CMake preset, compiling or | 821 | show some possible commands like selecting a CMake preset, compiling or |
724 | running CTest. | 822 | running CTest. |
@@ -731,10 +829,9 @@ The extensible SDK supports two different development modes. | |||
731 | show some possible commands like compiling or executing the unit tests. | 829 | show some possible commands like compiling or executing the unit tests. |
732 | 830 | ||
733 | A note on running cross-compiled unit tests on the host: Meson enables | 831 | A note on running cross-compiled unit tests on the host: Meson enables |
734 | support for QEMU user-mode by default. It is expected that the execution | 832 | support for QEMU user mode by default. It is expected that the execution |
735 | of the unit tests from the IDE will work easily without any additional | 833 | of the unit tests from the IDE will work without any additional steps, |
736 | steps, provided that the code is suitable for execution on the host | 834 | given that the code is suitable for the execution on the host machine. |
737 | machine. | ||
738 | 835 | ||
739 | - For the deployment to the target device, just press ``Ctrl + Shift + p``, | 836 | - For the deployment to the target device, just press ``Ctrl + Shift + p``, |
740 | type ``task``. Select ``install && deploy-target``. | 837 | type ``task``. Select ``install && deploy-target``. |
@@ -745,23 +842,23 @@ The extensible SDK supports two different development modes. | |||
745 | selected. After selecting one of the generated configurations, press the | 842 | selected. After selecting one of the generated configurations, press the |
746 | "play" button. | 843 | "play" button. |
747 | 844 | ||
748 | Starting a remote debugging session automatically initiates the deployment | 845 | Starting a remote debugging session automatically initiates the |
749 | to the target device. If this is not desired, the | 846 | deployment to the target device. If this is not desired, the |
750 | ``"dependsOn": ["install && deploy-target...]`` parameter of the tasks | 847 | ``"dependsOn": ["install && deploy-target...]`` parameter of the tasks |
751 | with ``"label": "gdbserver start...`` can be removed from the | 848 | with ``"label": "gdbserver start...`` can be removed from the |
752 | ``tasks.json`` file. | 849 | ``tasks.json`` file. |
753 | 850 | ||
754 | VSCode supports GDB with many different setups and configurations for many | 851 | VSCode supports GDB with many different setups and configurations for |
755 | different use cases. However, most of these setups have some limitations | 852 | many different use cases. However, most of these setups have some |
756 | when it comes to cross-development, support only a few target | 853 | limitations when it comes to cross-development, support only a few target |
757 | architectures or require a high performance target device. Therefore | 854 | architectures or require a high performance target device. Therefore |
758 | ``devtool ide-sdk`` supports the classic, generic setup with GDB on the | 855 | ``devtool ide-sdk`` supports the classic, generic setup with GDB on the |
759 | development host and gdbserver on the target device. | 856 | development host and gdbserver on the target device. |
760 | 857 | ||
761 | Roughly summarized, this means: | 858 | Roughly summarized, this means: |
762 | 859 | ||
763 | - The binaries are copied via SSH to the remote target device by a script | 860 | - The binaries are copied via SSH to the remote target device by a |
764 | referred by ``tasks.json``. | 861 | script referred by ``tasks.json``. |
765 | 862 | ||
766 | - gdbserver is started on the remote target device via SSH by a script | 863 | - gdbserver is started on the remote target device via SSH by a script |
767 | referred by ``tasks.json``. | 864 | referred by ``tasks.json``. |
@@ -863,16 +960,9 @@ The extensible SDK supports two different development modes. | |||
863 | 960 | ||
864 | #. *Shared sysroots mode* | 961 | #. *Shared sysroots mode* |
865 | 962 | ||
866 | For some recipes and use cases a per-recipe sysroot based SDK is not | 963 | Creating an SDK with shared :term:`Sysroots <Sysroot>` that contains all the |
867 | suitable. Optionally ``devtool ide-sdk`` configures the IDE to use the | 964 | dependencies needed to work with ``my-recipe`` is possible with the following |
868 | toolchain provided by the extensible SDK as described in | 965 | example command:: |
869 | :ref:`running_the_ext_sdk_env`. ``devtool ide-sdk --mode=shared`` is | ||
870 | basically a wrapper for the setup of the extensible SDK as described in | ||
871 | :ref:`setting_up_ext_sdk_in_build`. The IDE gets a configuration to use the | ||
872 | shared sysroots. | ||
873 | |||
874 | Creating a SDK with shared sysroots that contains all the dependencies needed | ||
875 | to work with ``my-recipe`` is possible with the following example command:: | ||
876 | 966 | ||
877 | $ devtool ide-sdk --mode=shared my-recipe | 967 | $ devtool ide-sdk --mode=shared my-recipe |
878 | 968 | ||
@@ -886,12 +976,14 @@ The extensible SDK supports two different development modes. | |||
886 | echo "project(foo VERSION 1.0)" > kit-test/CMakeLists.txt | 976 | echo "project(foo VERSION 1.0)" > kit-test/CMakeLists.txt |
887 | code kit-test | 977 | code kit-test |
888 | 978 | ||
889 | If there is a CMake project in the workspace, cross-compilation is supported: | 979 | If there is a CMake project in the workspace, cross-compilation is |
980 | supported: | ||
890 | 981 | ||
891 | - Press ``Ctrl + Shift + P``, type ``CMake: Scan for Kits`` | 982 | - Press ``Ctrl + Shift + P``, type ``CMake: Scan for Kits`` |
892 | - Press ``Ctrl + Shift + P``, type ``CMake: Select a Kit`` | 983 | - Press ``Ctrl + Shift + P``, type ``CMake: Select a Kit`` |
893 | 984 | ||
894 | Finally most of the features provided by CMake and the IDE should be available. | 985 | Finally most of the features provided by CMake and the IDE should be |
986 | available. | ||
895 | 987 | ||
896 | Other IDEs than VSCode are supported as well. However, | 988 | Other IDEs than VSCode are supported as well. However, |
897 | ``devtool ide-sdk --mode=shared --ide=none my-recipe`` is currently | 989 | ``devtool ide-sdk --mode=shared --ide=none my-recipe`` is currently |