Vous ne pouvez pas sélectionner plus de 25 sujets Les noms de sujets doivent commencer par une lettre ou un nombre, peuvent contenir des tirets ('-') et peuvent comporter jusqu'à 35 caractères.

building.rst 4.9KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133
  1. Building ``dds`` from Source
  2. ############################
  3. .. note::
  4. This page assumes that you have ready the :doc:`env` page, and that you are
  5. running all commands from within the Poetry-generated virtual environment.
  6. The main entrypoint for the ``dds`` CI process is the ``dds-ci`` command, which
  7. will build and test the ``dds`` from the repository sources. ``dds-ci`` accepts
  8. several optional command-line arguments to tweak its behavior.
  9. Running a Build *Only*
  10. **********************
  11. If you only wish to obtain a built ``dds`` executable, the ``--no-test``
  12. parameter can be given::
  13. $ dds-ci --no-test
  14. This will skip the audit-build and testing phases of CI and build only the final
  15. ``dds`` executable.
  16. Rapid Iterations for Development
  17. ********************************
  18. If you are making frequent changes to ``dds``'s source code and want a fast
  19. development process, use ``--rapid``::
  20. $ dds-ci --rapid
  21. This will build the build step only, and builds an executable with maximum debug
  22. and audit information, including AddressSanitizer and
  23. UndefinedBehaviorSanitizer. This will also execute the unit tests, which should
  24. run completely in under two seconds (if they are slower, then it may be a bug).
  25. Toolchain Control
  26. *****************
  27. ``dds-ci`` will automatically select and build with an appropriate
  28. :doc:`toolchain </guide/toolchains>` based on what it detects of the host
  29. platform, but you may want to tweak those options.
  30. The ``dds-ci`` script accepts two toolchain options:
  31. ``--main-toolchain``
  32. This is the toolchain that is used to create a final release-built executable.
  33. If you build with ``--no-test``, this toolchain will be used.
  34. ``--test-toolchain`` This is the toolchain that is used to create an auditing
  35. and debuggable executable of ``dds``. This is the toolchain that is used if you
  36. build with ``--rapid``.
  37. If you build with neither ``--rapid`` nor ``--no-test``, then ``dds-ci`` will
  38. build *two* ``dds`` executables: One with the ``--test-toolchain`` that is
  39. passed through the test suite, and another for ``--main-toolchain`` that is
  40. built for distribution.
  41. The default toolchains are files contained within the ``tools/`` directory of
  42. the repository. When ``dds-ci`` builds ``dds``, it will print the path to the
  43. toolchain file that is selected for that build.
  44. While these provided toolchains will work perfectly well in CI, you may need to
  45. tweak these for your build setup. For example: ``gcc-9-*.jsonc`` toolchains
  46. assume that the GCC 9 executables are named ``gcc-9`` and ``g++-9``, which is
  47. incorrect on some Unix and Linux distributions.
  48. It is recommended to tweak these files as necessary to get the build working on
  49. your system. However, **do not** include those tweaks in a commit unless they
  50. are necessary to get the build running in CI.
  51. What's Happening?
  52. *****************
  53. The ``dds-ci`` script performs the following actions, in order:
  54. #. If given ``--clean``, remove any prior build output and downloaded
  55. dependencies.
  56. #. Prepare the prior version of ``dds`` that will build the current version
  57. (usually, just download it). This is placed in ``_prebuilt/``.
  58. #. Import the ``old-catalog.json`` into a catalog database stored within
  59. ``_prebuilt/``. This will be used to resolve the third-party packages that
  60. ``dds`` itself uses.
  61. #. Invoke the build of ``dds`` using the prebuilt ``dds`` obtained from the
  62. prior bootstrap phase. If ``--no-test`` or ``--rapid`` was specified, the CI
  63. script stops here.
  64. #. Launch ``pytest`` with the generated ``dds`` executable and start the final
  65. release build simultaneously, and wait for both to finish.
  66. Unit Tests
  67. **********
  68. Various pieces of ``dds`` contain unit tests. These are stored within the
  69. ``src/`` directory itself in ``*.test.cpp`` files. They are built and executed
  70. as part of the iteration cycle *unconditionally*. These tests execute in
  71. milliseconds so as not to burden the development iteration cycle. The more
  72. rigorous tests are executed separately by PyTest.
  73. Speeding Up the Build
  74. *********************
  75. ``dds``'s build is unfortunately demanding, but can be sped up by additional
  76. tools:
  77. Use the LLVM ``lld`` Linker
  78. ===========================
  79. Installing the LLVM ``lld`` linker will *significantly* improve the time it
  80. takes for ``dds`` and its unit test executables to link. ``dds-ci`` will
  81. automatically recognize the presence of ``lld`` if it has been installed
  82. properly.
  83. .. note::
  84. ``dds-ci`` (and GCC) look for an executable called ``ld.ldd`` on the
  85. executable PATH (no version suffix!). You may need to symlink the
  86. version-suffixed executable with ``ld.ldd`` in another location on PATH so
  87. that ``dds-ci`` (and GCC) can find it.
  88. Use ``ccache``
  89. ==============
  90. ``dds-ci`` will also recognize ``ccache`` and add it as a compiler-launcher if
  91. it is installed on your PATH. This won't improve initial compilation times, but
  92. can make subsequent compilations significantly faster when files are unchanged.