diff options
author | Adrian Freihofer <adrian.freihofer@gmail.com> | 2024-02-15 23:53:33 +0100 |
---|---|---|
committer | Richard Purdie <richard.purdie@linuxfoundation.org> | 2024-02-19 11:34:33 +0000 |
commit | dfe98713729ceb329813ac00f6035dcfb470b469 (patch) | |
tree | aadd0cea16bc12138035692acd91f15d31d1dcc5 /scripts | |
parent | a510d455d3b93e2d7c5e1aef7b2dbe7d77d6a03d (diff) | |
download | poky-dfe98713729ceb329813ac00f6035dcfb470b469.tar.gz |
oe-init-build-env: generate .vscode from template
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.
(From OE-Core rev: 48829be7ab2edcbc2e4473f81cdaf35889d63f9c)
Signed-off-by: Adrian Freihofer <adrian.freihofer@siemens.com>
Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org>
Diffstat (limited to 'scripts')
-rwxr-xr-x | scripts/oe-setup-vscode | 93 |
1 files changed, 93 insertions, 0 deletions
diff --git a/scripts/oe-setup-vscode b/scripts/oe-setup-vscode new file mode 100755 index 0000000000..b8642780d5 --- /dev/null +++ b/scripts/oe-setup-vscode | |||
@@ -0,0 +1,93 @@ | |||
1 | #!/bin/sh | ||
2 | |||
3 | usage() { | ||
4 | echo "$0 <OEINIT> <BUILDDIR>" | ||
5 | echo " OEINIT: path to directory where the .vscode folder is" | ||
6 | echo " BUILDDIR: directory passed to the oe-init-setup-env script" | ||
7 | } | ||
8 | |||
9 | if [ "$#" -ne 2 ]; then | ||
10 | usage | ||
11 | exit 1 | ||
12 | fi | ||
13 | |||
14 | OEINIT=$(readlink -f "$1") | ||
15 | BUILDDIR=$(readlink -f "$2") | ||
16 | VSCODEDIR=$OEINIT/.vscode | ||
17 | |||
18 | if [ ! -d "$OEINIT" ] || [ ! -d "$BUILDDIR" ]; then | ||
19 | echo "$OEINIT and/or $BUILDDIR directories are not present." | ||
20 | exit 1 | ||
21 | fi | ||
22 | |||
23 | VSCODE_SETTINGS=$VSCODEDIR/settings.json | ||
24 | ws_builddir="$(echo "$BUILDDIR" | sed -e "s|$OEINIT|\${workspaceFolder}|g")" | ||
25 | |||
26 | # If BUILDDIR is in scope of VSCode ensure VSCode does not try to index the build folder. | ||
27 | # This would lead to a busy CPU and finally to an OOM exception. | ||
28 | mkdir -p "$VSCODEDIR" | ||
29 | cat <<EOMsettings > "$VSCODE_SETTINGS" | ||
30 | { | ||
31 | "bitbake.pathToBitbakeFolder": "\${workspaceFolder}/bitbake", | ||
32 | "bitbake.pathToEnvScript": "\${workspaceFolder}/oe-init-build-env", | ||
33 | "bitbake.pathToBuildFolder": "$ws_builddir", | ||
34 | "bitbake.commandWrapper": "", | ||
35 | "bitbake.workingDirectory": "\${workspaceFolder}", | ||
36 | "files.exclude": { | ||
37 | "**/.git/**": true, | ||
38 | "**/_build/**": true, | ||
39 | "**/buildhistory/**": true, | ||
40 | "**/cache/**": true, | ||
41 | "**/downloads/**": true, | ||
42 | "**/node_modules/**": true, | ||
43 | "**/oe-logs/**": true, | ||
44 | "**/oe-workdir/**": true, | ||
45 | "**/sstate-cache/**": true, | ||
46 | "**/tmp*/**": true, | ||
47 | "**/workspace/attic/**": true, | ||
48 | "**/workspace/sources/**": true | ||
49 | }, | ||
50 | "files.watcherExclude": { | ||
51 | "**/.git/**": true, | ||
52 | "**/_build/**": true, | ||
53 | "**/buildhistory/**": true, | ||
54 | "**/cache/**": true, | ||
55 | "**/downloads/**": true, | ||
56 | "**/node_modules/**": true, | ||
57 | "**/oe-logs/**": true, | ||
58 | "**/oe-workdir/**": true, | ||
59 | "**/sstate-cache/**": true, | ||
60 | "**/tmp*/**": true, | ||
61 | "**/workspace/attic/**": true, | ||
62 | "**/workspace/sources/**": true | ||
63 | }, | ||
64 | "python.analysis.exclude": [ | ||
65 | "**/_build/**", | ||
66 | "**/.git/**", | ||
67 | "**/buildhistory/**", | ||
68 | "**/cache/**", | ||
69 | "**/downloads/**", | ||
70 | "**/node_modules/**", | ||
71 | "**/oe-logs/**", | ||
72 | "**/oe-workdir/**", | ||
73 | "**/sstate-cache/**", | ||
74 | "**/tmp*/**", | ||
75 | "**/workspace/attic/**", | ||
76 | "**/workspace/sources/**" | ||
77 | ] | ||
78 | } | ||
79 | EOMsettings | ||
80 | |||
81 | |||
82 | # Ask the user if the yocto-bitbake extension should be installed | ||
83 | VSCODE_EXTENSIONS=$VSCODEDIR/extensions.json | ||
84 | cat <<EOMextensions > "$VSCODE_EXTENSIONS" | ||
85 | { | ||
86 | "recommendations": [ | ||
87 | "yocto-project.yocto-bitbake" | ||
88 | ] | ||
89 | } | ||
90 | EOMextensions | ||
91 | |||
92 | echo "You had no $VSCODEDIR configuration." | ||
93 | echo "These configuration files have therefore been created for you." | ||