Building NSS 编辑

Introduction

This page has detailed information on how to build NSS. Because NSS is a cross-platform library that builds on many different platforms and has many options, it may be complex to build. Please read these instructions carefully before attempting to build.

Build environment

NSS needs a C and C++ compiler.  It has minimal dependencies, including only standard C and C++ libraries, plus 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 compilation on Windows uses the same shared build system as Mozilla Firefox. You must first install the Windows Prerequisites, including MozillaBuild.

You can also build NSS on the Windows Subsystem for Linux, but the resulting binaries aren't usable by other Windows applications.

Get the source

NSS and NSPR use Mercurial for source control like other Mozilla projects. To check out the latest sources for NSS and NSPR--which may not be part of a stable release--use the following commands:

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

Build NSS using our build script:

nss/build.sh

This builds both NSPR and NSS.

Build with make

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.

BUILD_OPT
0
Build a debug (non-optimized) version of NSS. This is the default.
1
Build an optimized (non-debug) version of NSS.
USE_64
0
Build for a 32-bit environment/ABI. This is the default.
1
Build for a 64-bit environment/ABI. This is recommended.
USE_ASAN
0
Do not create an AddressSanitizer build. This is the default.
1
Create an AddressSanitizer build.

Unit testing

NSS contains extensive unit tests.  Scripts to run these are found in the tests directory.  Run the standard suite by:

HOST=localhost DOMSUF=localdomain USE_64=1 nss/tests/all.sh

Unit test configuration

NSS tests are configured using environment variables.
The scripts will attempt to infer values for HOST and DOMSUF, but can fail. Replace localhost and localdomain with the hostname and domain suffix for your host. You need to be able to connect to $HOST.$DOMSUF.

If you don't have a domain suffix you can add an entry to /etc/hosts (on Windows,c:\Windows\System32\drivers\etc\hosts) as follows:

127.0.0.1 localhost.localdomain

Validate this opening a command shell and typing: ping localhost.localdomain.

Remove the USE_64=1 override if using a 32-bit build.

Test results

Running all tests can take a considerable amount of time.

Test output is stored in tests_results/security/$HOST.$NUMBER/.  The file results.html summarizes the results, output.log captures all the test output.

Other subdirectories of nss/tests contain scripts that run a subset of the full suite. Those can be run directly instead of all.sh, which might save some time at the cost of coverage.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。
列表为空,暂无数据

词条统计

浏览:94 次

字数:5315

最后编辑:7 年前

编辑次数:0 次

    我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
    原文