Skip to contentSkip to conversation

bitbake-setup: preserve VSCode extension recommendation

PATCH In review Giancarlo Cicellyn Comneno 2 participants 3 messages Aug 18 – Aug 19

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 bitbake-setup: preserve VSCode extension recommendation

configure_vscode() initializes the Yocto BitBake extension recommendation when creating a new workspace. When an existing workspace is loaded, its extensions section replaces that initial value, so the managed recommendation can disappear.

Merge the managed recommendation into the existing recommendations while preserving recommendations added by the user. Extend test_vscode to cover both cases.

Tests:
LC_ALL=C LANG=C bitbake-selftest bb.tests.setup

AI-Generated: Uses OpenAI ChatGPT

---
 bin/bitbake-setup     |  5 +++++
 lib/bb/tests/setup.py | 11 +++++++++++
 2 files changed, 16 insertions(+)
bin/bitbake-setup +5 -0
index 34260139c..9e5f9b31c 100755
@@ -716,6 +716,11 @@ def configure_vscode(setupdir, layerdir, builddir, init_script):
     else:
         logger.debug("configure_vscode: creating new workspace file: {}".format(workspace_file))
 
+    # Update extension recommendations
+    recommendations = workspace.setdefault("extensions", {}).setdefault("recommendations", [])
+    if "yocto-project.yocto-bitbake" not in recommendations:
+        recommendations.append("yocto-project.yocto-bitbake")
+
     # Update folders
     existing_folders = workspace.get("folders", [])
     new_folders = [{"name": "conf", "path": conf_path}]
lib/bb/tests/setup.py +11 -0
index 53a07ee3a..0dfbd910e 100644
@@ -644,6 +644,7 @@ print("BBPATH is {{}}".format(os.environ["BBPATH"]))
         # user-added folders and settings while still rewriting managed ones
         workspace['folders'].append({"name": "user-folder", "path": "user/custom"})
         workspace['settings']['my.user.setting'] = 'preserved'
+        workspace['extensions']['recommendations'] = ['user.example-extension']
         with open(workspace_file, 'w') as f:
             json.dump(workspace, f, indent=4)
 
@@ -658,6 +659,16 @@ print("BBPATH is {{}}".format(os.environ["BBPATH"]))
                       "User-added folder was removed during update")
         self.assertIn('my.user.setting', updated['settings'],
                       "User-added setting was removed during update")
+        self.assertIn(
+            'yocto-project.yocto-bitbake',
+            updated.get('extensions', {}).get('recommendations', []),
+            "Managed BitBake extension recommendation was not restored during update"
+        )
+        self.assertIn(
+            'user.example-extension',
+            updated.get('extensions', {}).get('recommendations', []),
+            "User-added extension recommendation was removed during update"
+        )
 
         # update with a corrupt workspace file should log an error and leave it unchanged
         self.add_file_to_testrepo('test-file', 'updated-again\n')
Signature · 1 line
2.43.0
#1 lore raw
Quoted 4 lines · Giancarlo Cicellyn Comneno via lists.openembedded.org

configure_vscode() initializes the Yocto BitBake extension recommendation when creating a new workspace. When an existing workspace is loaded, its extensions section replaces that initial value, so the managed recommendation can disappear.

The existing workspace was also created by bitbake-setup, so what is the scenario where it doesn't have the yocto-bitbake extension and it needs to be re-added?

Alex

#2 lore raw

Hi Alex,

Thanks, you're right to question this.

I went back through the history of the VSCode workspace support and I can't establish a convincing real-world case for this patch.

The workspace feature was introduced with the yocto-project.yocto-bitbake recommendation already present, and the original test explicitly verifies it. I also couldn't find an established contract that treats extensions.recommendations as managed state that bitbake-setup should restore after a user changes it.

So the scenario in my test was effectively assuming policy that bitbake-setup doesn't currently define.

Please disregard this patch. Thanks for catching that.

Giancarlo

Quoted 13 lines · Alexander Kanavin
Quoted 4 lines · Giancarlo Cicellyn Comneno via lists.openembedded.org

configure_vscode() initializes the Yocto BitBake extension recommendation when creating a new workspace. When an existing workspace is loaded, its extensions section replaces that initial value, so the managed recommendation can disappear.

The existing workspace was also created by bitbake-setup, so what is the scenario where it doesn't have the yocto-bitbake extension and it needs to be re-added?

Alex