configuring_an_ide.rst 10 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298
  1. .. _doc_configuring_an_ide:
  2. Configuring an IDE
  3. ==================
  4. We assume that you already `cloned <https://github.com/godotengine/godot>`_
  5. and :ref:`compiled <toc-devel-compiling>` Godot.
  6. You can easily develop Godot with any text editor and by invoking ``scons``
  7. on the command line, but if you want to work with an IDE (Integrated
  8. Development Environment), here are setup instructions for some popular ones:
  9. - :ref:`Qt Creator <doc_configuring_an_ide_qtcreator>` (all desktop platforms)
  10. - :ref:`Kdevelop <doc_configuring_an_ide_kdevelop>` (all desktop platforms)
  11. - :ref:`Xcode <doc_configuring_an_ide_xcode>` (macOS)
  12. - :ref:`Visual Studio <doc_compiling_for_windows_install_vs>` (Windows)
  13. - :ref:`Visual Studio Code<doc_configuring_an_ide_vscode>` (all desktop platforms)
  14. It is possible to use other IDEs, but their setup is not documented yet.
  15. .. _doc_configuring_an_ide_qtcreator:
  16. Qt Creator
  17. ----------
  18. Importing the project
  19. ^^^^^^^^^^^^^^^^^^^^^
  20. - Choose *New Project* -> *Import Project* -> *Import Existing Project*.
  21. .. image:: img/qtcreator-new-project.png
  22. - Set the path to your Godot root directory and enter the project name.
  23. .. image:: img/qtcreator-set-project-path.png
  24. - Here you can choose which folders and files will be visible to the project. C/C++ files
  25. are added automatically. Potentially useful additions: \*.py for buildsystem files, \*.java for Android development,
  26. \*.mm for macOS. Click "Next".
  27. .. image:: img/qtcreator-apply-import-filter.png
  28. - Click *Finish*.
  29. - Add a line containing ``.`` to *project_name.includes* to get working code completion.
  30. .. image:: img/qtcreator-project-name-includes.png
  31. Build and run
  32. ^^^^^^^^^^^^^
  33. Build configuration:
  34. - Click on *Projects* and open the *Build* tab.
  35. - Delete the pre-defined ``make`` build step.
  36. .. image:: img/qtcreator-projects-build.png
  37. - Click *Add Build Step* -> *Custom Process Step*.
  38. .. image:: img/qtcreator-add-custom-process-step.png
  39. - Type ``scons`` in the *Command* field. If it fails with 'Could not start process "scons"',
  40. it can mean that ``scons`` is not in your ``PATH`` environment variable, so you may have to
  41. use the full path to the SCons binary.
  42. - Fill the *Arguments* field with your compilation options. (e.g.: ``p=x11 target=debug -j 4``)
  43. .. image:: img/qtcreator-set-scons-command.png
  44. Run configuration:
  45. - Open the *Run* tab.
  46. - Point the *Executable* to your compiled Godot binary (e.g: ``%{buildDir}/bin/godot.x11.opt.tools.64``)
  47. - If you want to run a specific game or project, point *Working directory* to the game directory.
  48. - If you want to run the editor, add ``-e`` to the *Command line arguments* field.
  49. .. image:: img/qtcreator-run-command.png
  50. Updating sources after pulling latest commits
  51. ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  52. As a developer you usually want to frequently pull the latest commits
  53. from the upstream git repository or a specific fork etc. However this
  54. brings a little problem with it: as the development continues, source files
  55. (and folders) are added or removed. These changes needs to be reflected in
  56. your project files for Qt Creator too, so you continue to have a nice
  57. experience coding in it. A simple way to check these things, is to right click
  58. at your root folder in the "Projects View" and click on "Edit files..."
  59. .. image:: img/qtcreator-edit-files-menu.png
  60. Now a new dialog should appear that is similar in functionality to the one in the third step
  61. of the "Importing the project" section. Here now you can check whether you want to add/remove
  62. specific files and/or folders. You can chose by clicking with your mouse or just simply by
  63. clicking the "Apply Filter" button. A simple click on "Ok" and you're ready to continue your work.
  64. .. image:: img/qtcreator-edit-files-dialog.png
  65. Code style configuration
  66. ^^^^^^^^^^^^^^^^^^^^^^^^
  67. Developers must follow the project's :ref:`code style <doc_code_style_guidelines>`
  68. and IDE should help them to do it. By default, Qt Creator does use spaces for indentation
  69. which is incorrect for Godot project. You can change this behavior by
  70. changing the "Code Style" in *Options* -> *C++*.
  71. .. image:: img/qtcreator-options-cpp.png
  72. Click on *Edit* to change the current settings, then click on *Copy Built-in Code Style* button
  73. to set a new code style. Set a name for it (e.g. Godot) and change the Tab policy
  74. to be *Tabs Only*.
  75. .. image:: img/qtcreator-edit-codestyle.png
  76. .. _doc_configuring_an_ide_kdevelop:
  77. KDevelop
  78. --------
  79. `KDevelop <https://www.kdevelop.org>`_ is a free, open source IDE for all desktop platforms.
  80. You can find a video tutorial `here <https://www.youtube.com/watch?v=yNVoWQi9TJA>`_.
  81. Or you may follow this text version tutorial.
  82. Start by opening KDevelop and choosing "open project".
  83. .. image:: img/kdevelop_newproject.png
  84. Choose the directory where you cloned Godot.
  85. On the next screen, choose "Custom Build System" for the *Project manager*.
  86. .. image:: img/kdevelop_custombuild.png
  87. Now that the project has been imported, open the project configuration.
  88. .. image:: img/kdevelop_openconfig.png
  89. Add the following includes/imports:
  90. ::
  91. . // a dot to indicate the root of the Godot project
  92. core/
  93. core/os/
  94. core/math/
  95. drivers/
  96. platform/x11/ // make that platform/osx/ if you're using macOS
  97. .. image:: img/kdevelop_addincludes.png
  98. Apply the changes.
  99. Switch to the "Custom Build System" tab. Add a build configuration
  100. and keep the build directory blank. Enable build tools and add ``scons``
  101. as the executable then add ``platform=x11 target=debug`` (``platform=osx``
  102. if you're on macOS) as the arguments.
  103. .. image:: img/kdevelop_buildconfig.png
  104. Next we need to tell KDevelop where to find the binary.
  105. From the "Run" menu, choose "Configure Launches".
  106. .. image:: img/kdevelop_configlaunches.png
  107. Click "Add" if no launcher exists. Then add the path to your
  108. executable in the executable section. Your executable should be located
  109. in the ``bin/`` sub-directory and should be named something like
  110. ``godot.x11.tools.64`` (the name could be different depending on your
  111. platform and depending on your build options).
  112. .. image:: img/kdevelop_configlaunches2.png
  113. That's it! Now you should be good to go :)
  114. .. _doc_configuring_an_ide_xcode:
  115. Xcode
  116. -----
  117. Project setup
  118. ^^^^^^^^^^^^^
  119. - Create an Xcode external build project anywhere
  120. .. image:: img/xcode_1_create_external_build_project.png
  121. - Set the *Build tool* to the path to scons
  122. Modify Build Target's Xcode Info Tab:
  123. - Set *Arguments* to something like: platform=osx tools=yes bits=64 target=debug
  124. - Set *Directory* to the path to Godot's source folder. Keep it blank if project is already there.
  125. - You may uncheck *Pass build settings in environment*
  126. .. image:: img/xcode_2_configure_scons.png
  127. Add a Command Line Target:
  128. - Go to Xcode File > New > Target... and add a new Xcode command line target
  129. .. image:: img/xcode_3_add_new_target.png
  130. .. image:: img/xcode_4_select_command_line_target.png
  131. - Name it something so you know not to compile with this target
  132. - e.g. ``GodotXcodeIndex``
  133. - Goto the newly created target's *Build Settings* tab and search for *Header Search Paths*
  134. - Set *Header Search Paths* to an absolute path to Godot's source folder
  135. - Make it recursive by adding two \*'s to the end of the path
  136. - e.g. ``/Users/me/repos/godot-source/\**``
  137. Add Godot Source to the Project:
  138. - Drag and drop Godot source into project file browser.
  139. - Uncheck *Create External Build System*
  140. .. image:: img/xcode_5_after_add_godot_source_to_project.png
  141. - Click Next
  142. - Select *create groups*
  143. .. image:: img/xcode_6_after_add_godot_source_to_project_2.png
  144. - Check off only your command line target in the *Add to targets* section
  145. - Click finish. Xcode will now index the files.
  146. - Grab a cup of coffee... Maybe make something to eat, too
  147. - You should have jump to definition, auto completion, and full syntax highlighting when it is done.
  148. Scheme setup
  149. ^^^^^^^^^^^^
  150. Edit Build Scheme of External Build Target:
  151. - Open scheme editor of external build target
  152. - Expand the *Build* menu
  153. - Goto *Post Actions*
  154. - Add a new script run action, select your project in ``Provide build settings from`` as this allows you to use ``${PROJECT_DIR}`` variable.
  155. .. image:: img/xcode_7_setup_build_post_action.png
  156. - Write a script that gives the binary a name that Xcode will recognize
  157. - e.g. ``ln -f ${PROJECT_DIR}/godot/bin/godot.osx.tools.64 ${PROJECT_DIR}/godot/bin/godot``
  158. - Build the external build target
  159. Edit Run Scheme of External Build Target:
  160. - Open the scheme editor again
  161. - Click Run
  162. .. image:: img/xcode_8_setup_run_scheme.png
  163. - Set the *Executable* to the file you linked in your post build action script
  164. - Check *Debug executable* if it isn't already
  165. - You can go to *Arguments* tab and add an -e and a -path to a project to debug the editor
  166. not the project selection screen
  167. Test it:
  168. - Set a breakpoint in platform/osx/godot_main_osx.mm
  169. - It should break at the point!
  170. .. _doc_configuring_an_ide_vscode:
  171. Visual Studio Code
  172. ------------------
  173. - Ensure that C/C++ extension is installed. You can find instructions in `docs <https://code.visualstudio.com/docs/languages/cpp>`_.
  174. - Now open cloned godot folder in VS Code (File > Open Folder...)
  175. In order to build the project, we need configurations files: *launch.json* and *tasks.json*.
  176. To create them:
  177. - Open Debug view (Ctrl + Shift + D) and select cogwheel with orange dot:
  178. .. image:: img/vscode_1_create_launch.json.png
  179. - Select *C++ (GDB/LLDB)* (it might be slightly differently called on macOS or Windows)
  180. - Update *launch.json* to match:
  181. .. image:: img/vscode_2_launch.json.png
  182. (Note that *godot.x11.tools.64* in "program" value might be differently called on macOS or Windows)
  183. - Create *tasks.json* by starting Debug process (F5). VS Code will show dialog with *Configure Task* button. Tap it and select *Create tasks.json file from template*, then select *Others*
  184. - Update *tasks.json* to match:
  185. .. image:: img/vscode_3_tasks.json.png
  186. (Note that *platform=x11* will be different for macOX and Windows)
  187. - You can now start Debug process again to test that everything works.
  188. - If the build phase fails, check the console for hints. On Linux it's most likely that some dependencies are missing. Check :ref:`Compiling for X11 (Linux, \*BSD) <doc_compiling_for_x11>`