--- title: Building NSS slug: NSS/Building translation_of: Mozilla/Projects/NSS/Building ---
介绍
此页包含有关如何构建NSS的详细信息。因为NSS是一个跨平台的库,它构建在许多不同的平台上,并且有许多选项,所以构建起来可能很复杂。在尝试构建之前,请仔细阅读这些说明。
NSS需要一个C和C++编译器。它有最小的依赖关系,包括标准的C和C++库,再加上ZLIB。
For building, you also need make. Ideally, also install gyp and ninja and put them on your path. This is recommended, as the build is faster and more reliable.
Windows上的NSS编译使用与Mozilla Firefox相同的共享生成系统。 你必须先安装 Windows Prerequisites, 包括 MozillaBuild.
您还可以在Windows子系统上为Linux构建NSS,但是生成的二进制文件不能被其他Windows应用程序使用。
获取源码
NSS和NSPR像其他Mozilla项目一样使用Mercurial进行源代码管理。 要查看NSS和NSPR的最新源(可能不是稳定版本的一部分),请使用以下命令:
hg clone https://hg.mozilla.org/projects/nspr hg clone https://hg.mozilla.org/projects/nss
To get the source of a specific release, see NSS Releases.
Build NSS using our build script:
nss/build.sh
This builds both NSPR and NSS.
Alternatively, there is a make
target called "nss_build_all", which produces a similar result. This supports some alternative options, but can be a lot slower.
make -C nss nss_build_all USE_64=1
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.
NSS包含大量的单元测试。运行这些测试的脚本可以在测试目录中找到。 通过以下方式运行标准套件:
HOST=localhost DOMSUF=localdomain USE_64=1 nss/tests/all.sh
NSS测试是使用环境变量配置的。
脚本将尝试推断主机和DOMSUF的值,但可能会失败。 用主机名和域后缀替换localhost和localdomain。 您需要能够连接到$HOST.$DOMSUF。
如果没有域后缀,则可以将条目添加到/etc/hosts (on Windows, c:\Windows\System32\drivers\etc\hosts
) as follows:
127.0.0.1 localhost.localdomain
验证是否打开命令shell并键入: ping localhost.localdomain
.
Remove the USE_64=1
override if using a 32-bit build.
运行所有测试可能需要相当长的时间。
测试输出存储在tests_results/security/$HOST.$NUMBER/中。 文件results.html概要结果,output.log捕获所有测试输出。
nss/tests的其他子目录包含运行完整套件子集的脚本。 它们可以直接运行,而不是all.sh,这可能会节省一些时间,但会降低覆盖率。