public inbox for openembedded-core@lists.openembedded.org
 help / color / mirror / Atom feed
* [PATCH v3 0/2] oe-init-build-env: generate .vscode from template
@ 2024-02-14 17:36 Adrian Freihofer
  2024-02-14 17:36 ` [PATCH v3 1/2] vscode: drop .vscode folder Adrian Freihofer
  2024-02-14 17:36 ` [PATCH v3 2/2] oe-init-build-env: generate .vscode from template Adrian Freihofer
  0 siblings, 2 replies; 6+ messages in thread
From: Adrian Freihofer @ 2024-02-14 17:36 UTC (permalink / raw)
  To: openembedded-core; +Cc: Adrian Freihofer

Changes in comparison to v2:
- Do not integrate with the oe-setup-build or templating infrastructuure.
  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              |  3 +-
 .vscode/settings.json   | 32 ---------------
 oe-init-build-env       |  6 +++
 scripts/oe-setup-vscode | 90 +++++++++++++++++++++++++++++++++++++++++
 4 files changed, 97 insertions(+), 34 deletions(-)
 delete mode 100644 .vscode/settings.json
 create mode 100755 scripts/oe-setup-vscode

-- 
2.43.0



^ permalink raw reply	[flat|nested] 6+ messages in thread

* [PATCH v3 1/2] vscode: drop .vscode folder
  2024-02-14 17:36 [PATCH v3 0/2] oe-init-build-env: generate .vscode from template Adrian Freihofer
@ 2024-02-14 17:36 ` Adrian Freihofer
  2024-02-14 17:36 ` [PATCH v3 2/2] oe-init-build-env: generate .vscode from template Adrian Freihofer
  1 sibling, 0 replies; 6+ messages in thread
From: Adrian Freihofer @ 2024-02-14 17:36 UTC (permalink / raw)
  To: openembedded-core; +Cc: Adrian Freihofer

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

Signed-off-by: Adrian Freihofer <adrian.freihofer@siemens.com>
---
 .gitignore            |  3 +--
 .vscode/settings.json | 32 --------------------------------
 2 files changed, 1 insertion(+), 34 deletions(-)
 delete mode 100644 .vscode/settings.json

diff --git a/.gitignore b/.gitignore
index f6ce090b5fc..ca9b5c8f515 100644
--- a/.gitignore
+++ b/.gitignore
@@ -36,5 +36,4 @@ _toaster_clones/
 downloads/
 sstate-cache/
 toaster.sqlite
