ninja.xml 4.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138
  1. <?xml version="1.0" encoding="UTF-8"?>
  2. <!DOCTYPE sect1 PUBLIC "-//OASIS//DTD DocBook XML V4.5//EN"
  3. "http://www.oasis-open.org/docbook/xml/4.5/docbookx.dtd" [
  4. <!ENTITY % general-entities SYSTEM "../general.ent">
  5. %general-entities;
  6. ]>
  7. <sect1 id="ch-system-ninja" role="wrap">
  8. <?dbhtml filename="ninja.html"?>
  9. <sect1info condition="script">
  10. <productname>ninja</productname>
  11. <productnumber>&ninja-version;</productnumber>
  12. <address>&ninja-url;</address>
  13. </sect1info>
  14. <title>Ninja-&ninja-version;</title>
  15. <indexterm zone="ch-system-ninja">
  16. <primary sortas="a-Ninja">Ninja</primary>
  17. </indexterm>
  18. <sect2 role="package">
  19. <title/>
  20. <para>Ninja 是一个注重速度的小型构建系统。</para>
  21. <segmentedlist>
  22. <segtitle>&buildtime;</segtitle>
  23. <segtitle>&diskspace;</segtitle>
  24. <seglistitem>
  25. <seg>&ninja-ch6-sbu;</seg>
  26. <seg>&ninja-ch6-du;</seg>
  27. </seglistitem>
  28. </segmentedlist>
  29. </sect2>
  30. <sect2 role="installation">
  31. <title>安装 Ninja</title>
  32. <!--para>When run, ninja normally runs a maximum number of processes
  33. in parallel. By default this is the number of cores on the system
  34. plus two. In some cases this can overheat a CPU or run a system out
  35. of memory. If run from the command line, passing a -jN parameter
  36. will limit the number of parallel processes, but some packages
  37. embed the execution of ninja and do not pass a -j parameter.</para-->
  38. <para>在运行时, ninja 一般尽量并行运行更多进程,
  39. 默认情况下最大进程数是系统 CPU 核心数加 2 得到的值。
  40. 某些情况下,这样会导致 CPU 过热,或者耗尽系统内存。
  41. 如果使用命令行执行 ninja,可以传递 -jN 参数以限制并行进程数,
  42. 但某些软件包内嵌了 ninja 的执行过程,且并不传递 -j 参数。</para>
  43. <!--para>Using the <emphasis>optional</emphasis> patch below allows a user to
  44. limit the number of parallel processes via an environment variable,
  45. NINJAJOBS. <command>For example</command> setting: -->
  46. <para>使用下面这个 <emphasis>可选的</emphasis> 补丁,
  47. 用户即可通过一个环境变量 NINJAJOBS 限制并行进程数量。
  48. <command>例如</command> 设置:
  49. <!-- Using <command> here to make the output bold. We really don't want
  50. users setting this now and experience shows that many users blindly
  51. copy/paste anything in a box. -->
  52. <!-- 这里的 <command> 标记用于加粗。我们确实不希望用户现在就设置
  53. 该变量,过去的经验表明许多用户盲目地复制粘贴矩形框中的所有内容。
  54. 译注:这可能是全书唯一一个被翻译的注释。-->
  55. <screen>export NINJAJOBS=4</screen>
  56. 会限制 ninja 使用 4 个并行进程。</para>
  57. <para>如果希望使用这个补丁,执行以下命令应用它:</para>
  58. <screen><userinput remap="pre">patch -Np1 -i ../ninja-1.8.2-add_NINJAJOBS_var-1.patch</userinput></screen>
  59. <para>构建 Ninja:</para>
  60. <screen><userinput remap="configure">python3 configure.py --bootstrap</userinput></screen>
  61. <variablelist>
  62. <title>构建选项的含义:</title>
  63. <varlistentry>
  64. <term><parameter>--bootstrap</parameter></term>
  65. <listitem>
  66. <para>这个参数强制 ninja 为当前系统重新构建自身。</para>
  67. </listitem>
  68. </varlistentry>
  69. </variablelist>
  70. <para>运行以下命令以测试编译结果:</para>
  71. <screen><userinput remap="test">python3 configure.py
  72. ./ninja ninja_test
  73. ./ninja_test --gtest_filter=-SubprocessTest.SetWithLots</userinput></screen>
  74. <para>安装该软件包:</para>
  75. <screen><userinput remap="install">install -vm755 ninja /usr/bin/
  76. install -vDm644 misc/bash-completion /usr/share/bash-completion/completions/ninja
  77. install -vDm644 misc/zsh-completion /usr/share/zsh/site-functions/_ninja</userinput></screen>
  78. </sect2>
  79. <sect2 id="contents-ninja" role="content">
  80. <title>Ninja 的内容</title>
  81. <segmentedlist>
  82. <segtitle>安装的程序</segtitle>
  83. <seglistitem>
  84. <seg>ninja</seg>
  85. </seglistitem>
  86. </segmentedlist>
  87. <variablelist>
  88. <bridgehead renderas="sect3">简要描述</bridgehead>
  89. <?dbfo list-presentation="list"?>
  90. <?dbhtml list-presentation="table"?>
  91. <varlistentry id="ninja">
  92. <term><command>ninja</command></term>
  93. <listitem>
  94. <para>是 ninja 构建系统</para>
  95. <indexterm zone="ch-system-ninja ninja">
  96. <primary sortas="b-ninja">ninja</primary>
  97. </indexterm>
  98. </listitem>
  99. </varlistentry>
  100. </variablelist>
  101. </sect2>
  102. </sect1>