visual_studio_code.rst 3.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108
  1. .. _doc_configuring_an_ide_vscode:
  2. Visual Studio Code
  3. ==================
  4. `Visual Studio Code <https://code.visualstudio.com>`_ is a free cross-platform IDE
  5. by `Microsoft <https://microsoft.com>`_ (not to be confused with :ref:`doc_configuring_an_ide_vs`).
  6. Importing the project
  7. ---------------------
  8. - Make sure the C/C++ extension is installed. You can find instructions in
  9. the `official documentation <https://code.visualstudio.com/docs/languages/cpp>`_.
  10. - From the Visual Studio Code's main screen open the Godot root folder with
  11. **File > Open Folder...**.
  12. - Press :kbd:`Ctrl + Shift + P` to open the command prompt window and enter *Configure Task*.
  13. .. figure:: img/vscode_configure_task.png
  14. :align: center
  15. - Select the **Create tasks.json file from template** option.
  16. .. figure:: img/vscode_create_tasksjson.png
  17. :align: center
  18. - Then select **Others**.
  19. .. figure:: img/vscode_create_tasksjson_others.png
  20. :align: center
  21. - Within the ``tasks.json`` file find the ``"tasks"`` array and add a new section to it:
  22. .. code-block:: js
  23. {
  24. "label": "build",
  25. "type": "shell",
  26. "command": "scons",
  27. "group": "build",
  28. "args": [
  29. "platform=linuxbsd", // Change to your current platform
  30. "target=debug",
  31. "-j4"
  32. ],
  33. "problemMatcher": "$msCompile"
  34. }
  35. .. figure:: img/vscode_3_tasks.json.png
  36. :figclass: figure-w480
  37. :align: center
  38. An example of a filled out ``tasks.json``.
  39. Arguments can be different based on your own setup and needs. See
  40. :ref:`doc_introduction_to_the_buildsystem` for a full list of arguments.
  41. Debugging the project
  42. ---------------------
  43. To run and debug the project you need to create a new configuration in the ``launch.json`` file.
  44. - Press :kbd:`Ctrl + Shift + D` to open the Run panel.
  45. - If ``launch.json`` file is missing you will be prompted to create a new one.
  46. .. figure:: img/vscode_1_create_launch.json.png
  47. :align: center
  48. - Select **C++ (GDB/LLDB)**. There may be another platform specific option here. If selected,
  49. adjust the configuration example provided accordingly.
  50. - Within the ``launch.json`` file find the ``"configurations"`` array and add a new section to it:
  51. .. code-block:: js
  52. {
  53. "name": "Launch",
  54. "type": "cppdbg",
  55. "request": "launch",
  56. // Change the path below to match your current platform.
  57. "program": "${workspaceFolder}/bin/godot.linuxbsd.tools.64",
  58. // Change the arguments below for the project you want to test with.
  59. // To run the project instead of editing it, remove the "--editor" argument.
  60. "args": [ "--editor", "--path", "path-to-your-godot-project-folder" ],
  61. "stopAtEntry": false,
  62. "cwd": "${workspaceFolder}",
  63. "environment": [],
  64. "externalConsole": true,
  65. "MIMode": "gdb",
  66. "setupCommands": [
  67. {
  68. "description": "Enable pretty-printing for gdb",
  69. "text": "-enable-pretty-printing",
  70. "ignoreFailures": true
  71. }
  72. ],
  73. "preLaunchTask": "build"
  74. }
  75. .. figure:: img/vscode_2_launch.json.png
  76. :figclass: figure-w480
  77. :align: center
  78. An example of a filled out ``launch.json``.
  79. The name under ``program`` depends on your build configuration,
  80. e.g. ``godot.linuxbsd.tools.64`` for 64-bit LinuxBSD platform with ``tools`` enabled.
  81. If you run into any issues, ask for help in one of
  82. `Godot's community channels <https://godotengine.org/community>`__.