configuring_an_ide.rst 12 KB

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