Skip to content
Permalink

Comparing changes

Choose two branches to see what’s changed or to start a new pull request. If you need to, you can also or learn more about diff comparisons.

Open a pull request

Create a new pull request by comparing changes across two branches. If you need to, you can also . Learn more about diff comparisons here.
base repository: yoctoproject/poky
Failed to load repositories. Confirm that selected base ref is valid, then try again.
Loading
base: master
Choose a base ref
...
head repository: savoirfairelinux/poky-ide
Failed to load repositories. Confirm that selected head ref is valid, then try again.
Loading
compare: staging
Choose a head ref
Can’t automatically merge. Don’t worry, you can still create the pull request.
  • 9 commits
  • 20 files changed
  • 1 contributor

Commits on Sep 27, 2023

  1. vscode: add minimal configuration

    It is essential to configure VSCode indexer plugins to ignore the build
    folder of bitbake. Otherwise, the indexer plugins run with 100% CPU load
    until an OOM exception occurs. In practice, this makes VSCode more or
    less unusable for working with Yocto until a file like the one added by
    this commit is deployed before VSCode starts. From the user's point of
    view, it is not obvious why the system runs at 100% CPU load and
    eventually crashes.
    
    It is even more misleading that VSCode starts the indexers immediately,
    but does not stop or reconfigure them when the ignore list is updated.
    In practice, this means that every time the ignore list is changed,
    VSCode immediately starts indexing the build folder until the OOM
    exception stops it. Depending on the system's OOM handler, the entire
    build machine may crash.
    Particularly annoying is the Python plugin that ignores the general
    ignore list and requires an extra ignore section.
    
    The settings are suitable for workflows like bitbake, devtool modify,
    devtool reset. The settings are not intended to work on the source code
    of a recipe. It is assumed that a separate instance of VSCode is used
    per workspace folder. These per workspace instances can have different
    settings depending on the details of the sources that come with the
    recipe. The new devtool ide plugin will generate settings to match this.
    
    Signed-off-by: Adrian Freihofer <adrian.freihofer@siemens.com>
    afreof authored and deribaucourt committed Sep 27, 2023
    Copy the full SHA
    2a86303 View commit details
  2. cmake.bbclass: support qemu

    Define the CMAKE_CROSSCOMPILING_EMULATOR variable similar to what the
    meson bbclass does. This allows for example to execute cross compilied
    unit tests on the build machine.
    
    CMAKE_CROSSCOMPILING_EMULATOR is a semi colon separated list of
    paramters which could directly handle the -L and the -E parameters.
    Creating a wrapper script is not absolutely mandatory. But anyway lets
    do it similar to what the meson.bbclass does and also disable pseudo.
    
    Signed-off-by: Adrian Freihofer <adrian.freihofer@siemens.com>
    afreof authored and deribaucourt committed Sep 27, 2023
    Copy the full SHA
    034dc95 View commit details
  3. devtool: new ide plugin

    The new devtool ide plugin configures an IDE to work with the eSDK.
    
    With this initial implementation VSCode is the default IDE.
    The plugin works for recipes inheriting the cmake or the meson bbclass.
    Support for more programming languages and build tools may be added in
    the future.
    
    Using the plugin in recipe modes:
    $ devtool modify a-recipe
    $ devtool ide a-recipe a-image
    $ code "$BUILDDIR/workspace/sources/a-recipe"
    Work in VSCode, after installing the proposed plugins
    
    Using the plugin without a recipe
    $ devtool ide none a-image
    vscode where/the/sources/are
    Use the cross tool-chain which is provided as a cmake-kit.
    
    The goal of this implementation is to create a configuration for VSCode
    (or other IDEs) that allows to work on the code of a recipe completely
    independent from bitbake. bitbake is only called if the configuration or
    the whole SDK has to be regenerated. But bitbake should not need to be
    called while working in the IDE. This has two major advantages over
    calling devtool build from the IDE:
    - The IDE provides plugins for integration with cmake, for example.
      These features are usable, which would not be the case if bitbake or
      devtool are called from within the IDE.
    - It is much faster.
    
    Signed-off-by: Adrian Freihofer <adrian.freihofer@siemens.com>
    afreof authored and deribaucourt committed Sep 27, 2023
    Copy the full SHA
    4c5e2bf View commit details
  4. tests: add a C++ example recipe

    This simple C++ project supports compilation with cmake and with meson.
    It's supposed to be used with oe-selftest for the devtool ide plugin.
    
    Signed-off-by: Adrian Freihofer <adrian.freihofer@siemens.com>
    afreof authored and deribaucourt committed Sep 27, 2023
    Copy the full SHA
    05453ed View commit details
  5. cmake-example: workaround for pseudo breakeage

    Signed-off-by: Adrian Freihofer <adrian.freihofer@siemens.com>
    afreof authored and deribaucourt committed Sep 27, 2023
    Copy the full SHA
    b8a5ddd View commit details
  6. devtool: refactor deploy-target

    Signed-off-by: Adrian Freihofer <adrian.freihofer@siemens.com>
    afreof authored and deribaucourt committed Sep 27, 2023
    Copy the full SHA
    a80eabf View commit details
  7. devtool: ide make deploy-target quicker

    Instead of calling devtool deploy-target which starts a bitbake server
    to get some variables the previous refactoring allows to generate a
    simple script which does no longer depend on variables from bitbake.
    This is much faster.
    afreof authored and deribaucourt committed Sep 27, 2023
    Copy the full SHA
    199bb41 View commit details
  8. oe-selftest devtool: ide tests

    Signed-off-by: Adrian Freihofer <adrian.freihofer@siemens.com>
    afreof authored and deribaucourt committed Sep 27, 2023
    Copy the full SHA
    44f8a81 View commit details
  9. docs: cover devtool ide

    Signed-off-by: Adrian Freihofer <adrian.freihofer@siemens.com>
    afreof authored and deribaucourt committed Sep 27, 2023
    Copy the full SHA
    ca80f50 View commit details
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -36,3 +36,5 @@ _toaster_clones/
downloads/
sstate-cache/
toaster.sqlite
.vscode/
vscode-bitbake-build/
32 changes: 32 additions & 0 deletions .vscode/settings.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
{
"files.watcherExclude": {
"**/.git/**": true,
"**/cache/**": true,
"**/tmp*/**": true,
"**/downloads/**": true,
"**/sstate-cache/**": true,
"**/vscode-bitbake-build/**": true,
"**/workspace/sources/**": true,
"**/workspace/attic/**": true
},
"files.exclude": {
"**/.git/**": true,
"**/cache/**": true,
"**/tmp*/**": true,
"**/downloads/**": true,
"**/sstate-cache/**": true,
"**/vscode-bitbake-build/**": true,
"**/workspace/sources/**": true,
"**/workspace/attic/**": true
},
"python.analysis.exclude": [
"**/.git/**",
"**/cache/**",
"**/tmp*/**",
"**/downloads/**",
"**/sstate-cache/**",
"**/vscode-bitbake-build/**",
"**/workspace/sources/**",
"**/workspace/attic/**"
]
}
98 changes: 97 additions & 1 deletion documentation/sdk-manual/extensible.rst
Original file line number Diff line number Diff line change
@@ -230,13 +230,16 @@ all the commands.
See the ":doc:`/ref-manual/devtool-reference`"
section in the Yocto Project Reference Manual.

