compiling_for_uwp.rst 6.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154
  1. .. _doc_compiling_for_uwp:
  2. Compiling for Universal Windows Platform
  3. ========================================
  4. .. highlight:: shell
  5. .. seealso::
  6. This page describes how to compile UWP export template binaries from source.
  7. If you're looking to export your project to UWP instead, read :ref:`doc_exporting_for_uwp`.
  8. Requirements
  9. ------------
  10. - `Python 3.6+ <https://www.python.org/downloads/windows/>`_.
  11. **Make sure to enable the option to add Python to the ``PATH`` in the installer.**
  12. - `SCons 3.0+ <https://scons.org/pages/download.html>`_ build system. Using the
  13. latest release is recommended, especially for proper support of recent Visual
  14. Studio releases.
  15. - Windows 10 SDK (can be selected in Visual Studio installation).
  16. - `ANGLE source <https://github.com/Microsoft/angle>`__. Use the
  17. ``ms_master`` (default) branch. Keep it in a path without spaces to
  18. avoid problems.
  19. .. note:: The ANGLE repo by Microsoft has been discontinued and the
  20. ``ms_master`` branch has been cleared out.
  21. As a temporary workaround however, it is still possible to
  22. download an older state of the source code via commit
  23. `c61d048 <https://github.com/microsoft/angle/tree/c61d0488abd9663e0d4d2450db7345baa2c0dfb6>`__.
  24. This page will eventually be updated in the future to reflect
  25. the new build instructions.
  26. .. seealso:: To get the Godot source code for compiling, see
  27. :ref:`doc_getting_source`.
  28. For a general overview of SCons usage for Godot, see
  29. :ref:`doc_introduction_to_the_buildsystem`.
  30. Compiling
  31. ---------
  32. You need to open a proper Visual Studio prompt for the target architecture
  33. you want to build. Check :ref:`doc_compiling_for_windows` to see how these
  34. prompts work.
  35. There are three target architectures for UWP: x86 (32-bits), x64 (64-bits)
  36. and ARM (32-bits). For the latter, you can run ``vcvarsall.bat`` with
  37. ``x86_arm`` or ``amd64_arm`` as argument to set the environment.
  38. Set the ``ANGLE_SRC_PATH`` to the directory where you downloaded the ANGLE
  39. source code. The build process will also build ANGLE to produce the
  40. required DLLs for the selected architecture.
  41. Once you're set, run the SCons command similarly to the other platforms::
  42. C:\godot>scons platform=uwp
  43. Creating UWP export templates
  44. -----------------------------
  45. To export using the editor you need to properly build package the templates.
  46. You need all three architectures with ``debug`` and ``release`` templates to
  47. be able to export.
  48. Open the command prompt for one architecture and run SCons twice (once for
  49. each target)::
  50. C:\godot>scons platform=uwp target=template_debug
  51. C:\godot>scons platform=uwp target=template_release
  52. Repeat for the other architectures.
  53. In the end your ``bin`` folder will have the ``.exe`` binaries with a name
  54. like ``godot.uwp.opt.debug.32.x86.exe`` (with variations for each
  55. target/arch).
  56. Copy one of these to ``misc/dist/uwp_template`` inside the Godot source
  57. folder and rename the binary to ``godot.uwp.exe``. From the ANGLE source,
  58. under ``winrt/10/src/Release_%arch%`` (where ``%arch%`` can be ``Win32``,
  59. ``x64`` or ``ARM``), get the ``libEGL.dll`` and the ``libGLESv2.dll``,
  60. putting them along with the executable.
  61. Add the files in the ``uwp_template`` folder to a ZIP. Rename the resulting
  62. Zip according to the target/architecture of the template::
  63. uwp_x86_debug.zip
  64. uwp_x86_release.zip
  65. uwp_x64_debug.zip
  66. uwp_x64_release.zip
  67. uwp_arm_debug.zip
  68. uwp_arm_release.zip
  69. Move those templates to the ``[versionstring]\templates`` folder in Godot
  70. settings path, where `versionstring` is the version of Godot you have compiled
  71. the export templates for - e.g. `3.0.alpha` for the alpha version of Godot 3.
  72. If you don't want to replace the templates, you can set the "Custom Package"
  73. property in the export window.
  74. Running UWP apps with Visual Studio
  75. -----------------------------------
  76. If you want to debug the UWP port or simply run your apps without packaging
  77. and signing, you can deploy and launch them using Visual Studio. It might be
  78. the easiest way if you are testing on a device such as a Windows Phone or an
  79. Xbox One.
  80. Within the ANGLE source folder, open ``templates`` and double-click the
  81. ``install.bat`` script file. This will install the Visual Studio project
  82. templates for ANGLE apps.
  83. If you have not built Godot yet, open the ``winrt/10/src/angle.sln`` solution
  84. from the ANGLE source and build it to Release/Win32 target. You may also need
  85. to build it for ARM if you plan to run on a device. You can also use MSBuild if
  86. you're comfortable with the command line.
  87. Create a new Windows App project using the "App for OpenGL ES
  88. (Windows Universal)" project template, which can be found under the
  89. ``Visual C++/Windows/Universal`` category.
  90. This is a base project with the ANGLE dependencies already set up. However, by
  91. default it picks the debug version of the DLLs which usually have poor
  92. performance. So in the "Binaries" filter, click in each of the DLLs there
  93. and in the "Properties" window and change the relative path from
  94. ``Debug_Win32`` to ``Release_Win32`` (or ``Release_ARM`` for devices).
  95. In the same "Binaries" filter, select "Add > Existing Item" and point to the
  96. Godot executable for UWP you have. In the "Properties" window, set "Content"
  97. to ``True`` so it's included in the project.
  98. Right-click the ``Package.appxmanifest`` file and select "Open With... > XML
  99. (Text) Editor". In the ``Package/Applications/Application`` element, replace
  100. the ``Executable`` attribute from ``$targetnametoken$.exe`` to
  101. ``godot.uwp.exe`` (or whatever your Godot executable is called). Also change
  102. the ``EntryPoint`` attribute to ``GodotUWP.App``. This will ensure that
  103. the Godot executable is correctly called when the app starts.
  104. Create a folder (*not* a filter) called ``game`` in your Visual Studio project
  105. folder and there you can put either a ``data.pck`` file or your Godot project
  106. files. After that, make sure to include it all with the "Add > Existing Item"
  107. command and set their "Content" property to ``True`` so they're copied to the
  108. app.
  109. To ease the workflow, you can open the "Solution Properties" and in the
  110. "Configuration" section untick the "Build" option for the app. You still have
  111. to build it at least once to generate some needed files, you can do so by
  112. right-clicking the project (*not* the solution) in the "Solution Explorer" and
  113. selecting "Build".
  114. Now you can just run the project and your app should open. You can also use
  115. the "Start Without Debugging" option from the "Debug" menu (or press :kbd:`Ctrl + F5`) to make it
  116. launch faster.