You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

196 lines
7.7KB

  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 and 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" with ``dds``.
  10. Another design decision is that ``dds`` is built to be driven by automated
  11. tools as well as humans. ``dds`` is not designed to entirely replace existing
  12. build systems and package management solutions. Rather, it is designed to be
  13. easy to integrate *with* existing systems and tools.
  14. Background
  15. **********
  16. I'm going to say something somewhat controversial: C and C++ don't need
  17. "package management." At least, not *generalized* "package management." C++
  18. needs *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 a nearly identical build process to every other project
  55. using ``dds``. Simply running :code:`dds build -t <toolchain>` should be enough
  56. to build *any* ``dds`` 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.
  81. .. _design.rules.change:
  82. *Your* Code Should Be Changed Before ``dds`` Should Be Changed
  83. =================================================================
  84. The wording of this rule means that the onus is on the library developer to
  85. meet the expectations that ``dds`` prescribes in order to make the build
  86. work.
  87. If your library meets all the requirements outlined in this document but you
  88. still find trouble in making your build work, this is grounds for change in
  89. ``dds``, either in clarifying the rules or tweaking ``dds`` functionality.
  90. .. _design.rules.layout:
  91. Library Projects Must Meet the Layout Requirements
  92. ==================================================
  93. This is a very concrete requirement. ``dds`` prescribes a particular project
  94. structure layout with minimal differing options. ``dds`` prescribes the
  95. `Pitchfork`_ layout requirements.
  96. .. note::
  97. These prescriptions are not as draconian as they may sound upon first
  98. reading. Refer to the :doc:`guide/packages` page for more information.
  99. .. _Pitchfork: https://api.csswg.org/bikeshed/?force=1&url=https://raw.githubusercontent.com/vector-of-bool/pitchfork/develop/data/spec.bs
  100. .. _design.rules.no-cond-compile:
  101. A Library Build Must Successfully Compile All Source Files
  102. ==========================================================
  103. Almost all Build Systems have a concept of *conditionally* adding a source file
  104. to a build. ``dds`` elides this feature in place of relying on in-source
  105. conditional compilation.
  106. .. _design.rules.no-lazy-code-gen:
  107. All Code Must Be in Place Before Building
  108. =========================================
  109. ``dds`` does not provide code-generation functionality. Instead, any
  110. generated code should be generated and committed to the repository to be only
  111. ever modified through such generation scripts.
  112. .. _design.rules.one-binary-per-src:
  113. All Compilable Files in a ``src/`` Directory Must Link Together
  114. ===============================================================
  115. As part of the prescribed project layout, the ``src/`` project directory
  116. contains source files. ``dds`` requires that *all* source files in a given
  117. ``src/`` directory should link together cleanly. Practically, this means that
  118. every ``src/`` directory must correspond to *exactly* one library.
  119. .. _design.rules.include:
  120. No Arbitrary ``#include`` Directories
  121. =====================================
  122. Only ``src/`` and ``include/`` will ever be used as the basis for header
  123. resolution while building a library, so all ``#include`` directives should be
  124. relative to those directories. Refer to :ref:`pkg.source-root`.
  125. .. _design.rules.uniform-compile:
  126. All Files Compile with the Same Options
  127. =======================================
  128. When DDS compiles a library, every source file will be compiled with an
  129. identical set of options. Additionally, when DDS compiles a dependency tree,
  130. every library in that dependency tree will be compiled with an identical set of
  131. options. Refer to the :doc:`guide/toolchains` page for more information.
  132. Currently, the only exception to this rules is for flags that control compiler
  133. warnings: Dependencies will be compiled without adding any warnings flags,
  134. while the main project will be compiled with warnings enabled by default.