oe-setup-vscode 2.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293
  1. #!/bin/sh
  2. usage() {
  3. echo "$0 <OEINIT> <BUILDDIR>"
  4. echo " OEINIT: path to directory where the .vscode folder is"
  5. echo " BUILDDIR: directory passed to the oe-init-setup-env script"
  6. }
  7. if [ "$#" -ne 2 ]; then
  8. usage
  9. exit 1
  10. fi
  11. OEINIT=$(readlink -f "$1")
  12. BUILDDIR=$(readlink -f "$2")
  13. VSCODEDIR=$OEINIT/.vscode
  14. if [ ! -d "$OEINIT" ] || [ ! -d "$BUILDDIR" ]; then
  15. echo "$OEINIT and/or $BUILDDIR directories are not present."
  16. exit 1
  17. fi
  18. VSCODE_SETTINGS=$VSCODEDIR/settings.json
  19. ws_builddir="$(echo "$BUILDDIR" | sed -e "s|$OEINIT|\${workspaceFolder}|g")"
  20. # If BUILDDIR is in scope of VSCode ensure VSCode does not try to index the build folder.
  21. # This would lead to a busy CPU and finally to an OOM exception.
  22. mkdir -p "$VSCODEDIR"
  23. cat <<EOMsettings > "$VSCODE_SETTINGS"
  24. {
  25. "bitbake.pathToBitbakeFolder": "\${workspaceFolder}/bitbake",
  26. "bitbake.pathToEnvScript": "\${workspaceFolder}/oe-init-build-env",
  27. "bitbake.pathToBuildFolder": "$ws_builddir",
  28. "bitbake.commandWrapper": "",
  29. "bitbake.workingDirectory": "\${workspaceFolder}",
  30. "files.exclude": {
  31. "**/.git/**": true,
  32. "**/_build/**": true,
  33. "**/buildhistory/**": true,
  34. "**/cache/**": true,
  35. "**/downloads/**": true,
  36. "**/node_modules/**": true,
  37. "**/oe-logs/**": true,
  38. "**/oe-workdir/**": true,
  39. "**/sstate-cache/**": true,
  40. "**/tmp*/**": true,
  41. "**/workspace/attic/**": true,
  42. "**/workspace/sources/**": true
  43. },
  44. "files.watcherExclude": {
  45. "**/.git/**": true,
  46. "**/_build/**": true,
  47. "**/buildhistory/**": true,
  48. "**/cache/**": true,
  49. "**/downloads/**": true,
  50. "**/node_modules/**": true,
  51. "**/oe-logs/**": true,
  52. "**/oe-workdir/**": true,
  53. "**/sstate-cache/**": true,
  54. "**/tmp*/**": true,
  55. "**/workspace/attic/**": true,
  56. "**/workspace/sources/**": true
  57. },
  58. "python.analysis.exclude": [
  59. "**/_build/**",
  60. "**/.git/**",
  61. "**/buildhistory/**",
  62. "**/cache/**",
  63. "**/downloads/**",
  64. "**/node_modules/**",
  65. "**/oe-logs/**",
  66. "**/oe-workdir/**",
  67. "**/sstate-cache/**",
  68. "**/tmp*/**",
  69. "**/workspace/attic/**",
  70. "**/workspace/sources/**"
  71. ]
  72. }
  73. EOMsettings
  74. # Ask the user if the yocto-bitbake extension should be installed
  75. VSCODE_EXTENSIONS=$VSCODEDIR/extensions.json
  76. cat <<EOMextensions > "$VSCODE_EXTENSIONS"
  77. {
  78. "recommendations": [
  79. "yocto-project.yocto-bitbake"
  80. ]
  81. }
  82. EOMextensions
  83. echo "You had no $VSCODEDIR configuration."
  84. echo "These configuration files have therefore been created for you."