build.rst 7.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217
  1. Build from source
  2. ==================
  3. .. image:: https://github.com/kovidgoyal/kitty/workflows/CI/badge.svg
  4. :alt: Build status
  5. :target: https://github.com/kovidgoyal/kitty/actions?query=workflow%3ACI
  6. .. note::
  7. If you just want to test the latest changes to kitty, you don't need to build
  8. from source. Instead install the :ref:`latest nightly build <nightly>`.
  9. .. highlight:: sh
  10. |kitty| is designed to run from source, for easy hack-ability. All you need to
  11. get started is a C compiler and the `go compiler
  12. <https://go.dev/doc/install>`__ (on Linux, the :ref:`X11 development libraries <x11-dev-libs>` as well).
  13. After installing those, run the following commands::
  14. git clone https://github.com/kovidgoyal/kitty.git && cd kitty
  15. ./dev.sh build
  16. That's it, kitty will be built from source, magically. You can run it as
  17. :file:`kitty/launcher/kitty`.
  18. This works, because the :code:`./dev.sh build` command downloads all the major
  19. dependencies of kitty as pre-built binaries for your platform and builds kitty
  20. to use these rather than system libraries. The few required system libraries
  21. are X11 and DBUS on Linux.
  22. If you make changes to kitty code, simply re-run :code:`./dev.sh build`
  23. to build kitty with your changes.
  24. .. note::
  25. If you plan to run kitty from source long-term, there are a couple of
  26. caveats to be aware of. You should occasionally run ``./dev.sh deps``
  27. to have the dependencies re-downloaded as they are updated periodically.
  28. Also, the built kitty executable assumes it will find source in whatever
  29. directory you first ran :code:`./dev.sh build` in. If you move/rename the
  30. directory, run :code:`make clean && ./dev.sh build`. You should also create
  31. symlinks to the :file:`kitty` and :file:`kitten` binaries from somewhere
  32. in your PATH so that they can be conveniently launched.
  33. .. note::
  34. On macOS, you can use :file:`kitty/launcher/kitty.app` to run kitty as well,
  35. but note that this is an unsigned kitty.app so some functionality such as
  36. notifications will not work as Apple disallows this. If you need this
  37. functionality, you can try signing the built :file:`kitty.app` with a self
  38. signed certificate, see for example, `here
  39. <https://stackoverflow.com/questions/27474751/how-can-i-codesign-an-app-without-being-in-the-mac-developer-program/27474942>`__.
  40. Building in debug mode
  41. ^^^^^^^^^^^^^^^^^^^^^^^^^^
  42. The following will build with debug symbols::
  43. ./dev.sh build --debug
  44. To build with sanitizers and debug symbols::
  45. ./dev.sh build --debug --sanitize
  46. For more help on the various options supported by the build script::
  47. ./dev.sh build -h
  48. Building the documentation
  49. -------------------------------------
  50. To have the kitty documentation available locally, run::
  51. ./dev.sh deps -for-docs && ./dev.sh docs
  52. To develop the docs, with live reloading, use::
  53. ./dev.sh deps -for-docs && ./dev.sh docs -live-reload
  54. Dependencies
  55. ----------------
  56. These dependencies are needed when building against system libraries only.
  57. Run-time dependencies:
  58. * ``python`` >= 3.8
  59. * ``harfbuzz`` >= 2.2.0
  60. * ``zlib``
  61. * ``libpng``
  62. * ``liblcms2``
  63. * ``libxxhash``
  64. * ``openssl``
  65. * ``pixman`` (not needed on macOS)
  66. * ``cairo`` (not needed on macOS)
  67. * ``freetype`` (not needed on macOS)
  68. * ``fontconfig`` (not needed on macOS)
  69. * ``libcanberra`` (not needed on macOS)
  70. * ``libsystemd`` (optional, not needed on non systemd systems)
  71. * ``ImageMagick`` (optional, needed to display uncommon image formats in the terminal)
  72. Build-time dependencies:
  73. * ``gcc`` or ``clang``
  74. * ``simde``
  75. * ``go`` >= _build_go_version (see :file:`go.mod` for go packages used during building)
  76. * ``pkg-config``
  77. * Symbols NERD Font Mono either installed system-wide or placed in :file:`fonts/SymbolsNerdFontMono-Regular.ttf`
  78. * For building on Linux in addition to the above dependencies you might also
  79. need to install the following packages, if they are not already installed by
  80. your distro:
  81. - ``liblcms2-dev``
  82. - ``libfontconfig-dev``
  83. - ``libssl-dev``
  84. - ``libpython3-dev``
  85. - ``libxxhash-dev``
  86. - ``libsimde-dev``
  87. - ``libcairo2-dev``
  88. .. _x11-dev-libs:
  89. Also, the X11 development libraries:
  90. - ``libdbus-1-dev``
  91. - ``libxcursor-dev``
  92. - ``libxrandr-dev``
  93. - ``libxi-dev``
  94. - ``libxinerama-dev``
  95. - ``libgl1-mesa-dev``
  96. - ``libxkbcommon-x11-dev``
  97. - ``libfontconfig-dev``
  98. - ``libx11-xcb-dev``
  99. Build and run from source with Nix
  100. -------------------------------------------
  101. On NixOS or any other Linux or macOS system with the Nix package manager
  102. installed, execute `nix-shell
  103. <https://nixos.org/guides/nix-pills/developing-with-nix-shell.html>`__ to create
  104. the correct environment to build kitty or use ``nix-shell --pure`` instead to
  105. eliminate most of the influence of the outside system, e.g. globally installed
  106. packages. ``nix-shell`` will automatically fetch all required dependencies and
  107. make them available in the newly spawned shell.
  108. Then proceed with ``make`` or ``make app`` according to the platform specific
  109. instructions above.
  110. .. _packagers:
  111. Notes for Linux/macOS packagers
  112. ----------------------------------
  113. The released |kitty| source code is available as a `tarball`_ from
  114. `the GitHub releases page <https://github.com/kovidgoyal/kitty/releases>`__.
  115. While |kitty| does use Python, it is not a traditional Python package, so please
  116. do not install it in site-packages.
  117. Instead run::
  118. make linux-package
  119. This will install |kitty| into the directory :file:`linux-package`. You can run
  120. |kitty| with :file:`linux-package/bin/kitty`. All the files needed to run kitty
  121. will be in :file:`linux-package/lib/kitty`. The terminfo file will be installed
  122. into :file:`linux-package/share/terminfo`. Simply copy these files into
  123. :file:`/usr` to install |kitty|. In other words, :file:`linux-package` is the
  124. staging area into which |kitty| is installed. You can choose a different staging
  125. area, by passing the ``--prefix`` argument to :file:`setup.py`.
  126. You should probably split |kitty| into three packages:
  127. :code:`kitty-terminfo`
  128. Installs the terminfo file
  129. :code:`kitty-shell-integration`
  130. Installs the shell integration scripts (the contents of the
  131. shell-integration directory in the kitty source code), probably to
  132. :file:`/usr/share/kitty/shell-integration`
  133. :code:`kitty`
  134. Installs the main program
  135. This allows users to install the terminfo and shell integration files on
  136. servers into which they ssh, without needing to install all of |kitty|. The
  137. shell integration files **must** still be present in
  138. :file:`lib/kitty/shell-integration` when installing the kitty main package as
  139. the kitty program expects to find them there.
  140. .. note::
  141. You need a couple of extra dependencies to build linux-package. :file:`tic`
  142. to compile terminfo files, usually found in the development package of
  143. :file:`ncurses`. Also, if you are building from a git checkout instead of the
  144. released source code tarball, you will need to install the dependencies from
  145. :file:`docs/requirements.txt` to build the kitty documentation. They can be
  146. installed most easily with ``python -m pip -r docs/requirements.txt``.
  147. This applies to creating packages for |kitty| for macOS package managers such as
  148. Homebrew or MacPorts as well.
  149. Cross compilation
  150. -------------------
  151. While cross compilation is neither officially supported, nor recommended, as it
  152. means the test suite cannot be run for the cross compiled build, there is some
  153. support for cross compilation. Basically, run::
  154. make prepare-for-cross-compile
  155. Then setup the cross compile environment (CC, CFLAGS, PATH, etc.) and run::
  156. make cross-compile
  157. This will create the cross compiled build in the :file:`linux-package`
  158. directory.