Three ``devtool`` subcommands provide entry-points into development:
Four ``devtool`` subcommands provide entry-points into
development:

- *devtool add*: Assists in adding new software to be built.

- *devtool modify*: Sets up an environment to enable you to modify
the source of an existing component.

- *devtool ide*: Generates a configuration for an IDE.

- *devtool upgrade*: Updates an existing recipe so that you can
build it for an updated set of source files.

@@ -614,6 +617,99 @@ command:
decide you do not want to proceed with your work. If you do use this
command, realize that the source tree is preserved.

Use ``devtool ide`` to generate an configuration for the IDE
------------------------------------------------------------

``devtool ide`` automatically configures the IDE for cross-compiling and remote debugging.
The IDE is configured to call for example cmake directly. This has several advantages.
First of all it is much faster than using e.g. ``devtool build``. But it also allows to
use the very good integration of build tools like cmake or gdb with VSCode directly.

Two different use cases are supported:

- Generate the IDE configuration for a workspace created by ``devtool modify``.

- Generate the IDE configuration for using a cross-toolchain as provided by
``bitbake meta-ide-support build-sysroots``.

Assuming the development environment is set up correctly and a workspace has been created
for the recipe using ``devtool modify recipe``, the following command can create the
configuration for VSCode in the recipe workspace:

