compiling_for_uwp.rst 5.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131
  1. .. _doc_compiling_for_uwp:
  2. Compiling for Universal Windows Platform
  3. ========================================
  4. .. highlight:: shell
  5. Requirements
  6. ------------
  7. - SCons (see :ref:`doc_compiling_for_windows` for more details).
  8. - Visual Studio 2015 Update 2. It may work with earlier versions. See
  9. :ref:`doc_compiling_for_windows` about the caveats of installing it
  10. and the various prompts.
  11. - Windows 10 SDK (can be selected in Visual Studio installation).
  12. - `ANGLE source <https://github.com/Microsoft/angle>`__. Use the
  13. ``ms_master`` (default) branch. Keep it in a path without spaces to
  14. avoid problems.
  15. Compiling
  16. ---------
  17. You need to open a proper Visual Studio prompt for the target architecture
  18. you want to build. Check :ref:`doc_compiling_for_windows` to see how these
  19. prompts work.
  20. There are three target architectures for UWP: x86 (32-bits), x64 (64-bits)
  21. and ARM (32-bits). You can run ``vcvarsall.bat`` with ``arm`` as argument to
  22. set the environment for this target architecture.
  23. Set the ``ANGLE_SRC_PATH`` to the directory where you downloaded the ANGLE
  24. source code. The build process will also build ANGLE to produce the
  25. required DLLs for the selected architecture.
  26. Once you're set, run the SCons command similarly to the other platforms::
  27. C:\godot>scons platform=winrt
  28. Creating UWP export templates
  29. -----------------------------
  30. To export using the editor you need to properly build package the templates.
  31. You need all three architectures with ``debug`` and ``release`` templates to
  32. be able to export.
  33. Open the command prompt for one architecture and run SCons twice (once for
  34. each target)::
  35. C:\godot>scons platform=winrt target=release_debug
  36. C:\godot>scons platform=winrt target=release
  37. Repeat for the other architectures.
  38. In the end your ``bin`` folder will have the ``.exe`` binaries with a name
  39. like ``godot.winrt.opt.debug.32.x86.exe`` (with variations for each
  40. target/arch).
  41. Copy one of these to ``misc/dist/uwp_template`` inside the Godot source
  42. folder and rename the binary to ``godot.winrt.exe``. From the ANGLE source,
  43. under ``winrt/10/src/Release_%arch%`` (where ``%arch%`` can be ``Win32``,
  44. ``x64`` or ``ARM``), get the ``libEGL.dll`` and the ``libGLESv2.dll``,
  45. putting them along with the executable.
  46. Add the files in the ``uwp_template`` folder to a ZIP. Rename the resulting
  47. Zip according to the target/architecture of the template::
  48. winrt_x86_debug.zip
  49. winrt_x86_release.zip
  50. winrt_x64_debug.zip
  51. winrt_x64_release.zip
  52. winrt_arm_debug.zip
  53. winrt_arm_release.zip
  54. Move those templates to the ``templates`` folder in Godot settings path. If
  55. you don't want to replacet the templates, you can set the "Custom Package"
  56. property in the export window.
  57. Running UWP apps with Visual Studio
  58. -----------------------------------
  59. If you want to debug the UWP port or simply run your apps without packaging
  60. and signing, you can deploy and launch them using Visual Studio. It might be
  61. the easiest way if you are testing on a device such as a Windows Phone or an
  62. Xbox One.
  63. Within the ANGLE source folder, open ``templates`` and double-click the
  64. ``install.bat`` script file. This will install the Visual Studio project
  65. templates for ANGLE apps.
  66. If you have not built Godot yet, open the ``winrt/10/src/angle.sln`` solution
  67. from the ANGLE source and build it to Release/Win32 target. You may also need
  68. to build it for ARM if you plan to run on a device. You can also use MSBuild if
  69. you're comfortable with the command line.
  70. Create a new Windows App project using the "App for OpenGL ES
  71. (Windows Unversal)" project template, which can be found under the
  72. ``Visual C++/Windows/Universal`` category.
  73. This is a base project with the ANGLE dependencies already set up. However, by
  74. default it picks the debug version of the DLLs which usually have a very poor
  75. performance. So in the "Binaries" filter, click in each of the DLLs there
  76. and in the "Properties" window and change the relative path from
  77. ``Debug_Win32`` to ``Release_Win32`` (or ``Release_ARM`` for devices).
  78. In the same "Binaries" filter, select "Add > Existing Item" and point to the
  79. Godot executable for UWP you have. In the "Properties" window, set "Content"
  80. to ``True`` so it's included in the project.
  81. Right-click the ``Package.appxmanifest`` file and select "Open With... > XML
  82. (Text) Editor". In the ``Package/Applications/Application`` element, replace
  83. the ``Executable`` attribute from ``$targetnametoken$.exe`` to
  84. ``godot.winrt.exe`` (or whatever your Godot executable is called). Also change
  85. the ``EntryPoint`` attribute to ``GodotWinRT.App``. This will ensure that
  86. the Godot executable is correctly called when the app starts.
  87. Create a folder (*not* a filter) called ``game`` in your Visual Studio project
  88. folder and there you can put either a ``data.pck`` file or your Godot project
  89. files. After that, make sure to include it all with the "Add > Existing Item"
  90. command and set their "Content" property to ``True`` so they're copied to the
  91. app.
  92. To ease the workflow, you can open the "Solution Properties" and in the
  93. "Configuration" section untick the "Build" option for the app. You still have
  94. to build it at least once to generate some needed files, you can do so by
  95. right-clicking the project (*not* the solution) in the "Solution Explorer" and
  96. selecting "Build".
  97. Now you can just run the project and your app should open. You can use also
  98. the "Start Without Debugging" from the "Debug" menu (Ctrl+F5) to make it
  99. launch faster.