building.rst 10 KB

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