$ devtool ide recipe core-image-minimal --target root@192.168.7.2

What this command does exactly depends on the recipe or the build tool used by the recipe.
Currently, only CMake and Meson are supported natively.

For a recipe which inherits cmake it does:

- Prepare the SDK by calling bitbake core-image-minimal, gdb-cross, qemu-native...

- Generate a cmake-preset with configures cmake to use exactly the same environent and
the same cmake-cache configuration as used by ``bitbake recipe``. The cmake-preset referres
to the per-recipe-sysroot of the recipe.

Currently Configure, Build and Test presets are supported. Test presets execute the test
binaries with Qemu.

- Generates a helper script to handle the do_install with pseudo

- Generates some helper scripts to start the gdbserver on the target device

- Generates the ``.vscode`` folder containing the following files:

- c_ccp_properties.json: configure the code navigation

- extensions.json: Recommend the extensions which are used.

- launch.json: Provide a configuration for remote debugging with gdb-cross and gdbserver.
The debug-symbols are searched in the build-folder, the per-recipe-sysroot and the rootfs-dbg
folder which is provided by the image.

- settings.json: confgure the indexer to ignore the build folders

- tasks.json: Provide some helpers for running

- do_install and ``devtool deploy-target``

- start the gdbserver via ssh

For a recipe which inherits meson a similar configuration is generated.
Because there is nothing like a meson-preset a wrapper script for meson is generated.

For some special recipes and use cases a per-recipe-sysroot based SDK is not suitable.
Therefore devtool ide also supports setting up the shared sysroots environment and generating
a IDE configurations referring to the shared sysroots. Recipes leading to a shared sysroot
are for example meta-ide-support or shared-sysroots. Also passing none as a recipe name leads
to a shared sysroot SDK.

$ devtool ide none core-image-minimal

In case of a shared sysroot SDK the configuration which gets generated for VSCode exposes the
cross-tool-chain as a cmake-kit. If a cmake project is loaded into VSCode the cross-toolchain
can be selected for compiling.

The default IDE is VSCode. Some hints about using VSCode:

- To work with cmake press ``Ctrl + Shift + p``, type cmake.
This will show some possible commands like selecting a cmake preset, compiling or running ctest.
A cmake kit might be activated by ``Ctrl + Shift + p``, type cmake quick start,
if not preset file is in the wokspace.

- To work with meson press ``Ctrl + Shift + p``, type meson.
This will show some possible commands like compiling or executing the unit tests.

- For the deployment to the target device, just press ``Ctrl + Shift + p``, type task.
Select the install & deploy task.

- For remote debugging, switch to the debugging view by pressing the play button with the bug on the left side.
This will provide a green play button with a drop-down list where a debug configuration can be selected.
After selecting one of the generated configurations, press the play button.

Additionally ``--ide=none`` is supported.
With the none IDE some generic configurations files like .gdbinit files and some helper scripts
are generated.

Use ``devtool upgrade`` to Create a Version of the Recipe that Supports a Newer Version of the Software
-------------------------------------------------------------------------------------------------------

