Capture Cargo target and host compiler settings, recipe Cargo state, and package configuration to generate IDE settings. Rust source paths use Cargo RUSTFLAGS and TARGET_DBGSRC_DIR because Rust does not use compiler DEBUG_PREFIX_MAP.
Mirror the -sys and pkg-config exports from cargo_common.bbclass so generated Cargo config matches OE's system-library behavior. AI-Generated: Uses GitHub Copilot Signed-off-by: Enguerrand de Ribaucourt <[email protected]> --- scripts/lib/devtool/ide_plugins/__init__.py | 1 + scripts/lib/devtool/ide_sdk.py | 57 +++++++++++++++++++++++++++++ 2 files changed, 58 insertions(+) diff --git a/scripts/lib/devtool/ide_plugins/__init__.py b/scripts/lib/devtool/ide_plugins/__init__.py index 7841bc37b9..10fcde471f 100644 --- a/scripts/lib/devtool/ide_plugins/__init__.py +++ b/scripts/lib/devtool/ide_plugins/__init__.py @@ -33,6 +33,7 @@ class BuildTool(Enum): UNDEFINED = auto() CMAKE = auto() MESON = auto() + CARGO = auto() KERNEL_MODULE = auto() @property diff --git a/scripts/lib/devtool/ide_sdk.py b/scripts/lib/devtool/ide_sdk.py index 9faf041957..e686dbcff8 100755 --- a/scripts/lib/devtool/ide_sdk.py +++ b/scripts/lib/devtool/ide_sdk.py @@ -877,6 +877,15 @@ class RecipeModified: self.extra_oemake = None self.kernel_cc = None self.staging_kernel_dir = None + # Cargo application + self.cargo = None + self.cargo_target = None + self.cargo_linker = None + self.cargo_home = None + self.cargo_build_flags = None + self.cargo_packageconfig_confargs = None + self.cargo_rustflags = None + self.cargo_env = None # Populated after bitbake built all the recipes self._installed_binaries = None @@ -1032,6 +1041,54 @@ class RecipeModified: self.extra_oemeson = recipe_d.getVar('EXTRA_OEMESON') self.meson_cross_file = recipe_d.getVar('MESON_CROSS_FILE') self.build_tool = BuildTool.MESON + elif bb.data.inherits_class('cargo', recipe_d): + self.cargo = recipe_d.getVar('CARGO') or 'cargo' + self.cargo_target = recipe_d.getVar('RUST_HOST_SYS') + self.cargo_linker = recipe_d.getVar('CARGO_RUST_TARGET_CCLD') + self.cargo_home = recipe_d.getVar('CARGO_HOME') + self.cargo_build_flags = recipe_d.getVar('CARGO_BUILD_FLAGS') or '' + self.cargo_packageconfig_confargs = recipe_d.getVar( + 'PACKAGECONFIG_CONFARGS') or '' + self.cargo_rustflags = recipe_d.getVar('RUSTFLAGS') or '' + # Rust DWARF paths need remapping to the target debug-source path + # so LLDB can resolve files after the source tree is relocated. + target_dbgsrc_dir = recipe_d.getVar('TARGET_DBGSRC_DIR') + if target_dbgsrc_dir: + source_map = '--remap-path-prefix=%s=%s' % ( + self.real_srctree, target_dbgsrc_dir) + self.cargo_rustflags = '%s %s' % ( + self.cargo_rustflags, shlex.quote(source_map)) + # This environment feeds the generated Cargo config and the C/C++ + # IntelliSense settings; build tasks themselves only need PATH. + self.cargo_env = self.exported_vars.copy() + self.cargo_env.update({ + 'CC': recipe_d.getVar('RUST_TARGET_CC'), + 'CXX': recipe_d.getVar('RUST_TARGET_CXX'), + 'CFLAGS': recipe_d.getVar('CFLAGS'), + 'CXXFLAGS': recipe_d.getVar('CXXFLAGS'), + 'AR': recipe_d.getVar('AR'), + 'TARGET_CC': recipe_d.getVar('RUST_TARGET_CC'), + 'TARGET_CXX': recipe_d.getVar('RUST_TARGET_CXX'), + 'TARGET_CFLAGS': recipe_d.getVar('CFLAGS'), + 'TARGET_CXXFLAGS': recipe_d.getVar('CXXFLAGS'), + 'TARGET_AR': recipe_d.getVar('AR'), + 'HOST_CC': recipe_d.getVar('RUST_BUILD_CC'), + 'HOST_CXX': recipe_d.getVar('RUST_BUILD_CXX'), + 'HOST_CFLAGS': recipe_d.getVar('BUILD_CFLAGS'), + 'HOST_CXXFLAGS': recipe_d.getVar('BUILD_CXXFLAGS'), + 'HOST_AR': recipe_d.getVar('BUILD_AR'), + # Match cargo_common.bbclass so Cargo -sys crates use OE's + # staged libraries through pkg-config instead of vendoring. + 'LIBGIT2_NO_VENDOR': '1', + 'LIBSSH2_SYS_USE_PKG_CONFIG': '1', + 'LIBSQLITE3_SYS_USE_PKG_CONFIG': '1', + 'OPENSSL_NO_VENDOR': '1', + 'PKG_CONFIG_ALLOW_CROSS': '1', + 'PKG_CONFIG_ALL_DYNAMIC': '1', + 'SYSTEM_DEPS_BUILD_INTERNAL': 'never', + 'ZSTD_SYS_USE_PKG_CONFIG': '1', + }) + self.build_tool = BuildTool.CARGO elif bb.data.inherits_class('module', recipe_d): self.build_tool = BuildTool.KERNEL_MODULE self.wants_gdbserver = False -- 2.53.0
-=-=-=-=-=-=-=-=-=-=-=- Links: You receive all messages sent to this group. View/Reply Online (#248640): https://lists.openembedded.org/g/openembedded-core/message/248640 Mute This Topic: https://lists.openembedded.org/mt/121938783/21656 Group Owner: [email protected] Unsubscribe: https://lists.openembedded.org/g/openembedded-core/unsub [[email protected]] -=-=-=-=-=-=-=-=-=-=-=-
