1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
|
---
title: Building NSS
slug: NSS/Building
translation_of: Mozilla/Projects/NSS/Building
---
<p><font face="x-locale-heading-primary, zillaslab, Palatino, Palatino Linotype, x-locale-heading-secondary, serif"><span style="font-size: 37.33327865600586px;"><strong>介绍</strong></span></font></p>
<p>此页包含有关如何构建NSS的详细信息。因为NSS是一个跨平台的库,它构建在许多不同的平台上,并且有许多选项,所以构建起来可能很复杂。在尝试构建之前,请仔细阅读这些说明。</p>
<h2 id="Build_环境">Build 环境</h2>
<p>NSS需要一个C和C++编译器。它有最小的依赖关系,包括标准的C和C++库,再加上ZLIB。</p>
<p>For building, you also need <a href="https://www.gnu.org/software/make/">make</a>. Ideally, also install <a href="https://gyp.gsrc.io/">gyp</a> and <a href="https://ninja-build.org/">ninja</a> and put them on your path. This is recommended, as the build is faster and more reliable.</p>
<h3 id="Windows">Windows</h3>
<p>Windows上的NSS编译使用与Mozilla Firefox相同的共享生成系统。 你必须先安装 <a href="/en-US/docs/Developer_Guide/Build_Instructions/Windows_Prerequisites">Windows Prerequisites</a>, 包括 <strong>MozillaBuild</strong>.</p>
<p>您还可以在Windows子系统上为Linux构建NSS,但是生成的二进制文件不能被其他Windows应用程序使用。</p>
<p><font face="x-locale-heading-primary, zillaslab, Palatino, Palatino Linotype, x-locale-heading-secondary, serif"><span style="font-size: 37.33327865600586px;"><strong>获取源码</strong></span></font></p>
<p>NSS和NSPR像其他Mozilla项目一样使用Mercurial进行源代码管理。 要查看NSS和NSPR的最新源(可能不是稳定版本的一部分),请使用以下命令:</p>
<pre>hg clone https://hg.mozilla.org/projects/nspr
hg clone https://hg.mozilla.org/projects/nss
</pre>
<p>To get the source of a specific release, see <a href="/en-US/docs/Mozilla/Projects/NSS/NSS_Releases">NSS Releases</a>.</p>
<dl>
<dd>
<dl>
</dl>
</dd>
</dl>
<h2 id="Build">Build</h2>
<p>Build NSS using our build script:</p>
<pre>nss/build.sh
</pre>
<p>This builds both NSPR and NSS.</p>
<h2 id="Build_with_make">Build with make</h2>
<p>Alternatively, there is a <code>make</code> target called "nss_build_all", which produces a similar result. This supports some alternative options, but can be a lot slower.</p>
<pre>make -C nss nss_build_all USE_64=1
</pre>
<p>The make-based build system for NSS uses a variety of variables to control the build. Below are some of the variables, along with possible values they may be set to.</p>
<dl>
<dt>BUILD_OPT</dt>
<dd>
<dl>
<dt>0</dt>
<dd>Build a debug (non-optimized) version of NSS. <em>This is the default.</em></dd>
<dt>1</dt>
<dd>Build an optimized (non-debug) version of NSS.</dd>
</dl>
</dd>
<dt>USE_64</dt>
<dd>
<dl>
<dt>0</dt>
<dd>Build for a 32-bit environment/ABI. <em>This is the default.</em></dd>
<dt>1</dt>
<dd>Build for a 64-bit environment/ABI. <em>This is recommended.</em></dd>
</dl>
</dd>
<dt>USE_ASAN</dt>
<dd>
<dl>
<dt>0</dt>
<dd>Do not create an <a href="http://clang.llvm.org/docs/AddressSanitizer.html">AddressSanitizer</a> build. <em>This is the default.</em></dd>
<dt>1</dt>
<dd>Create an AddressSanitizer build.</dd>
</dl>
</dd>
</dl>
<h2 id="单元测试">单元测试</h2>
<p>NSS包含大量的单元测试。运行这些测试的脚本可以在测试目录中找到。 通过以下方式运行标准套件:</p>
<pre>HOST=localhost DOMSUF=localdomain USE_64=1 nss/tests/all.sh</pre>
<h3 id="单元测试配置">单元测试配置</h3>
<p>NSS测试是使用环境变量配置的。<br>
脚本将尝试推断主机和DOMSUF的值,但可能会失败。 用主机名和域后缀替换localhost和localdomain。 您需要能够连接到$HOST.$DOMSUF。</p>
<p>如果没有域后缀,则可以将条目添加到/etc/hosts (on Windows,<code> c:\Windows\System32\drivers\etc\hosts</code>) as follows:</p>
<pre><code>127.0.0.1 localhost.localdomain</code></pre>
<p>验证是否打开命令shell并键入: <code>ping localhost.localdomain</code>.</p>
<p>Remove the <code>USE_64=1</code> override if using a 32-bit build.</p>
<h3 id="测试结果">测试结果</h3>
<p>运行所有测试可能需要相当长的时间。</p>
<p>测试输出存储在tests_results/security/$HOST.$NUMBER/中。 文件results.html概要结果,output.log捕获所有测试输出。</p>
<p>nss/tests的其他子目录包含运行完整套件子集的脚本。 它们可以直接运行,而不是all.sh,这可能会节省一些时间,但会降低覆盖率。</p>
|