compiling_with_mono.rst 3.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687
  1. .. _doc_compiling_with_mono:
  2. Compiling with Mono
  3. ===================
  4. .. highlight:: shell
  5. Requirements
  6. ------------
  7. - Mono (the required version is listed here: :ref:`doc_c_sharp`)
  8. - MSBuild
  9. - pkg-config
  10. Environment Variables
  11. ---------------------
  12. By default, SCons will try to find Mono in the Windows Registry on Windows or via ``pkg-config`` on other platforms. You can specify a different installation directory by using the following environment variables for the respective ``bits`` option: ``MONO32_PREFIX`` and ``MONO64_PREFIX``.
  13. The specified directory must contain the subdirectories ``bin``, ``include``, and ``lib``.
  14. Enable Mono Module
  15. --------------------
  16. By default, the mono module is disabled for builds. To enable it you can pass the option ``module_mono_enabled=yes`` to your SCons command.
  17. Generate The Glue
  18. -------------------
  19. The glue sources are the wrapper functions that will be called by the managed side. In order to generate them, first, you must build Godot with the options ``tools=yes`` and ``mono_glue=no``:
  20. ::
  21. scons p=<platform> tools=yes module_mono_enabled=yes mono_glue=no
  22. After the build finishes, you need to run the compiled executable with the parameter ``--generate-mono-glue`` followed by the path to an output directory. This path must be ``modules/mono/glue`` in the Godot directory.
  23. ::
  24. godot --generate-mono-glue modules/mono/glue
  25. This command will tell Godot to generate the file *modules/mono/glue/mono_glue.gen.cpp*. Once this file is generated, you can build Godot for all the desired targets without the need to repeat this process.
  26. As always, ``godot`` refers to the compiled Godot binary, so if it isn't in your PATH, you need to give the full path to the executable, e.g. if it is located in the ``bin`` subfolder, it becomes ``bin/godot``.
  27. Notes
  28. ^^^^^
  29. - **Do not** build normal binaries with ``mono_glue=no``. This option disables C# scripting and therefore must only be used for the temporary binary that will be used to generate the glue. Godot should print a message at startup warning you about this.
  30. - The glue sources must be regenerated every time the ClassDB API changes. If there is an API mismatch with the generated glue, Godot will print an error at startup.
  31. Examples
  32. --------
  33. Example (Windows)
  34. ^^^^^^^^^^^^^^^^^
  35. ::
  36. # Build temporary binary
  37. scons p=windows tools=yes module_mono_enabled=yes mono_glue=no
  38. # Generate glue sources
  39. bin\godot.windows.tools.64.mono --generate-mono-glue modules/mono/glue
  40. ### Build binaries normally
  41. # Editor
  42. scons p=windows target=release_debug tools=yes module_mono_enabled=yes
  43. # Export templates
  44. scons p=windows target=debug tools=no module_mono_enabled=yes
  45. scons p=windows target=release tools=no module_mono_enabled=yes
  46. Example (x11)
  47. ^^^^^^^^^^^^^
  48. ::
  49. # Build temporary binary
  50. scons p=x11 tools=yes module_mono_enabled=yes mono_glue=no
  51. # Generate glue sources
  52. bin/godot.x11.tools.64.mono --generate-mono-glue modules/mono/glue
  53. ### Build binaries normally
  54. # Editor
  55. scons p=x11 target=release_debug tools=yes module_mono_enabled=yes
  56. # Export templates
  57. scons p=x11 target=debug tools=no module_mono_enabled=yes
  58. scons p=x11 target=release tools=no module_mono_enabled=yes
  59. If everything went well, apart from the normal output, SCons should have also built the *GodotSharpTools.dll* assembly and copied it together with the mono runtime shared library to the ``bin`` subdirectory.