blob: b8642780d57e2a5183bdf60e685038ae24e02c37 [file] [log] [blame]
Patrick Williams73bd93f2024-02-20 08:07:48 -06001#!/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."