1 change: 1 addition & 0 deletions meta-selftest/recipes-test/cpp/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
build*
23 changes: 23 additions & 0 deletions meta-selftest/recipes-test/cpp/cmake-example.bb
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
#
# Copyright OpenEmbedded Contributors
#
# SPDX-License-Identifier: MIT
#

SUMMARY = "A C++ example compiled with cmake."

inherit cmake

require cpp-example.inc

SRC_URI += "\
file://CMakeLists.txt \
"

FILES:${PN}-ptest += "${bindir}/test-cmake-example"

# This is a workaround for packages with sources in-tree
# Without this bitbake ... does not work after running the install script.
# newenv['PSEUDO_IGNORE_PATHS'] = newenv['PSEUDO_IGNORE_PATHS'] + ""
# path mismatch [3 links]: ino 37529096 db '/home/adrian/projects/oss/meta-yocto-upstream/projects/poky-oe-glibc-sd/tmp/work/cortexa57-poky-linux/cmake-example/1.0-r0/package/usr/src/debug/cmake-example/1.0-r0/oe-local-files/cmake-example-lib.cpp' req '/home/adrian/projects/oss/meta-yocto-upstream/projects/poky-oe-glibc-sd/workspace/sources/cmake-example/oe-local-files/cmake-example-lib.cpp'.
PACKAGE_DEBUG_SPLIT_STYLE = "debug-without-src"
10 changes: 10 additions & 0 deletions meta-selftest/recipes-test/cpp/cmake-example/run-ptest
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
#!/bin/sh
#
# Copyright OpenEmbedded Contributors
#
# SPDX-License-Identifier: MIT
#

test-cmake-example

# Note: run-ptests exits with exit value from test-cmake-example
24 changes: 24 additions & 0 deletions meta-selftest/recipes-test/cpp/cpp-example.inc
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
#
# Copyright OpenEmbedded Contributors
#
# SPDX-License-Identifier: MIT
#

LICENSE = "MIT"
LIC_FILES_CHKSUM = "file://${COMMON_LICENSE_DIR}/MIT;md5=0835ade698e0bcf8506ecda2f7b4f302"

inherit ptest

DEPENDS += "json-c"

PV = "1.0"

S = "${WORKDIR}"

SRC_URI = "\
file://cpp-example.cpp \
file://cpp-example-lib.hpp \
file://cpp-example-lib.cpp \
file://test-cpp-example.cpp \
file://run-ptest \
"
60 changes: 60 additions & 0 deletions meta-selftest/recipes-test/cpp/files/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,60 @@
#
# Copyright OpenEmbedded Contributors
#
# SPDX-License-Identifier: MIT
#

cmake_minimum_required(VERSION 3.22)

project(cmake-example
VERSION 1.0.0
LANGUAGES CXX
)

option(BUILD_SHARED_LIBS "Build using shared libraries" ON)

set(CMAKE_CXX_STANDARD 17)
set(CMAKE_CXX_STANDARD_REQUIRED On)
set(CMAKE_CXX_EXTENSIONS Off)

include(GNUInstallDirs)

# Find json-c
# find_package(PkgConfig REQUIRED)
# pkg_check_modules(JSONC REQUIRED json-c)
find_package(json-c)

# A simple library linking json-c library found by pkgconfig
add_library(cmake-example-lib cpp-example-lib.cpp cpp-example-lib.hpp)
set_target_properties(cmake-example-lib PROPERTIES
VERSION ${PROJECT_VERSION}
SOVERSION ${PROJECT_VERSION_MAJOR}
)
target_link_libraries(cmake-example-lib PRIVATE json-c::json-c)
# target_link_libraries(cmake-example-lib ${JSONC_LIBRARIES})
# target_include_directories(cmake-example-lib PUBLIC ${JSONC_INCLUDE_DIRS})
# target_compile_options(cmake-example-lib PUBLIC ${JSONC_CFLAGS_OTHER})
install(TARGETS cmake-example-lib
INCLUDES DESTINATION ${CMAKE_INSTALL_INCLUDEDIR}
ARCHIVE DESTINATION ${CMAKE_INSTALL_LIBDIR}
LIBRARY DESTINATION ${CMAKE_INSTALL_LIBDIR}
)

