compiling_for_osx.rst 3.0 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798
  1. .. _doc_compiling_for_osx:
  2. Compiling for macOS
  3. ===================
  4. .. highlight:: shell
  5. Requirements
  6. ------------
  7. For compiling under Linux or other Unix variants, the following is
  8. required:
  9. - Python 2.7+ or Python 3.5+
  10. - SCons build system
  11. - Xcode (or the more lightweight Command Line Tools for Xcode)
  12. - *Optional* - yasm (for WebM SIMD optimizations)
  13. .. seealso:: For a general overview of SCons usage for Godot, see
  14. :ref:`doc_introduction_to_the_buildsystem`.
  15. Compiling
  16. ---------
  17. Start a terminal, go to the root dir of the engine source code and type:
  18. ::
  19. user@host:~/godot$ scons platform=osx
  20. If all goes well, the resulting binary executable will be placed in the
  21. "bin" subdirectory. This executable file contains the whole engine and
  22. runs without any dependencies. Executing it will bring up the project
  23. manager.
  24. To create an .app like in the official builds, you need to use the template
  25. located in ``misc/dist/osx_tools.app``. Typically, for a ".64" optimised binary
  26. built with `scons p=osx target=release_debug`:
  27. ::
  28. user@host:~/godot$ cp -r misc/dist/osx_tools.app ./Godot.app
  29. user@host:~/godot$ mkdir -p Godot.app/Contents/MacOS
  30. user@host:~/godot$ cp bin/godot.osx.tools.64 Godot.app/Contents/MacOS/Godot
  31. user@host:~/godot$ chmod +x Godot.app/Contents/MacOS/Godot
  32. Compiling for 32 and 64-bit
  33. ---------------------------
  34. All macOS versions after 10.6 are 64-bit exclusive, so the executable
  35. will be a ".64" file by default for most users. If you would like to
  36. compile a ".fat" executable which contains both 32 and 64-bit code,
  37. you can do so by specifying the bits in the scons command like so:
  38. ::
  39. user@host:~/godot$ scons platform=osx bits=fat
  40. Cross-compiling
  41. ---------------
  42. It is possible to compile for macOS in a Linux environment (and maybe
  43. also in Windows with Cygwin). For that you will need
  44. `OSXCross <https://github.com/tpoechtrager/osxcross>`__ to be able
  45. to use macOS as target. First, follow the instructions to install it:
  46. Clone the `OSXCross repository <https://github.com/tpoechtrager/osxcross>`
  47. somewhere on your machine (or download a zip file and extract it somewhere),
  48. e.g.:
  49. ::
  50. user@host:~$ git clone https://github.com/tpoechtrager/osxcross.git /home/myuser/sources/osxcross
  51. 1. Follow the instructions to package the SDK:
  52. https://github.com/tpoechtrager/osxcross#packaging-the-sdk
  53. 2. Follow the instructions to install OSXCross:
  54. https://github.com/tpoechtrager/osxcross#installation
  55. After that, you will need to define the ``OSXCROSS_ROOT`` as the path to
  56. the OSXCross installation (the same place where you cloned the
  57. repository/extracted the zip), e.g.:
  58. ::
  59. user@host:~$ export OSXCROSS_ROOT=/home/myuser/sources/osxcross
  60. Now you can compile with SCons like you normally would:
  61. ::
  62. user@host:~/godot$ scons platform=osx
  63. If you have an OSXCross SDK version different from the one expected by the SCons buildsystem, you can specify a custom one with the ``osxcross_sdk`` argument:
  64. ::
  65. user@host:~/godot$ scons platform=osx osxcross_sdk=darwin15