diff options
| -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 3f6a754d88..adca97bb3a 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" |
| @@ -672,9 +735,13 @@ The extensible SDK supports two different development modes. | |||
| 672 | 735 | ||
| 673 | $ devtool ide-sdk my-recipe core-image-minimal --target root@192.168.7.2 | 736 | $ devtool ide-sdk my-recipe core-image-minimal --target root@192.168.7.2 |
| 674 | 737 | ||
| 675 | The command requires an image recipe (``core-image-minimal`` for this example) | 738 | The command requires an image recipe (``core-image-minimal`` for this |
| 676 | that is used to create the SDK. This firmware image should also be installed | 739 | example) that is used to create the SDK. |
| 677 | on the target device. It is possible to pass multiple package recipes. | 740 | This firmware image should also be installed on the target device. |
| 741 | It is possible to pass multiple package recipes:: | ||
| 742 | |||
| 743 | $ devtool ide-sdk my-recipe-1 my-recipe-2 core-image-minimal --target root@192.168.7.2 | ||
| 744 | |||
| 678 | ``devtool ide-sdk`` tries to create an IDE configuration for all package | 745 | ``devtool ide-sdk`` tries to create an IDE configuration for all package |
| 679 | recipes. | 746 | recipes. |
| 680 | 747 | ||
| @@ -684,9 +751,9 @@ The extensible SDK supports two different development modes. | |||
| 684 | 751 | ||
| 685 | For example, a CMake preset is created for a recipe that inherits | 752 | For example, a CMake preset is created for a recipe that inherits |
| 686 | :ref:`ref-classes-cmake`. In the case of VSCode, CMake presets are supported | 753 | :ref:`ref-classes-cmake`. In the case of VSCode, CMake presets are supported |
| 687 | by the CMake Tools plugin. This is an example of how the build | 754 | by the CMake Tools plugin. This is an example of how the build configuration |
| 688 | configuration used by ``bitbake`` is exported to an IDE configuration that | 755 | used by ``bitbake`` is exported to an IDE configuration that gives exactly |
| 689 | gives exactly the same build results. | 756 | the same build results. |
| 690 | 757 | ||
| 691 | Support for remote debugging with seamless integration into the IDE is | 758 | Support for remote debugging with seamless integration into the IDE is |
| 692 | important for a cross-SDK. ``devtool ide-sdk`` automatically generates the | 759 | important for a cross-SDK. ``devtool ide-sdk`` automatically generates the |
| @@ -699,23 +766,54 @@ The extensible SDK supports two different development modes. | |||
| 699 | running on the target device, it is essential that the image built by | 766 | running on the target device, it is essential that the image built by |
| 700 | ``devtool ide-sdk`` is running on the target device. | 767 | ``devtool ide-sdk`` is running on the target device. |
| 701 | 768 | ||
| 702 | ``devtool ide-sdk`` aims to support multiple programming languages and | ||
| 703 | multiple IDEs natively. "Natively" means that the IDE is configured to call | ||
| 704 | the build tool (e.g. CMake or Meson) directly. This has several advantages. | ||
| 705 | First of all, it is much faster than ``devtool build``, but it also allows | ||
| 706 | to use the very good integration of tools like CMake or GDB in VSCode and | ||
| 707 | other IDEs. However, supporting many programming languages and multiple | ||
| 708 | IDEs is quite an elaborate and constantly evolving thing. Support for IDEs | ||
| 709 | is therefore implemented as plugins. Plugins can also be provided by | ||
| 710 | optional layers. | ||
| 711 | |||
| 712 | The default IDE is VSCode. Some hints about using VSCode: | 769 | The default IDE is VSCode. Some hints about using VSCode: |
| 713 | 770 | ||
| 714 | - To work on the source code of a recipe an instance of VSCode is started in | 771 | - VSCode can be used to work on the BitBake recipes or the application |
| 715 | the recipe's workspace. Example:: | 772 | source code. |
| 773 | Usually there is one instance of VSCode running in the folder where the | ||
| 774 | BitBake recipes are. This instance has the | ||
| 775 | `Yocto Project BitBake plugin <https://marketplace.visualstudio.com/items?itemName=yocto-project.yocto-bitbake>`_ | ||
| 776 | running. | ||
| 777 | |||
| 778 | .. warning:: | ||
| 779 | |||
| 780 | Some VSCode plugins (Python, BitBake and others) need a reasonable | ||
| 781 | configuration to work as expected. Otherwise, some plugins try to | ||
| 782 | index the build directory of BitBake, which keeps your system quite | ||
| 783 | busy until an out of memory exception stops this nonsense. | ||
| 784 | Other plugins, such as the BitBake plugin, do not behave as expected. | ||
| 785 | |||
| 786 | To work around such issues, the ``oe-init-build-env`` script creates | ||
| 787 | an initial ``.vscode/settings.json`` file if ``code`` can be found | ||
| 788 | and the ``.vscode`` folder does not yet exist. | ||
| 789 | It is best to run ``oe-init-build-env`` once before starting VSCode. | ||
| 790 | An alternative approach is to use a build folder outside the layers, | ||
| 791 | e.g. ``oe-init-build-env ../build``. | ||
| 792 | |||
| 793 | The BitBake plugin also offers to create devtool workspaces and run | ||
| 794 | ``devtool ide-sdk`` with a few mouse clicks. | ||
| 795 | Of course, issuing commands in the terminal works as well. | ||
| 796 | |||
| 797 | - To work on the source code of a recipe another instance of VSCode is | ||
| 798 | started in the recipe's workspace. Example:: | ||
| 716 | 799 | ||
| 717 | code build/workspace/sources/my-recipe | 800 | code build/workspace/sources/my-recipe |
| 718 | 801 | ||
| 802 | This instance of VSCode uses plugins that are useful for the development | ||
| 803 | of the application. ``devtool ide-sdk`` generates the necessary | ||
| 804 | ``extensions.json``, ``settings.json``, ``tasks.json``and ``launch.json`` | ||
| 805 | configuration files for all the involved plugins. | ||
| 806 | |||
| 807 | When the source code folder present in the workspace folder is opened in | ||
| 808 | VSCode for the first time, a pop-up message recommends installing the | ||
| 809 | required plugins. | ||
| 810 | After accepting the installation of the plugins, working with the source | ||
| 811 | code or some debugging tasks should work as usual with VSCode. | ||
| 812 | |||
| 813 | Starting the VSCode instances in the recipe workspace folders can also be | ||
| 814 | done by a mouse click on the recipe workspaces in the first VSCode | ||
| 815 | instance. | ||
| 816 | |||
| 719 | - To work with CMake press ``Ctrl + Shift + p``, type ``cmake``. This will | 817 | - To work with CMake press ``Ctrl + Shift + p``, type ``cmake``. This will |
| 720 | show some possible commands like selecting a CMake preset, compiling or | 818 | show some possible commands like selecting a CMake preset, compiling or |
| 721 | running CTest. | 819 | running CTest. |
| @@ -728,10 +826,9 @@ The extensible SDK supports two different development modes. | |||
| 728 | show some possible commands like compiling or executing the unit tests. | 826 | show some possible commands like compiling or executing the unit tests. |
| 729 | 827 | ||
| 730 | A note on running cross-compiled unit tests on the host: Meson enables | 828 | A note on running cross-compiled unit tests on the host: Meson enables |
| 731 | support for QEMU user-mode by default. It is expected that the execution | 829 | support for QEMU user mode by default. It is expected that the execution |
| 732 | of the unit tests from the IDE will work easily without any additional | 830 | of the unit tests from the IDE will work without any additional steps, |
| 733 | steps, provided that the code is suitable for execution on the host | 831 | given that the code is suitable for the execution on the host machine. |
| 734 | machine. | ||
| 735 | 832 | ||
| 736 | - For the deployment to the target device, just press ``Ctrl + Shift + p``, | 833 | - For the deployment to the target device, just press ``Ctrl + Shift + p``, |
| 737 | type ``task``. Select ``install && deploy-target``. | 834 | type ``task``. Select ``install && deploy-target``. |
| @@ -742,23 +839,23 @@ The extensible SDK supports two different development modes. | |||
| 742 | selected. After selecting one of the generated configurations, press the | 839 | selected. After selecting one of the generated configurations, press the |
| 743 | "play" button. | 840 | "play" button. |
| 744 | 841 | ||
| 745 | Starting a remote debugging session automatically initiates the deployment | 842 | Starting a remote debugging session automatically initiates the |
| 746 | to the target device. If this is not desired, the | 843 | deployment to the target device. If this is not desired, the |
| 747 | ``"dependsOn": ["install && deploy-target...]`` parameter of the tasks | 844 | ``"dependsOn": ["install && deploy-target...]`` parameter of the tasks |
| 748 | with ``"label": "gdbserver start...`` can be removed from the | 845 | with ``"label": "gdbserver start...`` can be removed from the |
| 749 | ``tasks.json`` file. | 846 | ``tasks.json`` file. |
| 750 | 847 | ||
| 751 | VSCode supports GDB with many different setups and configurations for many | 848 | VSCode supports GDB with many different setups and configurations for |
| 752 | different use cases. However, most of these setups have some limitations | 849 | many different use cases. However, most of these setups have some |
| 753 | when it comes to cross-development, support only a few target | 850 | limitations when it comes to cross-development, support only a few target |
| 754 | architectures or require a high performance target device. Therefore | 851 | architectures or require a high performance target device. Therefore |
| 755 | ``devtool ide-sdk`` supports the classic, generic setup with GDB on the | 852 | ``devtool ide-sdk`` supports the classic, generic setup with GDB on the |
| 756 | development host and gdbserver on the target device. | 853 | development host and gdbserver on the target device. |
| 757 | 854 | ||
| 758 | Roughly summarized, this means: | 855 | Roughly summarized, this means: |
| 759 | 856 | ||
| 760 | - The binaries are copied via SSH to the remote target device by a script | 857 | - The binaries are copied via SSH to the remote target device by a |
| 761 | referred by ``tasks.json``. | 858 | script referred by ``tasks.json``. |
| 762 | 859 | ||
| 763 | - gdbserver is started on the remote target device via SSH by a script | 860 | - gdbserver is started on the remote target device via SSH by a script |
| 764 | referred by ``tasks.json``. | 861 | referred by ``tasks.json``. |
| @@ -860,16 +957,9 @@ The extensible SDK supports two different development modes. | |||
| 860 | 957 | ||
| 861 | #. *Shared sysroots mode* | 958 | #. *Shared sysroots mode* |
| 862 | 959 | ||
| 863 | For some recipes and use cases a per-recipe sysroot based SDK is not | 960 | Creating an SDK with shared :term:`Sysroots <Sysroot>` that contains all the |
| 864 | suitable. Optionally ``devtool ide-sdk`` configures the IDE to use the | 961 | dependencies needed to work with ``my-recipe`` is possible with the following |
| 865 | toolchain provided by the extensible SDK as described in | 962 | example command:: |
| 866 | :ref:`running_the_ext_sdk_env`. ``devtool ide-sdk --mode=shared`` is | ||
| 867 | basically a wrapper for the setup of the extensible SDK as described in | ||
| 868 | :ref:`setting_up_ext_sdk_in_build`. The IDE gets a configuration to use the | ||
| 869 | shared sysroots. | ||
| 870 | |||
| 871 | Creating a SDK with shared sysroots that contains all the dependencies needed | ||
| 872 | to work with ``my-recipe`` is possible with the following example command:: | ||
| 873 | 963 | ||
| 874 | $ devtool ide-sdk --mode=shared my-recipe | 964 | $ devtool ide-sdk --mode=shared my-recipe |
| 875 | 965 | ||
| @@ -883,12 +973,14 @@ The extensible SDK supports two different development modes. | |||
| 883 | echo "project(foo VERSION 1.0)" > kit-test/CMakeLists.txt | 973 | echo "project(foo VERSION 1.0)" > kit-test/CMakeLists.txt |
| 884 | code kit-test | 974 | code kit-test |
| 885 | 975 | ||
| 886 | If there is a CMake project in the workspace, cross-compilation is supported: | 976 | If there is a CMake project in the workspace, cross-compilation is |
| 977 | supported: | ||
| 887 | 978 | ||
| 888 | - Press ``Ctrl + Shift + P``, type ``CMake: Scan for Kits`` | 979 | - Press ``Ctrl + Shift + P``, type ``CMake: Scan for Kits`` |
| 889 | - Press ``Ctrl + Shift + P``, type ``CMake: Select a Kit`` | 980 | - Press ``Ctrl + Shift + P``, type ``CMake: Select a Kit`` |
| 890 | 981 | ||
| 891 | Finally most of the features provided by CMake and the IDE should be available. | 982 | Finally most of the features provided by CMake and the IDE should be |
| 983 | available. | ||
| 892 | 984 | ||
| 893 | Other IDEs than VSCode are supported as well. However, | 985 | Other IDEs than VSCode are supported as well. However, |
| 894 | ``devtool ide-sdk --mode=shared --ide=none my-recipe`` is currently | 986 | ``devtool ide-sdk --mode=shared --ide=none my-recipe`` is currently |