# A simple executable linking the library
add_executable(cmake-example cpp-example.cpp)
target_link_libraries(cmake-example PRIVATE cmake-example-lib)

install(TARGETS cmake-example
RUNTIME DESTINATION ${CMAKE_INSTALL_BINDIR}
)

# A simple test executable for testing the library
add_executable(test-cmake-example test-cpp-example.cpp)
target_link_libraries(test-cmake-example PRIVATE cmake-example-lib)

install(TARGETS test-cmake-example
RUNTIME DESTINATION ${CMAKE_INSTALL_BINDIR}
)

include(CTest)
add_test(NAME test-cmake-example COMMAND test-cmake-example)
17 changes: 17 additions & 0 deletions meta-selftest/recipes-test/cpp/files/cpp-example-lib.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
/*
* Copyright OpenEmbedded Contributors
*
* SPDX-License-Identifier: MIT
*/

#include <string>
#include <json-c/json.h>
#include "cpp-example-lib.hpp"

const std::string& CppExample::get_string() {
return test_string;
}

const char* CppExample::get_json_c_version() {
return json_c_version();
}
16 changes: 16 additions & 0 deletions meta-selftest/recipes-test/cpp/files/cpp-example-lib.hpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
/*
* Copyright OpenEmbedded Contributors
*
* SPDX-License-Identifier: MIT
*/

#pragma once

#include <string>

struct CppExample {
inline static const std::string test_string = "cpp-example-lib Magic: 123456789";

const std::string& get_string();
const char* get_json_c_version();
};
16 changes: 16 additions & 0 deletions meta-selftest/recipes-test/cpp/files/cpp-example.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
/*
* Copyright OpenEmbedded Contributors
*
* SPDX-License-Identifier: MIT
*/

#include "cpp-example-lib.hpp"

#include <iostream>

int main() {
auto cpp_example = CppExample();
std::cout << "C++ example linking " << cpp_example.get_string() << std::endl;
std::cout << "Linking json-c version " << cpp_example.get_json_c_version() << std::endl;
return 0;
}
34 changes: 34 additions & 0 deletions meta-selftest/recipes-test/cpp/files/meson.build
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
#
# Copyright OpenEmbedded Contributors
#
# SPDX-License-Identifier: MIT
#

project('meson-example', 'cpp',
version: '1.0.0',
default_options: ['cpp_std=c++17']
)


jsoncdep = dependency('json-c')

mesonexlib = shared_library('mesonexlib',
'cpp-example-lib.cpp', 'cpp-example-lib.hpp',
version: meson.project_version(),
soversion: meson.project_version().split('.')[0],
dependencies : jsoncdep,
install : true
)

executable('mesonex',
'cpp-example.cpp',
link_with : mesonexlib,
install : true
)

test_mesonex = executable('test-mesonex',
'test-cpp-example.cpp',
link_with : mesonexlib,
install : true
)
test('meson example test', test_mesonex)
19 changes: 19 additions & 0 deletions meta-selftest/recipes-test/cpp/files/test-cpp-example.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
/*
* Copyright OpenEmbedded Contributors
*
* SPDX-License-Identifier: MIT
*/

#include "cpp-example-lib.hpp"

#include <iostream>

int main() {
auto cpp_example = CppExample();
auto ret_string = cpp_example.get_string();
if(0 == ret_string.compare(CppExample::test_string)) {
std::cout << "PASS: " << ret_string << " = " << CppExample::test_string << std::endl;
} else {
std::cout << "FAIL: " << ret_string << " != " << CppExample::test_string << std::endl;
}
}
Loading