diff mbox series

[02/14] build: vscode configuration

Message ID 20230821161120.171956-3-adrian.freihofer@siemens.com
State New
Headers show
Series devtool ide plugin | expand

Commit Message

Adrian Freihofer Aug. 21, 2023, 4:07 p.m. UTC
This is just my setup. It's not supposed to be merged into poky.
However, it could be useful to have something similar in poky because
if VSCode tries to index the build folder it runs until the OOM killer
stops it. Depending on the configuration of the OOM killer it's also
very likely that some other randomly selected tasks get killed.
---
 .vscode/extensions.json | 11 +++++++++++
 .vscode/launch.json     | 27 +++++++++++++++++++++++++++
 .vscode/settings.json   | 30 ++++++++++++++++++++++++++++++
 oe-init-build-env       |  8 ++++++++
 4 files changed, 76 insertions(+)
 create mode 100644 .vscode/extensions.json
 create mode 100644 .vscode/launch.json
 create mode 100644 .vscode/settings.json

Comments

Luca Ceresoli Aug. 21, 2023, 7:56 p.m. UTC | #1
Hello Adrian,

On Mon, 21 Aug 2023 18:07:05 +0200
"Adrian Freihofer" <adrian.freihofer@gmail.com> wrote:

> This is just my setup. It's not supposed to be merged into poky.

If this not supposed to me merged, clarifying that on the subject line
would be nice (e.g. add "**** DO NOT MERGE ****")  to not overlook that,
as well as moving this patch at the end of the series IMO.

Luca
Freihofer, Adrian Aug. 21, 2023, 9:46 p.m. UTC | #2
On Mon, 2023-08-21 at 21:56 +0200, Luca Ceresoli wrote:
> Hello Adrian,
> 
> On Mon, 21 Aug 2023 18:07:05 +0200
> "Adrian Freihofer" <adrian.freihofer@gmail.com> wrote:
> 
> > This is just my setup. It's not supposed to be merged into poky.
> 
> If this not supposed to me merged, clarifying that on the subject
> line
> would be nice (e.g. add "**** DO NOT MERGE ****")  to not overlook
> that,
> as well as moving this patch at the end of the series IMO.


Thank you for the hint. I will update it as soon as I get more
feedback.

But we should probably discuss this a bit more. When VSCode is used to
work on a meta layer (e.g. poky), some indexer plugins start indexing
the code. In the case of a meta-layer repository, the build folder can
be very large and it is very important to configure VSCode to ignore
it. Otherwise, the plugins will run with 100% CPU load until an OOM
exception occurs. In practice, this makes VSCode more or less unusable
for working with Yocto until a file like the one added by this patch is
deployed before VSCode starts. And from the user's point of view, it is
not obvious why the system runs at 100% CPU load and eventually
crashes. In other words: If you don't have this patch, you will hate
VSCode as a Yocto developer.

It is even more misleading that VSCode starts the indexers immediately,
but does not stop or reconfigure them when the ignore list is updated.
In practice, this means that every time the ignore list is changed,
VSCode immediately starts indexing the build folder until the OOM
exception stops it. Depending on the system's OOM handler, the entire
build machine may crash.

Particularly annoying is the Python plugin that ignores the general
ignore list and requires an extra ignore section.

However, putting a static file in poky doesn't look like a good
solution. Depending on the setup, the configuration here is not valid.
A better approach would be to handle this in the bitbake plugin. But
even that looks kind of wrong, because why should the bitbake plugin
configure other indexer plugins? Other ideas would be to have the
configuration file generated by the layer setup tool or simply cover
this topic in the documentation.

Regards,
Adrian

> 
> Luca
>
Alexander Kanavin Aug. 22, 2023, 10 a.m. UTC | #3
It's probably simpler to enforce that the build folder is not under
poky/ if I understand this right? How is it created, and at which
point?

Alex