-.vscode/
-vscode-bitbake-build/
+.vscode/*
diff --git a/.vscode/settings.json b/.vscode/settings.json
deleted file mode 100644
index 517a86d1bfa..00000000000
--- a/.vscode/settings.json
+++ /dev/null
@@ -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/**"
-    ]
-}
-- 
2.43.0



^ permalink raw reply related	[flat|nested] 6+ messages in thread

* [PATCH v3 2/2] oe-init-build-env: generate .vscode from template
  2024-02-14 17:36 [PATCH v3 0/2] oe-init-build-env: generate .vscode from template Adrian Freihofer
  2024-02-14 17:36 ` [PATCH v3 1/2] vscode: drop .vscode folder Adrian Freihofer
@ 2024-02-14 17:36 ` Adrian Freihofer
  2024-02-14 17:49   ` [OE-core] " Alexander Kanavin
  2024-02-15  8:31   ` Enguerrand de Ribaucourt
  1 sibling, 2 replies; 6+ messages in thread
From: Adrian Freihofer @ 2024-02-14 17:36 UTC (permalink / raw)
  To: openembedded-core; +Cc: 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.

Signed-off-by: Adrian Freihofer <adrian.freihofer@siemens.com>
---
 oe-init-build-env       |  6 +++
 scripts/oe-setup-vscode | 90 +++++++++++++++++++++++++++++++++++++++++
 2 files changed, 96 insertions(+)
 create mode 100755 scripts/oe-setup-vscode

diff --git a/oe-init-build-env b/oe-init-build-env
index 38333ab8582..82382f27078 100755
--- a/oe-init-build-env
+++ b/oe-init-build-env
@@ -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"
diff --git a/scripts/oe-setup-vscode b/scripts/oe-setup-vscode
new file mode 100755
index 00000000000..db1cde4ffb6
--- /dev/null
+++ b/scripts/oe-setup-vscode
@@ -0,0 +1,90 @@
+#!/bin/sh
+
+usage() {
+    echo "$0 <OEINIT> <BUILDDIR>"
+    echo "  OEINIT:   path to directory where the .vscode folder is"
+    echo "  BUILDDIR: directory passed to the oe-init-setup-env script"
+}
+
+if [ "$#" -ne 2 ]; then
+    usage
+    exit 1
+fi
+
+OEINIT=$(readlink -f "$1")
+BUILDDIR=$(readlink -f "$2")
+VSCODEDIR=$OEINIT/.vscode
+
+if [ ! -d "$OEINIT" ] || [ ! -d "$BUILDDIR" ]; then
+    echo "$OEINIT and/or $BUILDDIR directories are not present."
+    exit 1
+fi
+
+VSCODE_SETTINGS=$VSCODEDIR/settings.json
+ws_builddir="$(echo "$BUILDDIR" | sed -e "s|$OEINIT|\${workspaceFolder}|g")"
+
+# If BUILDDIR is in scope of VSCode ensure VSCode does not try to index the build folder.
+# This would lead to a busy CPU and finally to an OOM exception.
+mkdir -p "$VSCODEDIR"
+cat <<EOMsettings > "$VSCODE_SETTINGS"
+{
+    "bitbake.pathToBuildFolder": "$ws_builddir",
+    "bitbake.pathToEnvScript": "\${workspaceFolder}/oe-init-build-env",
+    "files.exclude": {
+        "**/.git/**": true,
+        "**/_build/**": true,
+        "**/buildhistory/**": true,
+        "**/cache/**": true,
+        "**/downloads/**": true,
+        "**/node_modules/**": true,
+        "**/oe-logs/**": true,
+        "**/oe-workdir/**": true,
+        "**/sstate-cache/**": true,
+        "**/tmp*/**": true,
+        "**/workspace/attic/**": true,
+        "**/workspace/sources/**": true
+    },
+    "files.watcherExclude": {
+        "**/.git/**": true,
+        "**/_build/**": true,
+        "**/buildhistory/**": true,
+        "**/cache/**": true,
+        "**/downloads/**": true,
+        "**/node_modules/**": true,
+        "**/oe-logs/**": true,
+        "**/oe-workdir/**": true,
+        "**/sstate-cache/**": true,
+        "**/tmp*/**": true,
+        "**/workspace/attic/**": true,
+        "**/workspace/sources/**": true
+    },
+    "python.analysis.exclude": [
+        "**/_build/**",
+        "**/.git/**",
+        "**/buildhistory/**",
+        "**/cache/**",
+        "**/downloads/**",
+        "**/node_modules/**",
+        "**/oe-logs/**",
+        "**/oe-workdir/**",
+        "**/sstate-cache/**",
+        "**/tmp*/**",
+        "**/workspace/attic/**",
+        "**/workspace/sources/**"
+    ]
+}
+EOMsettings
+
+
+# Ask the user if the yocto-bitbake extension should be installed
+VSCODE_EXTENSIONS=$VSCODEDIR/extensions.json
+cat <<EOMextensions > "$VSCODE_EXTENSIONS"
+{
+    "recommendations": [
+        "yocto-project.yocto-bitbake"
+    ]
+}
+EOMextensions
+
+echo "You had no $VSCODEDIR configuration."
+echo "These configuration files have therefore been created for you."
-- 
2.43.0



^ permalink raw reply related	[flat|nested] 6+ messages in thread

* Re: [OE-core] [PATCH v3 2/2] oe-init-build-env: generate .vscode from template
  2024-02-14 17:36 ` [PATCH v3 2/2] oe-init-build-env: generate .vscode from template Adrian Freihofer
@ 2024-02-14 17:49   ` Alexander Kanavin
  2024-02-14 17:59     ` adrian.freihofer
  2024-02-15  8:31   ` Enguerrand de Ribaucourt
  1 sibling, 1 reply; 6+ messages in thread
From: Alexander Kanavin @ 2024-02-14 17:49 UTC (permalink / raw)
  To: Adrian Freihofer; +Cc: openembedded-core, Adrian Freihofer

Thanks, I have no objections to this version.

Alex

On Wed, 14 Feb 2024 at 18:39, Adrian Freihofer
<adrian.freihofer@gmail.com> wrote:
>
> 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.
>
> Signed-off-by: Adrian Freihofer <adrian.freihofer@siemens.com>
> ---
>  oe-init-build-env       |  6 +++
>  scripts/oe-setup-vscode | 90 +++++++++++++++++++++++++++++++++++++++++
>  2 files changed, 96 insertions(+)
>  create mode 100755 scripts/oe-setup-vscode
>
> diff --git a/oe-init-build-env b/oe-init-build-env
> index 38333ab8582..82382f27078 100755
> --- a/oe-init-build-env
> +++ b/oe-init-build-env
> @@ -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"
> diff --git a/scripts/oe-setup-vscode b/scripts/oe-setup-vscode
> new file mode 100755
> index 00000000000..db1cde4ffb6
> --- /dev/null
> +++ b/scripts/oe-setup-vscode
> @@ -0,0 +1,90 @@
> +#!/bin/sh
> +
> +usage() {
> +    echo "$0 <OEINIT> <BUILDDIR>"
> +    echo "  OEINIT:   path to directory where the .vscode folder is"
> +    echo "  BUILDDIR: directory passed to the oe-init-setup-env script"
> +}
> +
> +if [ "$#" -ne 2 ]; then
> +    usage
> +    exit 1
> +fi
> +
> +OEINIT=$(readlink -f "$1")
> +BUILDDIR=$(readlink -f "$2")
> +VSCODEDIR=$OEINIT/.vscode
> +
> +if [ ! -d "$OEINIT" ] || [ ! -d "$BUILDDIR" ]; then
> +    echo "$OEINIT and/or $BUILDDIR directories are not present."
> +    exit 1
> +fi
> +
> +VSCODE_SETTINGS=$VSCODEDIR/settings.json
> +ws_builddir="$(echo "$BUILDDIR" | sed -e "s|$OEINIT|\${workspaceFolder}|g")"
> +
> +# If BUILDDIR is in scope of VSCode ensure VSCode does not try to index the build folder.
> +# This would lead to a busy CPU and finally to an OOM exception.
> +mkdir -p "$VSCODEDIR"
> +cat <<EOMsettings > "$VSCODE_SETTINGS"
> +{
> +    "bitbake.pathToBuildFolder": "$ws_builddir",
> +    "bitbake.pathToEnvScript": "\${workspaceFolder}/oe-init-build-env",
> +    "files.exclude": {
> +        "**/.git/**": true,
> +        "**/_build/**": true,
> +        "**/buildhistory/**": true,
> +        "**/cache/**": true,
> +        "**/downloads/**": true,
> +        "**/node_modules/**": true,
> +        "**/oe-logs/**": true,
> +        "**/oe-workdir/**": true,
> +        "**/sstate-cache/**": true,
> +        "**/tmp*/**": true,
> +        "**/workspace/attic/**": true,
> +        "**/workspace/sources/**": true
> +    },
> +    "files.watcherExclude": {
> +        "**/.git/**": true,
> +        "**/_build/**": true,
> +        "**/buildhistory/**": true,
> +        "**/cache/**": true,
> +        "**/downloads/**": true,
> +        "**/node_modules/**": true,
> +        "**/oe-logs/**": true,
> +        "**/oe-workdir/**": true,
> +        "**/sstate-cache/**": true,
> +        "**/tmp*/**": true,
> +        "**/workspace/attic/**": true,
> +        "**/workspace/sources/**": true
> +    },
> +    "python.analysis.exclude": [
> +        "**/_build/**",
> +        "**/.git/**",
> +        "**/buildhistory/**",
> +        "**/cache/**",
> +        "**/downloads/**",
> +        "**/node_modules/**",
> +        "**/oe-logs/**",
> +        "**/oe-workdir/**",
> +        "**/sstate-cache/**",
> +        "**/tmp*/**",
> +        "**/workspace/attic/**",
> +        "**/workspace/sources/**"
> +    ]
> +}
> +EOMsettings
> +
> +
> +# Ask the user if the yocto-bitbake extension should be installed
> +VSCODE_EXTENSIONS=$VSCODEDIR/extensions.json
> +cat <<EOMextensions > "$VSCODE_EXTENSIONS"
> +{
> +    "recommendations": [
> +        "yocto-project.yocto-bitbake"
> +    ]
> +}
> +EOMextensions
> +
> +echo "You had no $VSCODEDIR configuration."
> +echo "These configuration files have therefore been created for you."
> --
> 2.43.0
>
>
> -=-=-=-=-=-=-=-=-=-=-=-
> Links: You receive all messages sent to this group.
> View/Reply Online (#195488): https://lists.openembedded.org/g/openembedded-core/message/195488
> Mute This Topic: https://lists.openembedded.org/mt/104357383/1686489
> Group Owner: openembedded-core+owner@lists.openembedded.org
> Unsubscribe: https://lists.openembedded.org/g/openembedded-core/unsub [alex.kanavin@gmail.com]
> -=-=-=-=-=-=-=-=-=-=-=-
>


^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: [OE-core] [PATCH v3 2/2] oe-init-build-env: generate .vscode from template
  2024-02-14 17:49   ` [OE-core] " Alexander Kanavin
@ 2024-02-14 17:59     ` adrian.freihofer
  0 siblings, 0 replies; 6+ messages in thread
From: adrian.freihofer @ 2024-02-14 17:59 UTC (permalink / raw)
  To: Alexander Kanavin; +Cc: openembedded-core

On Wed, 2024-02-14 at 18:49 +0100, Alexander Kanavin wrote:
> Thanks, I have no objections to this version.

I have done my best to take all your ideas into account :-).
I agree, it is much simpler and it still does what is needed to improve
the user experience when working with VSCode, the new yocto-bitbake
plugin as well as with Git (on the command line).

Thank you!
Adrian


> 
> Alex



^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: [PATCH v3 2/2] oe-init-build-env: generate .vscode from template
  2024-02-14 17:36 ` [PATCH v3 2/2] oe-init-build-env: generate .vscode from template Adrian Freihofer
  2024-02-14 17:49   ` [OE-core] " Alexander Kanavin
@ 2024-02-15  8:31   ` Enguerrand de Ribaucourt
  1 sibling, 0 replies; 6+ messages in thread
From: Enguerrand de Ribaucourt @ 2024-02-15  8:31 UTC (permalink / raw)
  To: openembedded-core

Hello Adrian,

I recommend to keep expliciting other vscode-bitbake parameters. In addition to the default config, the user may have overridden the configuration in their global setting. In which case, the unspecified settings in your template will take that value and probably break.

```
    "bitbake.pathToBitbakeFolder": "${workspaceFolder}/bitbake",
    "bitbake.pathToEnvScript": "${workspaceFolder}/oe-init-build-env",
    "bitbake.pathToBuildFolder": "${workspaceFolder}/build",
    "bitbake.commandWrapper": "",
    "bitbake.workingDirectory": "${workspaceFolder}",
```

Thanks for this new feature which is a great way to share the VSCode configs!


^ permalink raw reply	[flat|nested] 6+ messages in thread

end of thread, other threads:[~2024-02-15  8:31 UTC | newest]

Thread overview: 6+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2024-02-14 17:36 [PATCH v3 0/2] oe-init-build-env: generate .vscode from template Adrian Freihofer
2024-02-14 17:36 ` [PATCH v3 1/2] vscode: drop .vscode folder Adrian Freihofer
2024-02-14 17:36 ` [PATCH v3 2/2] oe-init-build-env: generate .vscode from template Adrian Freihofer
2024-02-14 17:49   ` [OE-core] " Alexander Kanavin
2024-02-14 17:59     ` adrian.freihofer
2024-02-15  8:31   ` Enguerrand de Ribaucourt

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox