Du kan inte välja fler än 25 ämnen Ämnen måste starta med en bokstav eller siffra, kan innehålla bindestreck ('-') och vara max 35 tecken långa.

303 lines
7.9KB

  1. .. highlight:: yaml
  2. Toolchains
  3. ##########
  4. One of the core components of ``dds`` is that of the *toolchain*. A toolchain
  5. encompasses the environment used to build and link source code, including, but
  6. not limited to:
  7. #. The executable binaries that constitute the language implementation:
  8. Compilers, linkers, and archive managers.
  9. #. The configuration of those tools, including most options given to those
  10. tools when they are invoked.
  11. #. The set of preprocessor macros and language features that are active during
  12. compilation.
  13. When a build is run, every file in the entire tree (including dependencies)
  14. will be compiled, archived, and linked using the same toolchain.
  15. This page provides an introduction on how one can make use of toolchains most
  16. effectively in your project.
  17. .. note::
  18. **IMPORTANT**: ``dds`` will *not* automatically load the Visual C++
  19. environment. To use Visual C++, ``dds`` must be executed from the
  20. appropriate environment in order for the Visual C++ toolchain executables
  21. and files to be available.
  22. Passing a Toolchain
  23. *******************
  24. In ``dds``, the default format of a toolchain is that of a single file that
  25. describes the entire toolchain, and uses the extension ``.tc.dds`` by
  26. convention. When running a build for a project, the ``dds`` executable will
  27. look for a file named ``toolchain.tc.dds`` by default, and will error out if
  28. this file does not exist. A different toolchain can be provided by passing the
  29. toolchain file for the ``--toolchain`` (or ``-t``) option on the command line::
  30. $ dds build -t my-toolchain.tc.dds
  31. Alternatively, you can pass the name of a built-in toolchain. See below.
  32. Built-in Toolchains
  33. *******************
  34. For convenience, ``dds`` includes several built-in toolchains that can be
  35. accessed in the ``--toolchain`` command-line option using a colon ``:``
  36. prefix::
  37. $ dds build -T :gcc
  38. ``dds`` will treat the leading colon (``:``) as a name for a built-in
  39. toolchain (this means that a toolchain's filepath may not begin with a colon).
  40. There are several built-in toolchains that may be specified:
  41. ``:gcc``
  42. Uses the default ``gcc`` and ``g++`` executables, linkers, and options
  43. thereof.
  44. ``:gcc-N`` (for some integer ``N``)
  45. Equivalent to ``:gcc``, but uses the ``gcc-N`` and ``g++-N`` executables.
  46. ``:clang``
  47. Equivalent to ``:gcc``, but uses the ``clang`` and ``clang++`` executables.
  48. ``:clang-N`` (for some integer ``N``)
  49. Equivalent to ``:clang``, but uses the ``clang-N`` and ``clang++-N``
  50. executables.
  51. ``:msvc``
  52. Compiles and links using the Visual C++ toolchain.
  53. The following pseudo-toolchains are also available:
  54. ``:debug:XYZ``
  55. Uses built-in toolchain ``:XYZ``, but generates debugging information.
  56. ``:ccache:XYZ``
  57. Uses built-in toolchain ``:XYZ``, but prefixes all compile commands with
  58. ``ccache``.
  59. ``:c++UV:XYZ`` (for two integers ``UV``)
  60. Sets the C++ version to ``C++UV`` and uses the ``:XYZ`` toolchain.
  61. Toolchain Definitions
  62. *********************
  63. Besides using the built-in toolchains, it is likely that you'll soon want to
  64. customize a toolchain further. Further customization must be done with a
  65. file that contains the toolchain definition. The most basic toolchain file is
  66. simply one line:
  67. .. code-block::
  68. Compiler-ID: <compiler-id>
  69. where ``<compiler-id>`` is one of the known ``Compiler-ID`` options (See the
  70. toolchain option reference). ``dds`` will infer common suitable defaults for
  71. the remaining options based on the value of ``Compiler-ID``.
  72. For example, if you specify ``GNU``, then ``dds`` will assume ``gcc`` to be the
  73. C compiler, ``g++`` to be the C++ compiler, and ``ar`` to be the library
  74. archiving tool.
  75. If you know that your compiler executable has a different name, you can
  76. specify them with additional options:
  77. .. code-block::
  78. Compiler-ID: GNU
  79. C-Compiler: gcc-9
  80. C++-Compiler: g++-9
  81. ``dds`` will continue to infer other options based on the ``Compiler-ID``, but
  82. will use the provided executable names when compiling files for the respective
  83. languages.
  84. To specify compilation flags, the ``Flags`` option can be used:
  85. .. code-block::
  86. Flags: -fsanitize=address -fno-inline
  87. .. note::
  88. Use ``Warning-Flags`` to specify options regarding compiler warnings.
  89. Flags for linking executables can be specified with ``Link-Flags``:
  90. .. code-block::
  91. Link-Flags: -fsanitize=address -fPIE
  92. Toolchain Option Reference
  93. **************************
  94. The following options are available to be specified within a toolchain file:
  95. ``Compiler-ID``
  96. ---------------
  97. Specify the identity of the compiler. This option is used to infer many other
  98. facts about the toolchain. If specifying the full toolchain with the command
  99. templates, this option is not required.
  100. Valid values are:
  101. ``GNU``
  102. For GCC
  103. ``Clang``
  104. For LLVM/Clang
  105. ``MSVC``
  106. For Microsoft Visual C++
  107. ``C-Compiler`` and ``C++-Compiler``
  108. -----------------------------------
  109. Names/paths of the C and C++ compilers, respectively. Defaults will be inferred
  110. from ``Compiler-ID``.
  111. ``C-Version`` and ``C++-Version``
  112. ---------------------------------
  113. Specify the language versions for C and C++, respectively. By default, ``dds``
  114. will not set any language version. Using this option requires that the
  115. ``Compiler-ID`` be specified
  116. Valid ``C-Version`` values are:
  117. - ``C89``
  118. - ``C99``
  119. - ``C11``
  120. - ``C18``
  121. Valid ``C++-Version`` values are:
  122. - ``C++98``
  123. - ``C++03``
  124. - ``C++11``
  125. - ``C++14``
  126. - ``C++17``
  127. - ``C++20``
  128. .. warning::
  129. ``dds`` will not do any "smarts" to infer the exact option to pass to have
  130. the required effect. If you ask for ``C++20`` from ``gcc 5.3``, ``dds``
  131. will simply pass ``-std=c++20`` with no questions asked. If you need
  132. finer-grained control, use the ``Flags`` option.
  133. ``Warning-Flags``
  134. -----------------
  135. Override the compiler flags that should be used to enable warnings. This option
  136. is stored separately from ``Flags``, as these options may be enabled/disabled
  137. separately depending on how ``dds`` is invoked.
  138. .. note::
  139. If ``Compiler-ID`` is provided, a default value will be used that enables
  140. common warning levels.
  141. If you need to tweak warnings further, use this option.
  142. ``Flags``, ``C-Flags``, and ``C++-Flags``
  143. -----------------------------------------
  144. Specify *additional* compiler options, possibly per-language.
  145. ``Link-Flags``
  146. --------------
  147. Specify *additional* link options to use when linking executables.
  148. ``Optimize``
  149. ------------
  150. Boolean option (``True`` or ``False``) to enable/disable optimizations. Default
  151. is ``False``.
  152. ``Debug``
  153. ---------
  154. Boolean option (``True`` or ``False``) to enable/disable the generation of
  155. debugging information. Default is ``False``.
  156. ``Compiler-Launcher``
  157. ---------------------
  158. Provide a command prefix that should be used on all compiler executions.
  159. e.g. ``ccache``.
  160. Advanced Options Reference
  161. **************************
  162. The options below are probably not good to tweak unless you *really* know what
  163. you are doing. Their values will be inferred from ``Compiler-ID``.
  164. ``Deps-Mode``
  165. -------------
  166. Specify the way in which ``dds`` should track compilation dependencies. One
  167. of ``GNU``, ``MSVC``, or ``None``.
  168. ``C-Compile-File``
  169. ------------------
  170. Override the *command template* that is used to compile C source files.
  171. ``C++-Compile-File``
  172. --------------------
  173. Override the *command template* that is used to compile C++ source files.
  174. ``Create-Archive``
  175. ------------------
  176. Override the *command template* that is used to generate static library archive
  177. files.
  178. ``Link-Executable``
  179. -------------------
  180. Override the *command template* that is used to link executables.
  181. ``Include-Template``
  182. --------------------
  183. Override the *command template* for the flags to specify a header search path.
  184. ``External-Include-Template``
  185. -----------------------------
  186. Override the *command template* for the flags to specify a header search path
  187. of an external library.
  188. ``Define-Template``
  189. -------------------
  190. Override the *command template* for the flags to set a preprocessor definition.