123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134 |
- <?xml version="1.0" encoding="UTF-8"?>
- <!DOCTYPE sect1 PUBLIC "-//OASIS//DTD DocBook XML V4.5//EN"
- "http://www.oasis-open.org/docbook/xml/4.5/docbookx.dtd" [
- <!ENTITY % general-entities SYSTEM "../general.ent">
- %general-entities;
- ]>
- <sect1 id="ch-system-ninja" role="wrap">
- <?dbhtml filename="ninja.html"?>
- <sect1info condition="script">
- <productname>ninja</productname>
- <productnumber>&ninja-version;</productnumber>
- <address>&ninja-url;</address>
- </sect1info>
- <title>Ninja-&ninja-version;</title>
- <indexterm zone="ch-system-ninja">
- <primary sortas="a-Ninja">Ninja</primary>
- </indexterm>
- <sect2 role="package">
- <title/>
- <para>Ninja 是一个注重速度的小型构建系统。</para>
- <segmentedlist>
- <segtitle>&buildtime;</segtitle>
- <segtitle>&diskspace;</segtitle>
- <seglistitem>
- <seg>&ninja-ch6-sbu;</seg>
- <seg>&ninja-ch6-du;</seg>
- </seglistitem>
- </segmentedlist>
- </sect2>
- <sect2 role="installation">
- <title>安装 Ninja</title>
- <para>在运行时, ninja 一般尽量并行运行更多进程,
- 默认情况下最大进程数是系统 CPU 核心数加 2 得到的值。
- 某些情况下,这样会导致 CPU 过热,或者耗尽系统内存。
- 如果使用命令行执行 ninja,可以传递 -jN 参数以限制并行进程数,
- 但某些软件包内嵌了 ninja 的执行过程,且并不传递 -j 参数。</para>
- <para>应用下面这个 <emphasis>可选的</emphasis> 修改,
- 用户即可通过一个环境变量 NINJAJOBS 限制并行进程数量。
- <command>例如</command> 设置:
- <!--Using <command> here to make the output bold. We really don't want
- users setting this now and experience shows that many users blindly
- copy/paste anything in a box. -->
- <!-- 这里的 <command> 标记用于加粗。我们确实不希望用户现在就设置
- 该变量,过去的经验表明许多用户盲目地复制粘贴矩形框中的所有内容。
- 译注:这可能是全书唯一一个被翻译的注释。-->
- <screen>export NINJAJOBS=4</screen>
- 会限制 ninja 使用 4 个并行进程。</para>
- <para>如果您希望 Ninja 能够使用环境变量 NINJAJOBS,执行以下命令,
- 添加这一功能:</para>
- <screen><userinput remap="pre">sed -i '/int Guess/a \
- int j = 0;\
- char* jobs = getenv( "NINJAJOBS" );\
- if ( jobs != NULL ) j = atoi( jobs );\
- if ( j > 0 ) return j;\
- ' src/ninja.cc</userinput></screen>
- <para>构建 Ninja:</para>
- <screen><userinput remap="configure">python3 configure.py --bootstrap</userinput></screen>
- <variablelist>
- <title>构建选项的含义:</title>
- <varlistentry>
- <term><parameter>--bootstrap</parameter></term>
- <listitem>
- <para>这个参数强制 ninja 为当前系统重新构建自身。</para>
- </listitem>
- </varlistentry>
- </variablelist>
- <para>运行以下命令以测试编译结果:</para>
- <screen><userinput remap="test">python3 configure.py
- ./ninja ninja_test
- ./ninja_test --gtest_filter=-SubprocessTest.SetWithLots</userinput></screen>
- <para>安装该软件包:</para>
- <screen><userinput remap="install">install -vm755 ninja /usr/bin/
- install -vDm644 misc/bash-completion /usr/share/bash-completion/completions/ninja
- install -vDm644 misc/zsh-completion /usr/share/zsh/site-functions/_ninja</userinput></screen>
- </sect2>
- <sect2 id="contents-ninja" role="content">
- <title>Ninja 的内容</title>
- <segmentedlist>
- <segtitle>安装的程序</segtitle>
- <seglistitem>
- <seg>ninja</seg>
- </seglistitem>
- </segmentedlist>
- <variablelist>
- <bridgehead renderas="sect3">简要描述</bridgehead>
- <?dbfo list-presentation="list"?>
- <?dbhtml list-presentation="table"?>
- <varlistentry id="ninja">
- <term><command>ninja</command></term>
- <listitem>
- <para>是 ninja 构建系统</para>
- <indexterm zone="ch-system-ninja ninja">
- <primary sortas="b-ninja">ninja</primary>
- </indexterm>
- </listitem>
- </varlistentry>
- </variablelist>
- </sect2>
- </sect1>
|