On Mon, 21 Aug 2023 at 23:46, Adrian Freihofer via
lists.openembedded.org
<adrian.freihofer=siemens.com@lists.openembedded.org> wrote:
>
> On Mon, 2023-08-21 at 21:56 +0200, Luca Ceresoli wrote:
> > Hello Adrian,
> >
> > On Mon, 21 Aug 2023 18:07:05 +0200
> > "Adrian Freihofer" <adrian.freihofer@gmail.com> wrote:
> >
> > > This is just my setup. It's not supposed to be merged into poky.
> >
> > If this not supposed to me merged, clarifying that on the subject
> > line
> > would be nice (e.g. add "**** DO NOT MERGE ****")  to not overlook
> > that,
> > as well as moving this patch at the end of the series IMO.
>
>
> Thank you for the hint. I will update it as soon as I get more
> feedback.
>
> But we should probably discuss this a bit more. When VSCode is used to
> work on a meta layer (e.g. poky), some indexer plugins start indexing
> the code. In the case of a meta-layer repository, the build folder can
> be very large and it is very important to configure VSCode to ignore
> it. Otherwise, the plugins will run with 100% CPU load until an OOM
> exception occurs. In practice, this makes VSCode more or less unusable
> for working with Yocto until a file like the one added by this patch is
> deployed before VSCode starts. And from the user's point of view, it is
> not obvious why the system runs at 100% CPU load and eventually
> crashes. In other words: If you don't have this patch, you will hate
> VSCode as a Yocto developer.
>
> It is even more misleading that VSCode starts the indexers immediately,
> but does not stop or reconfigure them when the ignore list is updated.
> In practice, this means that every time the ignore list is changed,
> VSCode immediately starts indexing the build folder until the OOM
> exception stops it. Depending on the system's OOM handler, the entire
> build machine may crash.
>
> Particularly annoying is the Python plugin that ignores the general
> ignore list and requires an extra ignore section.
>
> However, putting a static file in poky doesn't look like a good
> solution. Depending on the setup, the configuration here is not valid.
> A better approach would be to handle this in the bitbake plugin. But
> even that looks kind of wrong, because why should the bitbake plugin
> configure other indexer plugins? Other ideas would be to have the
> configuration file generated by the layer setup tool or simply cover
> this topic in the documentation.
>
> Regards,
> Adrian
>
> >
> > Luca
> >
>
>
> -=-=-=-=-=-=-=-=-=-=-=-
> Links: You receive all messages sent to this group.
> View/Reply Online (#186485): https://lists.openembedded.org/g/openembedded-core/message/186485
> Mute This Topic: https://lists.openembedded.org/mt/100876148/1686489
> Group Owner: openembedded-core+owner@lists.openembedded.org
> Unsubscribe: https://lists.openembedded.org/g/openembedded-core/unsub [alex.kanavin@gmail.com]
> -=-=-=-=-=-=-=-=-=-=-=-
>
Freihofer, Adrian Aug. 22, 2023, 7:11 p.m. UTC | #4
On Tue, 2023-08-22 at 12:00 +0200, Alexander Kanavin wrote:
> It's probably simpler to enforce that the build folder is not under
> poky/ if I understand this right? How is it created, and at which
> point?
Do you mean something like this:

cd poky
. oe-init-build-env ../poky-build

Yes, it would probably work. But moving the build folder would break a
long-established standard. I'm not sure if such a change would be
accepted by the users.

I will send a v2 with a minimalistic, static settings.json file added
to git. It covers all build folder under poky. I tried several
different things and this looks like the best solution to me.

Regards,
Adrian


> Alex
> 
> On Mon, 21 Aug 2023 at 23:46, Adrian Freihofer via
> lists.openembedded.org
> <adrian.freihofer=siemens.com@lists.openembedded.org> wrote:
> > 
> > On Mon, 2023-08-21 at 21:56 +0200, Luca Ceresoli wrote:
> > > Hello Adrian,
> > > 
> > > On Mon, 21 Aug 2023 18:07:05 +0200
> > > "Adrian Freihofer" <adrian.freihofer@gmail.com> wrote:
> > > 
> > > > This is just my setup. It's not supposed to be merged into
> > > > poky.
> > > 
> > > If this not supposed to me merged, clarifying that on the subject
> > > line
> > > would be nice (e.g. add "**** DO NOT MERGE ****")  to not
> > > overlook
> > > that,
> > > as well as moving this patch at the end of the series IMO.
> > 
> > 
> > Thank you for the hint. I will update it as soon as I get more
> > feedback.
> > 
> > But we should probably discuss this a bit more. When VSCode is used
> > to
> > work on a meta layer (e.g. poky), some indexer plugins start
> > indexing
> > the code. In the case of a meta-layer repository, the build folder
> > can
> > be very large and it is very important to configure VSCode to
> > ignore
> > it. Otherwise, the plugins will run with 100% CPU load until an OOM
> > exception occurs. In practice, this makes VSCode more or less
> > unusable
> > for working with Yocto until a file like the one added by this
> > patch is
> > deployed before VSCode starts. And from the user's point of view,
> > it is
> > not obvious why the system runs at 100% CPU load and eventually
> > crashes. In other words: If you don't have this patch, you will
> > hate
> > VSCode as a Yocto developer.
> > 
> > It is even more misleading that VSCode starts the indexers
> > immediately,
> > but does not stop or reconfigure them when the ignore list is
> > updated.
> > In practice, this means that every time the ignore list is changed,
> > VSCode immediately starts indexing the build folder until the OOM
> > exception stops it. Depending on the system's OOM handler, the
> > entire
> > build machine may crash.
> > 
> > Particularly annoying is the Python plugin that ignores the general
> > ignore list and requires an extra ignore section.
> > 
> > However, putting a static file in poky doesn't look like a good
> > solution. Depending on the setup, the configuration here is not
> > valid.
> > A better approach would be to handle this in the bitbake plugin.
> > But
> > even that looks kind of wrong, because why should the bitbake
> > plugin
> > configure other indexer plugins? Other ideas would be to have the
> > configuration file generated by the layer setup tool or simply
> > cover
> > this topic in the documentation.
> > 
> > Regards,
> > Adrian
> > 
> > > 
> > > Luca
> > > 
> > 
> > 
> > 
> > 
> 
> -=-=-=-=-=-=-=-=-=-=-=-
> Links: You receive all messages sent to this group.
> View/Reply Online (#186500):
> https://lists.openembedded.org/g/openembedded-core/message/186500
> Mute This Topic: https://lists.openembedded.org/mt/100876148/4454582
> Group Owner: openembedded-core+owner@lists.openembedded.org
> Unsubscribe:
> https://lists.openembedded.org/g/openembedded-core/unsub [
> adrian.freihofer@gmail.com]
> -=-=-=-=-=-=-=-=-=-=-=-
>
Alexander Kanavin Aug. 22, 2023, 8:09 p.m. UTC | #5
On Tue, 22 Aug 2023 at 21:11, Freihofer, Adrian
<adrian.freihofer@siemens.com> wrote:
> Do you mean something like this:
>
> cd poky
> . oe-init-build-env ../poky-build
>
> Yes, it would probably work. But moving the build folder would break a
> long-established standard. I'm not sure if such a change would be
> accepted by the users.

I'm not sure there's a standard. You can do

. /path/to/poky/oe-init-build-env

from any directory, and the build directory will be made there, and
not in poky/. As long as you don't let users run oe-init-build-env
directly (such as with upcoming oe-setup-build :) we should be fine?

A more radical idea is to indeed prevent build directories from being
created under poky/ directly in oe-init-build-env. I'll be everyone's
favorite blame target again for this.

Alex
Freihofer, Adrian Aug. 22, 2023, 8:28 p.m. UTC | #6
On Tue, 2023-08-22 at 22:09 +0200, Alexander Kanavin wrote:
> On Tue, 22 Aug 2023 at 21:11, Freihofer, Adrian
> <adrian.freihofer@siemens.com> wrote:
> > Do you mean something like this:
> > 
> > cd poky
> > . oe-init-build-env ../poky-build
> > 
> > Yes, it would probably work. But moving the build folder would
> > break a
> > long-established standard. I'm not sure if such a change would be
> > accepted by the users.
> 
> I'm not sure there's a standard. You can do
> 
> . /path/to/poky/oe-init-build-env

With "standard" I mean that just doing

. oe-init-biuld-env

is what probably most manuals suggest and what most users expect to
work. But with VSCode it does not until there is a settings.json. I
just sent a v2 which adds a static settings.json file to
git: https://lists.openembedded.org/g/openembedded-core/message/186524
The globs in the settings.json should cover all build folders which are
inside the poky folder. For a build folder outside of the poky folder
it does not harm.

> 
> from any directory, and the build directory will be made there, and
> not in poky/. As long as you don't let users run oe-init-build-env
> directly (such as with upcoming oe-setup-build :) we should be fine?

Yes, that would be nice. But it does not cover all possible cases.

Adrian
> 
> A more radical idea is to indeed prevent build directories from being
> created under poky/ directly in oe-init-build-env. I'll be everyone's
> favorite blame target again for this.


> 
> Alex
> 
> -=-=-=-=-=-=-=-=-=-=-=-
> Links: You receive all messages sent to this group.
> View/Reply Online (#186537):
> https://lists.openembedded.org/g/openembedded-core/message/186537
> Mute This Topic: https://lists.openembedded.org/mt/100876148/4454582
> Group Owner: openembedded-core+owner@lists.openembedded.org
> Unsubscribe:
> https://lists.openembedded.org/g/openembedded-core/unsub [
> adrian.freihofer@gmail.com]
> -=-=-=-=-=-=-=-=-=-=-=-
>
diff mbox series

Patch

diff --git a/.vscode/extensions.json b/.vscode/extensions.json
new file mode 100644
index 00000000000..09983dbc0dc
--- /dev/null
+++ b/.vscode/extensions.json
@@ -0,0 +1,11 @@ 
+{
+    "recommendations": [
+        "EditorConfig.EditorConfig",
+        "EugenWiens.bitbake",
+        "maattdd.gitless",
+        "ms-python.isort",
+        "ms-python.python",
+        "ms-python.vscode-pylance",
+        "timonwong.shellcheck",
+    ]
+}
diff --git a/.vscode/launch.json b/.vscode/launch.json
new file mode 100644
index 00000000000..145d2ab3e8c
--- /dev/null
+++ b/.vscode/launch.json
@@ -0,0 +1,27 @@ 
+{
+    // Use IntelliSense to learn about possible attributes.
+    // Hover to view descriptions of existing attributes.
+    // For more information, visit: https://go.microsoft.com/fwlink/?linkid=830387
+    "version": "0.2.0",
+    "configurations": [
+        {
+            "name": "Python: bitbake -T-1 --server-only",
+            "type": "python",
+            "request": "launch",
+            "program": "${workspaceFolder}/bitbake/bin/bitbake",
+            "args": ["-T-1", "--server-only", "-DDD"],
+            "cwd": "${workspaceFolder}/build",
+            "envFile": "${workspaceFolder}/oe-init-build-env",
+            "console": "integratedTerminal",
+            "justMyCode": true
+        },
+        {
+            "name": "Python: Current File",
+            "type": "python",
+            "request": "launch",
+            "program": "${file}",
+            "console": "integratedTerminal",
+            "justMyCode": true
+        }
+    ]
+}
\ No newline at end of file
diff --git a/.vscode/settings.json b/.vscode/settings.json
new file mode 100644
index 00000000000..4b61b35e1aa
--- /dev/null
+++ b/.vscode/settings.json
@@ -0,0 +1,30 @@ 
+{
+    // Configure glob patterns of file paths to exclude from file watching. Patterns must match on absolute paths (i.e. prefix with ** or the full path to match properly). Changing this setting requires a restart. When you experience Code consuming lots of CPU time on startup, you can exclude large folders to reduce the initial load.
+    "files.watcherExclude": {
+        "**/.git/**": true,
+        "**/build*/cache/**": true,
+        "**/build*/tmp/**": true,
+        "**/downloads/**": true,
+        "**/sstate-cache/**": true,
+        "**/vscode-bitbake-build/**": true,
+        "**/workspace/sources/**": true
+    },
+    // Configure glob patterns for excluding files and folders. For example, the files explorer decides which files and folders to show or hide based on this setting.
+    "files.exclude": {
+        "**/.git/**": true,
+        "**/build*/cache/**": true,
+        "**/build*/tmp/**": true,
+        "**/downloads/**": true,
+        "**/sstate-cache/**": true,
+        "**/vscode-bitbake-build/**": true,
+        "**/workspace/sources/**": true
+    },
+    "python.analysis.exclude": [
+        "**/.git/**",
+        "**/build*/**",
+        "**/downloads/**",
+        "**/sstate-cache/**",
+        "**/vscode-bitbake-build/**",
+        "**/workspace/sources/**"
+    ]
+}
diff --git a/oe-init-build-env b/oe-init-build-env
index 38333ab8582..450ae71788c 100755
--- a/oe-init-build-env
+++ b/oe-init-build-env
@@ -51,3 +51,11 @@  unset OEROOT
 
 [ -z "$BUILDDIR" ] || cd "$BUILDDIR"
 
+
+# Generate a minimal env file which can be used e.g. to debug bitbake with a Python debugger
+cat << EOFbuildenv > $BUILDDIR/.buildenv
+BBPATH="$BBPATH"
+BUILDDIR="$BUILDDIR"
+PATH="$PATH"
+BB_ENV_PASSTHROUGH_ADDITIONS="$BB_ENV_PASSTHROUGH_ADDITIONS"
+EOFbuildenv