Skip to contentSkip to conversation

oe-init-build-env: generate .vscode from template

PATCH New Adrian Freihofer 1 participant 3 messages Feb 15, 2024

lore
Share & tools
lore
#0 lore raw

v4 cover oe-init-build-env: generate .vscode from template

Changes in comparison to v3:
- Add more plugin settings as suggested by Enguerrand
https://lists.openembedded.org/g/openembedded-core/message/195505

Changes in comparison to v2:
- Do not integrate with the oe-setup-build or templating infrastrucutre. Provide a minimalistic script which is just good enough to generate a configuration which fits for poky.
- Some details will be fixed on the plugin side which allows to simplify the generated bitbake plugin configuration to a minimum.

With these patches, VSCode and the new plugin from
https://marketplace.visualstudio.com/items?itemName=yocto-project.yocto-bitbake
should work without any manual configuration once the oe-init-build-env script has been sourced. VSCode is also configured to not index the build folder and finally crash with an OOM exception.

Without these patches, the issue is that the plugin automatically updates the .vscode/settings.json file. Having the settings.json file in git and a plugin which modifies this file is not ideal. It can lead to anoying situations especially when working with git. For example a git stash reverts the settings which are automatically applied by the plugin. While git stashed the settings.json file the plugin immediately changes the file again and tries to run bitbake based on the newly generated settings. When git does a stash pop the restored settings.json file conflicts with the new settigns.json file which has been generated while the git stash took place.

Just removing the settings.json from git would lead to other issues as already described in the commit message of 5ff688fe29. And the plugin needs manual configuration.

Discussion is here:
https://github.com/yoctoproject/vscode-bitbake/issues/95

Adrian Freihofer (2):
vscode: drop .vscode folder
oe-init-build-env: generate .vscode from template

 .gitignore              |  1 -
 .vscode/settings.json   | 32 --------------
 oe-init-build-env       |  6 +++
 scripts/oe-setup-vscode | 93 +++++++++++++++++++++++++++++++++++++++++
 4 files changed, 99 insertions(+), 33 deletions(-)
 delete mode 100644 .vscode/settings.json
 create mode 100755 scripts/oe-setup-vscode
Signature · 1 line
2.43.1
#1 lore raw

PATCH v4 1/2 vscode: drop .vscode folder

There is a new official bitbake plugin:
https://marketplace.visualstudio.com/items?itemName=yocto-project.yocto-bitbake

This plugin automatically updates the .vscode/settings.json file. Having the settings.json file in git and a plugin which modifies this file is not ideal. It can lead to anoying situations especially when working with git. For example a git stash reverts the settings which are automatically applied by the plugin. While git stashed the settings.json file the plugin immediately changes the file again and tries to run bitbake based on the newly generated settings. When git does a stash pop the restored settings.json file conflicts with the new settigns.json file which has been generated while the git stash took place.

Therefore this patch removes the .vscode folder from git.

Removing the settings.json leads to other issues as already described in the commit message of 5ff688fe29. But we still need another solution where the settings.json file is not in Git.

Discussion is here:
https://github.com/yoctoproject/vscode-bitbake/issues/95

---
 .gitignore            |  1 -
 .vscode/settings.json | 32 --------------------------------
 2 files changed, 33 deletions(-)
 delete mode 100644 .vscode/settings.json
.gitignore +0 -1
index f6ce090b5fc..ec0447356e2 100644
@@ -37,4 +37,3 @@ downloads/
 sstate-cache/
 toaster.sqlite
 .vscode/
-vscode-bitbake-build/
.vscode/settings.json deleted +0 -32
deleted file mode 100644
index 517a86d1bfa..00000000000
@@ -1,32 +0,0 @@
-{
-    "files.watcherExclude": {
-        "**/.git/**": true,
-        "**/cache/**": true,
-        "**/tmp*/**": true,
-        "**/downloads/**": true,
-        "**/sstate-cache/**": true,
-        "**/vscode-bitbake-build/**": true,
-        "**/workspace/sources/**": true,
-        "**/workspace/attic/**": true
-    },
-    "files.exclude": {
-        "**/.git/**": true,
-        "**/cache/**": true,
-        "**/tmp*/**": true,
-        "**/downloads/**": true,
-        "**/sstate-cache/**": true,
-        "**/vscode-bitbake-build/**": true,
-        "**/workspace/sources/**": true,
-        "**/workspace/attic/**": true
-    },
-    "python.analysis.exclude": [
-        "**/.git/**",
-        "**/cache/**",
-        "**/tmp*/**",
-        "**/downloads/**",
-        "**/sstate-cache/**",
-        "**/vscode-bitbake-build/**",
-        "**/workspace/sources/**",
-        "**/workspace/attic/**"
-    ]
-}
Signature · 1 line
2.43.1
#2 lore raw

PATCH v4 2/2 oe-init-build-env: generate .vscode from template

In reply to Adrian Freihofer

Provide a reasonable default configuration for VSCode and the yocto.bitbake extension.
The generated default configuration is generic and minimal. It's mostly supposed to prevent VSCode from OOM exceptions if the build directory is in the scope of the indexer plugins of VSCode.
But it also configures the yocto-bitbake plugin to just work without manual user interaction.

The configuration is only generated if VSCode is installed. Currently, VSCode is one of many popular editors for Yocto/OE. Removing the check would mean that the configuration would be generated by e.g. oe-selftest or for users not using VSCode. If it should prove useful, the check can be removed later.

Customization for other layers is possible. A layer might provide it's own oe-setup-build-env script which calls the oe-setup-vscode script from poky with different folders. But it's also possible to override the oe-setup-vscode script by another layer with a custom implementation.

---
 oe-init-build-env       |  6 +++
 scripts/oe-setup-vscode | 93 +++++++++++++++++++++++++++++++++++++++++
 2 files changed, 99 insertions(+)
 create mode 100755 scripts/oe-setup-vscode
oe-init-build-env +6 -0
index 38333ab8582..82382f27078 100755
@@ -47,6 +47,12 @@ export OEROOT
     unset OEROOT
     return 1
 }
+
+# Generate an initial configuration for VSCode and the yocto-bitbake plugin.
+if command -v code > /dev/null && [ ! -d "$OEROOT/.vscode" ]; then
+    oe-setup-vscode "$OEROOT" "$BUILDDIR"
+fi
+
 unset OEROOT
 
 [ -z "$BUILDDIR" ] || cd "$BUILDDIR"
scripts/oe-setup-vscode new file +93 -0

93 lines not on this page · raw message

Signature · 1 line
2.43.1