diff mbox series

[v2,12/18] devtool: ide-sdk: remap Cargo sources for BitBake builds

Message ID 20261109-devtool-ide-sdk-cargo-v2-12-d56134000561@savoirfairelinux.com
State New
Headers show
Series devtool: ide-sdk: add support for Rust recipes | expand

Commit Message

Enguerrand de Ribaucourt Nov. 9, 2026, 1:44 p.m. UTC
With devtool modify, Cargo sources can live outside WORKDIR, so the
standard Rust remaps leave the workspace path in DWARF and package QA
rejects the debug package. Append a workspace-specific remap to
RUST_DEBUG_REMAP in a managed bbappend section so repeated ide-sdk runs
restore and reparse it.

AI-Generated: Uses GitHub Copilot

---

Changes in v2:

- Revert bbappend comparison after stripping managed sections to avoid
  reparse when the ide-sdk section is not modified. I think there is a
  pre-existing bug with that logic however. An ide-sdk re-run leaves the
  stripped bbappend for clang and cargo classes. As a consequence, I
  simplified the Qemu selftest to no longer run ide-sdk twice.
---
 scripts/lib/devtool/ide_sdk.py | 34 +++++++++++++++++++++++++---------
 1 file changed, 25 insertions(+), 9 deletions(-)

Comments

patchtest@automation.yoctoproject.org Nov. 9, 2026, 2:08 p.m. UTC | #1
Thank you for your submission. Patchtest identified one
or more issues with the patch. Please see the log below for
more information:

---
Testing patch /home/patchtest/share/mboxes/v2-12-18-devtool-ide-sdk-remap-Cargo-sources-for-BitBake-builds.patch

FAIL: test Signed-off-by presence: Mbox is missing Signed-off-by. Add it manually or with "git commit --amend -s" (test_mbox.TestMbox.test_signed_off_by_presence)

PASS: pretest pylint (test_python_pylint.PyLint.pretest_pylint)
PASS: test auh changelog truncation notice (test_mbox.TestMbox.test_auh_changelog_truncation_notice)
PASS: test author valid (test_mbox.TestMbox.test_author_valid)
PASS: test commit message presence (test_mbox.TestMbox.test_commit_message_presence)
PASS: test commit message user tags (test_mbox.TestMbox.test_commit_message_user_tags)
PASS: test max line length (test_metadata.TestMetadata.test_max_line_length)
PASS: test mbox format (test_mbox.TestMbox.test_mbox_format)
PASS: test non-AUH upgrade (test_mbox.TestMbox.test_non_auh_upgrade)
PASS: test pylint (test_python_pylint.PyLint.test_pylint)
PASS: test shortlog format (test_mbox.TestMbox.test_shortlog_format)
PASS: test shortlog length (test_mbox.TestMbox.test_shortlog_length)
PASS: test target mailing list (test_mbox.TestMbox.test_target_mailing_list)

SKIP: pretest src uri left files: No modified recipes, skipping pretest (test_metadata.TestMetadata.pretest_src_uri_left_files)
SKIP: test CVE check ignore: No modified recipes or older target branch, skipping test (test_metadata.TestMetadata.test_cve_check_ignore)
SKIP: test CVE tag format: No new source patches introduced (test_patch.TestPatch.test_cve_tag_format)
SKIP: test Signed-off-by presence: No new source patches introduced (test_patch.TestPatch.test_signed_off_by_presence)
SKIP: test Upstream-Status presence: No new source patches introduced (test_patch.TestPatch.test_upstream_status_presence_format)
SKIP: test bugzilla entry format: No bug ID found (test_mbox.TestMbox.test_bugzilla_entry_format)
SKIP: test lic files chksum modified not mentioned: No modified recipes, skipping test (test_metadata.TestMetadata.test_lic_files_chksum_modified_not_mentioned)
SKIP: test lic files chksum presence: No added recipes, skipping test (test_metadata.TestMetadata.test_lic_files_chksum_presence)
SKIP: test license presence: No added recipes, skipping test (test_metadata.TestMetadata.test_license_presence)
SKIP: test series merge on head: Merge test is disabled for now (test_mbox.TestMbox.test_series_merge_on_head)
SKIP: test src uri left files: No modified recipes, skipping test (test_metadata.TestMetadata.test_src_uri_left_files)
SKIP: test summary presence: No added recipes, skipping test (test_metadata.TestMetadata.test_summary_presence)

---

Please address the issues identified and
submit a new revision of the patch, or alternatively, reply to this
email with an explanation of why the patch should be accepted. If you
believe these results are due to an error in patchtest, please submit a
bug at https://bugzilla.yoctoproject.org/ (use the 'Patchtest' category
under 'Yocto Project Subprojects'). For more information on specific
failures, see: https://wiki.yoctoproject.org/wiki/Patchtest. Thank
you!
diff mbox series

Patch

diff --git a/scripts/lib/devtool/ide_sdk.py b/scripts/lib/devtool/ide_sdk.py
index 0ce2a7780e..5096297b32 100755
--- a/scripts/lib/devtool/ide_sdk.py
+++ b/scripts/lib/devtool/ide_sdk.py
@@ -831,6 +831,7 @@  class RecipeModified:
     VALID_BASH_ENV_NAME_CHARS = re.compile(r"^[a-zA-Z0-9_]*$")
 
     MARKER = '# devtool ide-sdk: clangd toolchain support'
+    CARGO_REMAP_MARKER = '# devtool ide-sdk: Cargo source debug remap'
 
     # PROVIDES of recipes that are deployed via do_deploy (e.g. to
     # DEPLOY_DIR_IMAGE) rather than installed into the rootfs, so adding them
@@ -951,13 +952,14 @@  class RecipeModified:
                 content = f.read()
             originals[name] = content
             stripped = cls._strip_marker_section(content, cls.MARKER)
+            stripped = cls._strip_marker_section(stripped, cls.CARGO_REMAP_MARKER)
             if stripped != content:
                 with open(bbappend, 'w') as f:
                     f.write(stripped)
         return originals
 
     def update_bbappend(self):
-        """Add DEPENDS on clang-native when clangd is used as only the IntelliSense engine"""
+        """Add workspace-only clang dependencies or Cargo debug path remaps."""
         wants_clang_native = (
             self.build_tool.is_c_cpp
             and self.ide_sdk_intellisense == 'clangd'
@@ -970,17 +972,27 @@  class RecipeModified:
         else:
             parsed_content = ''
 
-        if not wants_clang_native:
+        new_sections = []
+        if wants_clang_native:
+            new_sections.append(
+                self.MARKER + '\nDEPENDS:append = " clang-native"\n')
+        if self.build_tool is BuildTool.CARGO:
+            new_sections.append(
+                self.CARGO_REMAP_MARKER
+                + '\nRUST_DEBUG_REMAP:append = " '
+                '--remap-path-prefix=${S}=${TARGET_DBGSRC_DIR}"\n')
+
+        if not new_sections:
             if self.MARKER in original_content:
                 logger.info(
                     "Removed clangd toolchain support from %s: no longer needed", self.bbappend)
             return False
 
-        new_section = self.MARKER + '\nDEPENDS:append = " clang-native"\n'
         new_content = parsed_content
-        if new_content and not new_content.endswith('\n'):
-            new_content += '\n'
-        new_content += new_section
+        for section in new_sections:
+            if new_content and not new_content.endswith('\n'):
+                new_content += '\n'
+            new_content += section
 
         if new_content == original_content:
             return False
@@ -989,9 +1001,13 @@  class RecipeModified:
         os.makedirs(appends_dir, exist_ok=True)
         with open(self.bbappend, 'w') as f:
             f.write(new_content)
-        logger.info(
-            "Updated %s: added DEPENDS on clang-native, needed to stage clangd "
-            "for IDE_SDK_INTELLISENSE=\"clangd\"", self.bbappend)
+        if wants_clang_native:
+            logger.info(
+                "Updated %s: added DEPENDS on clang-native, needed to stage clangd "
+                "for IDE_SDK_INTELLISENSE=\"clangd\"", self.bbappend)
+        if self.build_tool is BuildTool.CARGO:
+            logger.info(
+                "Updated %s: remapped Cargo external sources for debug info", self.bbappend)
         return True
 
     def initialize(self, config, workspace, tinfoil):