@@ -128,6 +128,45 @@ class IdeVSCode(IdeBase):
def dot_code_dir(self, modified_recipe):
return os.path.join(modified_recipe.srctree, '.vscode')
+ def __gen_meson_absolute_cross_file(self, modified_recipe):
+ """Generate an extra cross file overriding c/cpp binaries with absolute paths.
+
+ The recipe's generated meson.cross references the toolchain binaries
+ (e.g. "aarch64-poky-linux-clang++") by bare name, relying on PATH
+ being set up by the meson wrapper script at build time. Meson stores
+ that command exactly as configured (it never resolves it to an
+ absolute path itself), so it ends up unresolved in
+ compile_commands.json and meson-info/intro-compilers.json. cpptools
+ (via the mesonbuild extension) resolves compilerPath using its own
+ process PATH, which does not include the toolchain directory, and
+ silently falls back to a host compiler for IntelliSense.
+
+ Real builds are unaffected since the wrapper script sets up PATH, so
+ the recipe's meson.cross is left untouched. Instead, an extra
+ --cross-file is layered on top with only the c/cpp [binaries]
+ entries absolutized, reusing the exact same flags as CC/CXX to avoid
+ any behavior drift. Meson merges multiple machine files, with later
+ files overriding matching keys from earlier ones.
+ """
+ def absolutize(cmd):
+ args = cmd.split()
+ args[0] = os.path.join(
+ modified_recipe.staging_bindir_toolchain, args[0])
+ return repr(args)
+
+ lines = ["[binaries]"]
+ if modified_recipe.cc:
+ lines.append("c = %s" % absolutize(modified_recipe.cc))
+ if modified_recipe.cxx:
+ lines.append("cpp = %s" % absolutize(modified_recipe.cxx))
+
+ os.makedirs(modified_recipe.ide_sdk_dir, exist_ok=True)
+ cross_file = os.path.join(
+ modified_recipe.ide_sdk_dir, 'meson-absolute-toolchain.cross')
+ with open(cross_file, 'w') as f:
+ f.write(os.linesep.join(lines) + os.linesep)
+ return ['--cross-file', cross_file]
+
def __vscode_settings_meson(self, settings_dict, modified_recipe):
if modified_recipe.build_tool is not BuildTool.MESON:
return
@@ -135,6 +174,8 @@ class IdeVSCode(IdeBase):
confopts = modified_recipe.mesonopts.split()
confopts += modified_recipe.meson_cross_file.split()
+ if modified_recipe.meson_cross_file:
+ confopts += self.__gen_meson_absolute_cross_file(modified_recipe)
confopts += modified_recipe.extra_oemeson.split()
settings_dict["mesonbuild.configureOptions"] = confopts
settings_dict["mesonbuild.buildFolder"] = modified_recipe.b
@@ -478,6 +478,7 @@ class RecipeModified:
self.bblayers = recipe_d.getVar('BBLAYERS').split()
self.bitbakepath = recipe_d.getVar('BITBAKEPATH')
self.bpn = recipe_d.getVar('BPN')
+ self.cc = recipe_d.getVar('CC')
self.cxx = recipe_d.getVar('CXX')
self.d = recipe_d.getVar('D')
self.debug_build = recipe_d.getVar('DEBUG_BUILD')