diff mbox series

[1/2] devtool: ide-sdk: honor XDG_DATA_HOME for the CMake kits

Message ID 20261025200949.1757990-1-adrian.freihofer@siemens.com
State New
Headers show
Series [1/2] devtool: ide-sdk: honor XDG_DATA_HOME for the CMake kits | expand

Commit Message

AdrianF Oct. 25, 2026, 8:09 p.m. UTC
From: Adrian Freihofer <adrian.freihofer@siemens.com>

CMake Tools reads its user kits from XDG_DATA_HOME/CMakeTools if
XDG_DATA_HOME is set and only falls back to ~/.local/share/CMakeTools.
The shared sysroot mode always wrote to the fallback location, so the
kit was not found by CMake Tools if XDG_DATA_HOME is set. Use the same
location as CMake Tools.

Signed-off-by: Adrian Freihofer <adrian.freihofer@siemens.com>
---
 scripts/lib/devtool/ide_plugins/ide_code.py | 7 +++++--
 1 file changed, 5 insertions(+), 2 deletions(-)
diff mbox series

Patch

diff --git a/scripts/lib/devtool/ide_plugins/ide_code.py b/scripts/lib/devtool/ide_plugins/ide_code.py
index 081dc08657..39356dcfb1 100644
--- a/scripts/lib/devtool/ide_plugins/ide_code.py
+++ b/scripts/lib/devtool/ide_plugins/ide_code.py
@@ -77,6 +77,7 @@  class IdeVSCode(IdeBase):
     A workspace cannot be created because there is no recipe that defines how a workspace could
     be set up.
     - cmake: adds a cmake-kit to .local/share/CMakeTools/cmake-tools-kits.json
+             (below XDG_DATA_HOME instead of .local/share if it is set)
              The cmake-kit uses the environment script and the tool-chain file
              generated by meta-ide-support.
     - meson: Meson needs manual workspace configuration.
@@ -95,8 +96,10 @@  class IdeVSCode(IdeBase):
         deploy_dir_image = shared_env.ide_support.deploy_dir_image
         real_multimach_target_sys = shared_env.ide_support.real_multimach_target_sys
         standalone_sysroot_native = shared_env.build_sysroots.standalone_sysroot_native
-        vscode_ws_path = os.path.join(
-            os.environ['HOME'], '.local', 'share', 'CMakeTools')
+        # CMake Tools stores its user data in XDG_DATA_HOME, if it is set
+        data_home = os.environ.get('XDG_DATA_HOME') or os.path.join(
+            os.environ['HOME'], '.local', 'share')
+        vscode_ws_path = os.path.join(data_home, 'CMakeTools')
         cmake_kits_path = os.path.join(vscode_ws_path, 'cmake-tools-kits.json')
         oecmake_generator = "Ninja"
         env_script = os.path.join(