bitbake-setup: preserve VSCode extension recommendation
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
@@ -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
@@ -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
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
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