building.rst 9.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252
  1. .. _building-label:
  2. ===============================
  3. Appendix A: Building the Client
  4. ===============================
  5. This section explains how to build the Nextcloud Client from source for all
  6. major platforms. You should read this section if you want to develop for the
  7. desktop client.
  8. .. note:: Build instructions are subject to change as development proceeds.
  9. Please check the version for which you want to build.
  10. These instructions are updated to work with version |version| of the Nextcloud Client.
  11. Getting Source Code
  12. -------------------
  13. The :ref:`generic-build-instructions` pull the latest code directly from
  14. GitHub, and work on Linux, macOS, and Windows.
  15. macOS
  16. -----
  17. In addition to needing XCode (along with the command line tools), developing in
  18. the macOS environment requires extra dependencies. You can install these
  19. dependencies through MacPorts_ or Homebrew_. These dependencies are required
  20. only on the build machine, because non-standard libs are deployed in the app
  21. bundle.
  22. The tested and preferred way to develop in this environment is through the use
  23. of HomeBrew_. The team has its own repository containing non-standard
  24. recipes.
  25. To set up your build environment for development using HomeBrew_:
  26. 1. Install Xcode
  27. 2. Install Xcode command line tools::
  28. xcode-select --install
  29. 3. Install homebrew::
  30. /usr/bin/ruby -e "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/master/install)"
  31. 4. Add the Nextcloud repository using the following command::
  32. brew tap owncloud/owncloud
  33. 5. Install a Qt5 version with qtwebkit support::
  34. brew install qt5 --with-qtwebkit
  35. 6. Install any missing dependencies::
  36. brew install $(brew deps owncloud-client)
  37. 7. Add Qt from brew to the path::
  38. export PATH=/usr/local/Cellar/qt5/5.x.y/bin:$PATH
  39. Where ``x.y`` is the current version of Qt 5 that brew has installed
  40. on your machine.
  41. 8. Install qtkeychain from here: git clone https://github.com/frankosterfeld/qtkeychain.git
  42. make sure you make the same install prefix as later while building the client e.g. -
  43. ``DCMAKE_INSTALL_PREFIX=/Path/to/client-install``
  44. 9. For compilation of the client, follow the :ref:`generic-build-instructions`.
  45. 10. Install the Packages_ package creation tool.
  46. 11. In the build directory, run ``admin/osx/create_mac.sh <build_dir> <install_dir>``.
  47. If you have a developer signing certificate, you can specify
  48. its Common Name as a third parameter (use quotes) to have the package
  49. signed automatically.
  50. .. note:: Contrary to earlier versions, Nextcloud 1.7 and later are packaged
  51. as a ``pkg`` installer. Do not call "make package" at any time when
  52. compiling for OS X, as this will build a disk image, and will not
  53. work correctly.
  54. Windows Development Build
  55. -------------------------
  56. If you want to test some changes and deploy them locally, you can build natively
  57. on Windows using MinGW. If you want to generate an installer for deployment, please
  58. follow `Windows Installer Build (Cross-Compile)`_ instead.
  59. 1. Get the required dependencies:
  60. * Make sure that you have CMake_ and Git_.
  61. * Download the Qt_ MinGW package. You will use the MinGW version bundled with it.
  62. * Download an `OpenSSL Windows Build`_ (the non-"Light" version)
  63. 2. Get the QtKeychain_ sources as well as the latest versions of the Nextcloud client
  64. from Git as follows::
  65. git clone https://github.com/frankosterfeld/qtkeychain.git
  66. git clone git://github.com/nextcloud/client.git
  67. 3. Open the Qt MinGW shortcut console from the Start Menu
  68. 4. Make sure that OpenSSL's ``bin`` directory as well as your qtkeychain source
  69. directories are in your PATH. This will allow CMake to find the library and
  70. headers, as well as allow the Nextcloud client to find the DLLs at runtime::
  71. set PATH=C:\<OpenSSL Install Dir>\bin;%PATH%
  72. set PATH=C:\<qtkeychain Clone Dir>;%PATH%
  73. 5. Build qtkeychain **directly in the source directory** so that the DLL is built
  74. in the same directory as the headers to let CMake find them together through PATH::
  75. cd <qtkeychain Clone Dir>
  76. cmake -G "MinGW Makefiles" .
  77. mingw32-make
  78. cd ..
  79. 6. Create the build directory::
  80. mkdir client-build
  81. cd client-build
  82. 7. Build the client::
  83. cmake -G "MinGW Makefiles" ../client
  84. mingw32-make
  85. .. note:: You can try using ninja to build in parallel using
  86. ``cmake -G Ninja ../client`` and ``ninja`` instead.
  87. .. note:: Refer to the :ref:`generic-build-instructions` section for additional options.
  88. The Nextcloud binary will appear in the ``bin`` directory.
  89. Windows Installer Build (Cross-Compile)
  90. ---------------------------------------
  91. Due to the large number of dependencies, building the client installer for Windows
  92. is **currently only officially supported on openSUSE**, by using the MinGW cross compiler.
  93. You can set up any currently supported version of openSUSE in a virtual machine if you do not
  94. have it installed already.
  95. In order to make setup simple, you can use the provided Dockerfile to build your own image.
  96. 1. Assuming you are in the root of the Nextcloud Client's source tree, you can
  97. build an image from this Dockerfile like this::
  98. cd admin/win/docker
  99. docker build . -t nextcloud-client-win32:<version>
  100. Replace ``<version>`` by the version of the client you are building, e.g.
  101. |version| for the release of the client that this document describes.
  102. If you do not wish to use docker, you can run the commands in ``RUN`` manually
  103. in a shell, e.g. to create your own build environment in a virtual machine.
  104. .. note:: Docker images are specific to releases. This one refers to |version|.
  105. Newer releases may have different dependencies, and thus require a later
  106. version of the docker image! Always pick the docker image fitting your release
  107. of Nextcloud client!
  108. 2. From within the source tree Run the docker instance::
  109. docker run -v "$PWD:/home/user/client" nextcloud-client-win32:<version> \
  110. /home/user/client/admin/win/docker/build.sh client/ $(id -u)
  111. It will run the build, create an NSIS based installer, as well as run tests.
  112. You will find the resulting binary in an newly created ``build-win32`` subfolder.
  113. If you do not wish to use docker, and ran the ``RUN`` commands above in a virtual machine,
  114. you can run the indented commands in the lower section of ``build.sh`` manually in your
  115. source tree.
  116. 4. Finally, you should sign the installer to avoid warnings upon installation.
  117. This requires a `Microsoft Authenticode`_ Certificate ``osslsigncode`` to sign the installer::
  118. osslsigncode -pkcs12 $HOME/.codesign/packages.pfx -h sha256 \
  119. -pass yourpass \
  120. -n "ACME Client" \
  121. -i "http://acme.com" \
  122. -ts "http://timestamp.server/" \
  123. -in ${unsigned_file} \
  124. -out ${installer_file}
  125. For ``-in``, use the URL to the time stamping server provided by your CA along with the Authenticode certificate. Alternatively,
  126. you may use the official Microsoft ``signtool`` utility on Microsoft Windows.
  127. If you're familiar with docker, you can use the version of ``osslsigncode`` that is part of the docker image.
  128. .. _generic-build-instructions:
  129. Generic Build Instructions
  130. --------------------------
  131. Compared to previous versions, building the desktop sync client has become easier. Unlike
  132. earlier versions, CSync, which is the sync engine library of the client, is now
  133. part of the client source repository and not a separate module.
  134. To build the most up-to-date version of the client:
  135. 1. Clone the latest versions of the client from Git_ as follows::
  136. git clone git://github.com/nextcloud/client.git
  137. cd client
  138. git submodule init
  139. git submodule update
  140. 2. Create the build directory::
  141. mkdir client-build
  142. cd client-build
  143. 3. Configure the client build::
  144. cmake -DCMAKE_BUILD_TYPE="Debug" ..
  145. .. note:: You must use absolute paths for the ``include`` and ``library``
  146. directories.
  147. .. note:: On macOS, you need to specify ``-DCMAKE_INSTALL_PREFIX=target``,
  148. where ``target`` is a private location, i.e. in parallel to your build
  149. dir by specifying ``../install``.
  150. .. note:: qtkeychain must be compiled with the same prefix e.g ``CMAKE_INSTALL_PREFIX=/Users/path/to/client/install/ .``
  151. .. note:: Example:: ``cmake -DCMAKE_PREFIX_PATH=/usr/local/opt/qt5 -DCMAKE_INSTALL_PREFIX=/Users/path/to/client/install/ -DNO_SHIBBOLETH=1``
  152. 4. Call ``make``.
  153. The Nextcloud binary will appear in the ``bin`` directory.
  154. 5. (Optional) Call ``make install`` to install the client to the
  155. ``/usr/local/bin`` directory.
  156. The following are known cmake parameters:
  157. * ``QTKEYCHAIN_LIBRARY=/path/to/qtkeychain.dylib -DQTKEYCHAIN_INCLUDE_DIR=/path/to/qtkeychain/``:
  158. Used for stored credentials. When compiling with Qt5, the library is called ``qt5keychain.dylib.``
  159. You need to compile QtKeychain with the same Qt version.
  160. * ``WITH_DOC=TRUE``: Creates doc and manpages through running ``make``; also adds install statements,
  161. providing the ability to install using ``make install``.
  162. * ``CMAKE_PREFIX_PATH=/path/to/Qt5.2.0/5.2.0/yourarch/lib/cmake/``: Builds using Qt5.
  163. * ``BUILD_WITH_QT4=ON``: Builds using Qt4 (even if Qt5 is found).
  164. * ``CMAKE_INSTALL_PREFIX=path``: Set an install prefix. This is mandatory on Mac OS
  165. .. _CMake: http://www.cmake.org/download
  166. .. _CSync: http://www.csync.org
  167. .. _Client Download Page: https://nextcloud.com/install/#install-clients
  168. .. _Git: http://git-scm.com
  169. .. _MacPorts: http://www.macports.org
  170. .. _Homebrew: http://mxcl.github.com/homebrew/
  171. .. _OpenSSL Windows Build: http://slproweb.com/products/Win32OpenSSL.html
  172. .. _Qt: http://www.qt.io/download
  173. .. _Microsoft Authenticode: https://msdn.microsoft.com/en-us/library/ie/ms537361%28v=vs.85%29.aspx
  174. .. _QtKeychain: https://github.com/frankosterfeld/qtkeychain
  175. .. _Packages: http://s.sudre.free.fr/Software/Packages/about.html