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.

124 satır
4.5KB

  1. Project Layout
  2. ##############
  3. The layout expected by ``dds`` is based on the `Pitchfork layout`_ (PFL).
  4. ``dds`` does not make use of every provision of the layout document, but the
  5. features it does have are based on PFL.
  6. .. _Pitchfork layout: https://api.csswg.org/bikeshed/?force=1&url=https://raw.githubusercontent.com/vector-of-bool/pitchfork/develop/data/spec.bs
  7. In particular, the following directories are used:
  8. - ``src/``
  9. - ``include/``
  10. - ``libs/``
  11. - ``_build/`` (the default build output directory used by ``dds``).
  12. Note that the ``libs/*/`` directories can contain their own ``src/`` and
  13. ``include/`` directories, the purposes and behaviors of which match those of
  14. their top-level counterparts.
  15. .. _guide.layout.include:
  16. Include Directories and Header Resolution
  17. *****************************************
  18. A compiler's "include path" is the list of directories in which it will attempt
  19. to resolve ``#include`` directives.
  20. The layout prescriptions permit either ``src/``, ``include/``, or both. In the
  21. presence of both, the ``include/`` directory is used as the *public* include
  22. directory, and ``src/`` is used as the *private* include directory. When only
  23. one of either is present, that directory will be treated as the *public*
  24. include directory (and there will be no *private* include directory).
  25. .. _guide.layout.sources:
  26. Source Files
  27. ************
  28. ``dds`` distinguishes between *headers* and *compilable* sources. The heuristic
  29. used is based on common file extensions:
  30. The following are considered to be *header* source files:
  31. - ``.h``
  32. - ``.hpp``
  33. - ``.hxx``
  34. - ``.inl``
  35. - ``.h++``
  36. While the following are considered to be *compilable* source files:
  37. - ``.c``
  38. - ``.cpp``
  39. - ``.cc``
  40. - ``.cxx``
  41. - ``.c++``
  42. ``dds`` will compile every compilable source file that appears in the ``src/``
  43. directory. ``dds`` will not compile compilable source files that appear in the
  44. ``include/`` directory and will issue a warning on each file found.
  45. .. _guide.layout.apps-tests:
  46. Applications and Tests
  47. **********************
  48. ``dds`` will recognize certain compilable source files as belonging to
  49. applications and tests. If a compilable source file stem ends with ``.main`` or
  50. ``.test``, that source file is assumed to correspond to an executable to
  51. generate. The filename stem before the ``.main`` or ``.test`` will be used as
  52. the name of the generated executable. For example:
  53. - ``foo.main.cpp`` will generate an executable named ``foo``.
  54. - ``bar.test.cpp`` will generate an executable named ``bar``.
  55. - ``cat-meow.main.cpp`` will generate an executable named ``cat-meow``.
  56. - ``cats.musical.test.cpp`` will generate an executable named ``cats.musical``.
  57. .. note::
  58. ``dds`` will automatically append the appropriate filename extension to the
  59. generated executables based on the host and toolchain.
  60. If the inner extension is ``.main``, then ``dds`` will assume the corresponding
  61. executable to be an *application*. If the inner extension is ``.test``, ``dds``
  62. will assume the executable to be a test.
  63. The building of tests and applications can be controlled when running
  64. ``dds build``. If tests are built, ``dds`` will automatically execute those
  65. tests in parallel once the executables have been generated.
  66. In any case, the executables are associated with a *library*, and, when those
  67. executables are linked, the associated library (and its dependencies) will be
  68. linked into the final executable. There is no need to manually specify this
  69. linking behavior.
  70. .. _guide.layout.libraries:
  71. Libraries
  72. *********
  73. The *library* is a fundamental unit of consumable code, and ``dds`` is
  74. specifically built to work with them. When you are in ``dds``, the library is
  75. the center of everything.
  76. A *source root* is a directory that contains the ``src/`` and/or ``include/``
  77. directories. The ``src/`` and ``include/`` directories are themselves
  78. *source directories*. A single *source root* will always correspond to exactly
  79. one library. If the library has any compilable sources then ``dds`` will use
  80. those sources to generate a static library file that is linked into runtime
  81. binaries. If a library contains only headers then ``dds`` will not generate an
  82. archive to be included in downstream binaries, but it will still generate link
  83. rules for the dependencies of a header-only library.
  84. In the previous section, :ref:`guide.layout.apps-tests`, it was noted that
  85. applications and tests are associated with a library. This association is
  86. purely based on being collocated within the same source root.
  87. When an executable is built within the context of a library, that library (and
  88. all of its dependencies) will be linked into that executable.