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.

193 lines
7.5KB

  1. ``dds`` Design and Rationale
  2. ############################
  3. ``dds`` has been designed from the very beginning as an extremely opinionated
  4. hybrid *build system* and *package manager*. Unlike most build systems however,
  5. ``dds`` has a hyper-specific focus on a particular aspect of software
  6. development: C++ libraries.
  7. This may sound pointless, right? Libraries are useless unless we can use them
  8. to build applications!
  9. Indeed, applications *are* essential, but that is "not our job."
  10. Another design decision is that ``dds`` is built to be driven by automated
  11. tools as well as humans. ``dds`` will not build your AAA console game, nor will
  12. it compile an OS kernel. Instead, the build system of your AAA console game or
  13. OS kernel can *use* ``dds``.
  14. Background
  15. **********
  16. I'm going to say something somewhat controversial: C++ doesn't need "package
  17. management." At least, not *generalize* "package management." C++ needs
  18. *library* "package management."
  19. The C and C++ compilation model is inherently *more complex* than almost any
  20. other language in use today. This isn't to say "bad," but rather than it is
  21. built to meet extremely high and strange demands. It also comes with a large
  22. burden of *legacy*. Meeting both of these requirements simultaneously presents
  23. incredible implementation challenges.
  24. Despite the vast amount of work put into build systems and tooling, virtually
  25. all developers are using them *incorrectly* and/or *dangerously* without
  26. realizing it. Despite this work, we seem to be a great distance from a unified
  27. library package distribution and consumption mechanism.
  28. Tabula Rasa
  29. ***********
  30. ``dds`` attempts to break from the pattern of legacy demands and strange usage
  31. demands in a few ways. The major differences between ``dds`` and other build
  32. systems like CMake, Meson, build2, SCons, MSBuild, etc. is that of *tradeoffs*.
  33. If you opt-in to have your library built by ``dds``, you forgoe
  34. *customizability* in favor of *simplicity* and *ease*.
  35. ``dds`` takes a look at what is needed to build and develop *libraries* and
  36. hyper-optimizes for that use case. It is also built with a very strong, very
  37. opinionated idea of *how* libraries should be constructed and used. These
  38. prescriptions are not at all arbitrary, though. They are built upon the
  39. observations of the strengths and weaknesses of build systems in use throughout
  40. industry and community.
  41. There is some ambiguity on the term "build system." It can mean one of two
  42. things:
  43. 1. A *proper noun* "Build System," such as CMake, Meson, Autotools, or even
  44. Gulp, WebPack, and Mix. These are specific tools that have been developed
  45. for the implementation of the second definition:
  46. 2. A general noun "build system" refers to the particular start-to-finish
  47. process through which a specific piece of software is mapped from its raw
  48. *inputs* (source code, resource libraries, toolchains) to the outputs
  49. (applications, appliances, libraries, or web sites).
  50. For example, LLVM and Blender both use the CMake "Build System," but their
  51. "build system" is not the same. The "build system" for each is wildly
  52. different, despite both using the same underlying "Build System."
  53. ``dds`` takes a massive divergence at this point. One project using ``dds`` as
  54. their build system has an identical build process to every other project using
  55. ``dds``. Simply running :code:`dds -F` is enough to build *any* ``dds``
  56. project.
  57. In order to reach this uniformity and simplicity, ``dds`` drops almost all
  58. aspects of project-by-project customizability. Instead, ``dds`` affords the
  59. developer a contract:
  60. If you play by my rules, you get to play in my space.
  61. .. _design.rules:
  62. The Rules
  63. *********
  64. We've talked an awful lot about the "rules" and "restrictions" that ``dds``
  65. imposes, but what are they?
  66. .. _design.rules.not-apps:
  67. ``dds`` Is not Made for Complex Applications
  68. ===============================================
  69. Alright, this one isn't a "rule" as much as a recommendation: If you are
  70. building an application that *needs* some build process functionality that
  71. ``dds`` does not provide, ``dds`` is only open to changes that do not
  72. violate any of the other existing rules.
  73. .. note::
  74. **However:** If you are a *library* author and you find that ``dds``
  75. cannot correctly build your library without violating other rules, we may
  76. have to take a look. This is certainly not to say it will allow arbitrary
  77. customization features to permit the rules to be bent arbitrarily: Read
  78. on.
  79. ``dds`` contains a minimal amount of functionality for building simple
  80. applications, but it is certainly not its primary purpose (See the ``--apps``
  81. flag).
  82. .. _design.rules.change:
  83. *Your* Code Should Be Changed Before ``dds`` Should Be Changed
  84. =================================================================
  85. The wording of this rule means that the onus is on the library developer to
  86. meet the expectations that ``dds`` prescribes in order to make the build
  87. work.
  88. If your library meets all the requirements outlined in this document but you
  89. still find trouble in making your build work, this is grounds for change in
  90. ``dds``, either in clarifying the rules or tweaking ``dds`` functionality.
  91. .. _design.rules.layout:
  92. Library Projects Must Meet the Layout Requirements
  93. ==================================================
  94. This is a very concrete requirement. ``dds`` prescribes a particular project
  95. structure layout with minimal differing options. ``dds`` prescribes the
  96. `Pitchfork`_ layout requirements.
  97. .. note::
  98. These prescriptions are not as draconian as they may sound upon first
  99. reading. Refer to the :doc:`layout` page for more information.
  100. .. _Pitchfork: https://api.csswg.org/bikeshed/?force=1&url=https://raw.githubusercontent.com/vector-of-bool/pitchfork/develop/data/spec.bs
  101. .. _design.rules.no-cond-compile:
  102. A Library Build Must Successfully Compile All Source Files
  103. ==========================================================
  104. Almost all Build Systems have a concept of *conditionally* adding a source file
  105. to a build. ``dds`` elides this feature in place of relying on in-source
  106. conditional compilation.
  107. .. _design.rules.no-lazy-code-gen:
  108. All Code Must Be in Place Before Building
  109. =========================================
  110. ``dds`` does not provide code-generation functionality. Instead, any
  111. generated code should be generated and committed to the repository to be only
  112. ever modified through such generation scripts.
  113. .. _design.rules.one-binary-per-src:
  114. All Compilable Files in a ``src/`` Directory Must Link Together
  115. ===============================================================
  116. As part of the prescribed project layout, the ``src/`` project directory
  117. contains source files. ``dds`` requires that *all* source files in a given
  118. ``src/`` directory should link together cleanly. Practically, this means that
  119. every ``src/`` directory must correspond to *exactly* one library.
  120. .. _design.rules.include:
  121. No Arbitrary ``#include`` Directories
  122. =====================================
  123. Only ``src/`` and ``include/`` will ever be used as the basis for header
  124. resolution while building a library, so all ``#include`` directives should be
  125. relative to those directories. Refer to :ref:`guide.layout.include`.
  126. .. _design.rules.uniform-compile:
  127. All Files Compile with the Same Options
  128. =======================================
  129. When DDS compiles a library, every source file will be compiled with an
  130. identical set of options. Additionally, when DDS compiles a dependency tree,
  131. every library in that dependency tree will be compiled with an identical set of
  132. options. Refer to the :doc:`toolchains` page for more information.