diff options
| author | Adrian Freihofer <adrian.freihofer@siemens.com> | 2024-12-16 18:43:05 +0100 |
|---|---|---|
| committer | Richard Purdie <richard.purdie@linuxfoundation.org> | 2024-12-17 11:41:53 +0000 |
| commit | 92a4abac54a2e6526c97fc4edb5715221dc67e7e (patch) | |
| tree | f63804356247fd383109d9324fcfde642c33e431 /scripts/lib/devtool | |
| parent | 71acb3b781d8fd6749ebc1ff4895d0fe9ca78d2b (diff) | |
| download | poky-92a4abac54a2e6526c97fc4edb5715221dc67e7e.tar.gz | |
devtool: ide-sdk recommend DEBUG_BUILD
The debug_build_config function was never called. Compiling with debug
optimized compiler flags was not working. Even with the
--debug-build-config flag set, the build configuration from the recipe
was used.
The devtool ide-sdk --debug-build-config approach didn't work very well
anyway. The problem is that changing the bbappend file doesn't work
while bitbake uses the bbappend file. As a workaround, it would be
possible to parse the recipe, get DEBUG_BUILD and the path to the append
file, exit tinfoil, change the bbappend file, reopen tinfoil and do what
ide-sdk is supposed to do. Such an implementation would be complicated
and slow.
Therefore, the code that was originally supposed to implement this is
removed from ide-sdk and the new --debug-build function of devtool
modify is used instead. Additionally, a hint should be given on how to
manually add DEBUG_BUILD = '1' to bbappend.
This is compatible with the VSCode Bitbake plug-in, which does not
support this parameter anyway.
(From OE-Core rev: 65950eb601c6c8aac0e4bc8683e544305346229d)
Signed-off-by: Adrian Freihofer <adrian.freihofer@siemens.com>
Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org>
Diffstat (limited to 'scripts/lib/devtool')
| -rwxr-xr-x | scripts/lib/devtool/ide_sdk.py | 50 |
1 files changed, 9 insertions, 41 deletions
diff --git a/scripts/lib/devtool/ide_sdk.py b/scripts/lib/devtool/ide_sdk.py index 42ee13b3e5..ee7c68dbbe 100755 --- a/scripts/lib/devtool/ide_sdk.py +++ b/scripts/lib/devtool/ide_sdk.py | |||
| @@ -288,6 +288,7 @@ class RecipeModified: | |||
| 288 | self.bblayers = None | 288 | self.bblayers = None |
| 289 | self.bpn = None | 289 | self.bpn = None |
| 290 | self.d = None | 290 | self.d = None |
| 291 | self.debug_build = None | ||
| 291 | self.fakerootcmd = None | 292 | self.fakerootcmd = None |
| 292 | self.fakerootenv = None | 293 | self.fakerootenv = None |
| 293 | self.libdir = None | 294 | self.libdir = None |
| @@ -348,6 +349,7 @@ class RecipeModified: | |||
| 348 | self.bpn = recipe_d.getVar('BPN') | 349 | self.bpn = recipe_d.getVar('BPN') |
| 349 | self.cxx = recipe_d.getVar('CXX') | 350 | self.cxx = recipe_d.getVar('CXX') |
| 350 | self.d = recipe_d.getVar('D') | 351 | self.d = recipe_d.getVar('D') |
| 352 | self.debug_build = recipe_d.getVar('DEBUG_BUILD') | ||
| 351 | self.fakerootcmd = recipe_d.getVar('FAKEROOTCMD') | 353 | self.fakerootcmd = recipe_d.getVar('FAKEROOTCMD') |
| 352 | self.fakerootenv = recipe_d.getVar('FAKEROOTENV') | 354 | self.fakerootenv = recipe_d.getVar('FAKEROOTENV') |
| 353 | self.libdir = recipe_d.getVar('libdir') | 355 | self.libdir = recipe_d.getVar('libdir') |
| @@ -389,17 +391,6 @@ class RecipeModified: | |||
| 389 | self.recipe_id = self.bpn + "-" + self.package_arch | 391 | self.recipe_id = self.bpn + "-" + self.package_arch |
| 390 | self.recipe_id_pretty = self.bpn + ": " + self.package_arch | 392 | self.recipe_id_pretty = self.bpn + ": " + self.package_arch |
| 391 | 393 | ||
| 392 | def append_to_bbappend(self, append_text): | ||
| 393 | with open(self.bbappend, 'a') as bbap: | ||
| 394 | bbap.write(append_text) | ||
| 395 | |||
| 396 | def remove_from_bbappend(self, append_text): | ||
| 397 | with open(self.bbappend, 'r') as bbap: | ||
| 398 | text = bbap.read() | ||
| 399 | new_text = text.replace(append_text, '') | ||
| 400 | with open(self.bbappend, 'w') as bbap: | ||
| 401 | bbap.write(new_text) | ||
| 402 | |||
| 403 | @staticmethod | 394 | @staticmethod |
| 404 | def is_valid_shell_variable(var): | 395 | def is_valid_shell_variable(var): |
| 405 | """Skip strange shell variables like systemd | 396 | """Skip strange shell variables like systemd |
| @@ -412,34 +403,6 @@ class RecipeModified: | |||
| 412 | return True | 403 | return True |
| 413 | return False | 404 | return False |
| 414 | 405 | ||
| 415 | def debug_build_config(self, args): | ||
| 416 | """Explicitely set for example CMAKE_BUILD_TYPE to Debug if not defined otherwise""" | ||
| 417 | if self.build_tool is BuildTool.CMAKE: | ||
| 418 | append_text = os.linesep + \ | ||
| 419 | 'OECMAKE_ARGS:append = " -DCMAKE_BUILD_TYPE:STRING=Debug"' + os.linesep | ||
| 420 | if args.debug_build_config and not 'CMAKE_BUILD_TYPE' in self.cmake_cache_vars: | ||
| 421 | self.cmake_cache_vars['CMAKE_BUILD_TYPE'] = { | ||
| 422 | "type": "STRING", | ||
| 423 | "value": "Debug", | ||
| 424 | } | ||
| 425 | self.append_to_bbappend(append_text) | ||
| 426 | elif 'CMAKE_BUILD_TYPE' in self.cmake_cache_vars: | ||
| 427 | del self.cmake_cache_vars['CMAKE_BUILD_TYPE'] | ||
| 428 | self.remove_from_bbappend(append_text) | ||
| 429 | elif self.build_tool is BuildTool.MESON: | ||
| 430 | append_text = os.linesep + 'MESON_BUILDTYPE = "debug"' + os.linesep | ||
| 431 | if args.debug_build_config and self.meson_buildtype != "debug": | ||
| 432 | self.mesonopts.replace( | ||
| 433 | '--buildtype ' + self.meson_buildtype, '--buildtype debug') | ||
| 434 | self.append_to_bbappend(append_text) | ||
| 435 | elif self.meson_buildtype == "debug": | ||
| 436 | self.mesonopts.replace( | ||
| 437 | '--buildtype debug', '--buildtype plain') | ||
| 438 | self.remove_from_bbappend(append_text) | ||
| 439 | elif args.debug_build_config: | ||
| 440 | logger.warn( | ||
| 441 | "--debug-build-config is not implemented for this build tool yet.") | ||
| 442 | |||
| 443 | def solib_search_path(self, image): | 406 | def solib_search_path(self, image): |
| 444 | """Search for debug symbols in the rootfs and rootfs-dbg | 407 | """Search for debug symbols in the rootfs and rootfs-dbg |
| 445 | 408 | ||
| @@ -950,6 +913,13 @@ def ide_setup(args, config, basepath, workspace): | |||
| 950 | recipe_modified.gen_meson_wrapper() | 913 | recipe_modified.gen_meson_wrapper() |
| 951 | ide.setup_modified_recipe( | 914 | ide.setup_modified_recipe( |
| 952 | args, recipe_image, recipe_modified) | 915 | args, recipe_image, recipe_modified) |
| 916 | |||
| 917 | if recipe_modified.debug_build != '1': | ||
| 918 | logger.warn( | ||
| 919 | 'Recipe %s is compiled with release build configuration. ' | ||
| 920 | 'You might want to add DEBUG_BUILD = "1" to %s. ' | ||
| 921 | 'Note that devtool modify --debug-build can do this automatically.', | ||
| 922 | recipe_modified.name, recipe_modified.bbappend) | ||
| 953 | else: | 923 | else: |
| 954 | raise DevtoolError("Must not end up here.") | 924 | raise DevtoolError("Must not end up here.") |
| 955 | 925 | ||
| @@ -1027,6 +997,4 @@ def register_commands(subparsers, context): | |||
| 1027 | '-p', '--no-preserve', help='Do not preserve existing files', action='store_true') | 997 | '-p', '--no-preserve', help='Do not preserve existing files', action='store_true') |
| 1028 | parser_ide_sdk.add_argument( | 998 | parser_ide_sdk.add_argument( |
| 1029 | '--no-check-space', help='Do not check for available space before deploying', action='store_true') | 999 | '--no-check-space', help='Do not check for available space before deploying', action='store_true') |
| 1030 | parser_ide_sdk.add_argument( | ||
| 1031 | '--debug-build-config', help='Use debug build flags, for example set CMAKE_BUILD_TYPE=Debug', action='store_true') | ||
| 1032 | parser_ide_sdk.set_defaults(func=ide_setup) | 1000 | parser_ide_sdk.set_defaults(func=ide_setup) |
