summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rwxr-xr-xoe-init-build-env6
-rwxr-xr-xscripts/oe-setup-vscode93
2 files changed, 99 insertions, 0 deletions
diff --git a/oe-init-build-env b/oe-init-build-env
index 38333ab858..82382f2707 100755
--- a/oe-init-build-env
+++ b/oe-init-build-env
@@ -47,6 +47,12 @@ export OEROOT
47 unset OEROOT 47 unset OEROOT
48 return 1 48 return 1
49} 49}
50
51# Generate an initial configuration for VSCode and the yocto-bitbake plugin.
52if command -v code > /dev/null && [ ! -d "$OEROOT/.vscode" ]; then
53 oe-setup-vscode "$OEROOT" "$BUILDDIR"
54fi
55
50unset OEROOT 56unset OEROOT
51 57
52[ -z "$BUILDDIR" ] || cd "$BUILDDIR" 58[ -z "$BUILDDIR" ] || cd "$BUILDDIR"
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
3usage() {
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
9if [ "$#" -ne 2 ]; then
10 usage
11 exit 1
12fi
13
14OEINIT=$(readlink -f "$1")
15BUILDDIR=$(readlink -f "$2")
16VSCODEDIR=$OEINIT/.vscode
17
18if [ ! -d "$OEINIT" ] || [ ! -d "$BUILDDIR" ]; then
19 echo "$OEINIT and/or $BUILDDIR directories are not present."
20 exit 1
21fi
22
23VSCODE_SETTINGS=$VSCODEDIR/settings.json
24ws_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.
28mkdir -p "$VSCODEDIR"
29cat <<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}
79EOMsettings
80
81
82# Ask the user if the yocto-bitbake extension should be installed
83VSCODE_EXTENSIONS=$VSCODEDIR/extensions.json
84cat <<EOMextensions > "$VSCODE_EXTENSIONS"
85{
86 "recommendations": [
87 "yocto-project.yocto-bitbake"
88 ]
89}
90EOMextensions
91
92echo "You had no $VSCODEDIR configuration."
93echo "These configuration files have therefore been created for you."