| Message ID | 20260818203658.90975-1-giancarlo.cicellyn@gmail.com |
|---|---|
| State | New |
| Headers | show |
| Series | bitbake-setup: preserve VSCode extension recommendation | expand |
On Tue, 18 Aug 2026 at 22:37, Giancarlo Cicellyn Comneno via lists.openembedded.org <giancarlo.cicellyn=gmail.com@lists.openembedded.org> wrote: > 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 On Wed, 19 Aug 2026 10:32:26 +0200, Alexander Kanavin <alex.kanavin@gmail.com> wrote: > On Tue, 18 Aug 2026 at 22:37, Giancarlo Cicellyn Comneno via > lists.openembedded.org > <giancarlo.cicellyn=gmail.com@lists.openembedded.org> wrote: > > 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
diff --git a/bin/bitbake-setup b/bin/bitbake-setup index 34260139c..9e5f9b31c 100755 --- a/bin/bitbake-setup +++ b/bin/bitbake-setup @@ -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}] diff --git a/lib/bb/tests/setup.py b/lib/bb/tests/setup.py index 53a07ee3a..0dfbd910e 100644 --- a/lib/bb/tests/setup.py +++ b/lib/bb/tests/setup.py @@ -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')
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 Signed-off-by: Giancarlo Cicellyn Comneno <giancarlo.cicellyn@gmail.com> --- bin/bitbake-setup | 5 +++++ lib/bb/tests/setup.py | 11 +++++++++++ 2 files changed, 16 insertions(+)