configuring_an_ide.rst 8.7 KB

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