Du kannst nicht mehr als 25 Themen auswählen Themen müssen entweder mit einem Buchstaben oder einer Ziffer beginnen. Sie können Bindestriche („-“) enthalten und bis zu 35 Zeichen lang sein.

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