Skip to content
Merged
Changes from 1 commit
Commits
Show all changes
65 commits
Select commit Hold shift + click to select a range
1d03df4
crypto: add Hash.prototype.copy() method
bnoordhuis Oct 9, 2019
a63f7e7
dgram: add source-specific multicast support
Oct 2, 2017
39070bb
doc: make YAML matter consistent in crypto.md
Trott Oct 18, 2019
5ca5864
cli: add --trace-uncaught flag
addaleax Oct 18, 2019
f01c5c5
inspector: turn platform tasks that outlive Agent into no-ops
addaleax Oct 18, 2019
5ba842b
build: python3 support for configure
rvagg Oct 21, 2019
8b75aab
crypto: guard with OPENSSL_NO_GOST
codebytere Oct 21, 2019
0d9ae1b
deps: V8: cherry-pick ed40ab1
targos Oct 22, 2019
edfbee3
module: resolve self-references
hybrist Aug 20, 2019
1cfa98c
deps: V8: cherry-pick c721203
targos Oct 22, 2019
a03809d
test: verify npm compatibility with releases
targos Oct 23, 2019
ea9d125
doc: add legendecas to collaborators
legendecas Oct 25, 2019
fd0aded
src: allow inspector without v8 platform
codebytere Oct 21, 2019
cedad02
build: prefer python 3 over 2 for configure
sam-github Oct 23, 2019
8980d8c
build: vcbuild uses default Python, not Py2
joaocgreis Oct 24, 2019
1d9f427
test: use arrow functions for callbacks
mpark86 Oct 22, 2019
93b1bb8
n-api,doc: add info about building n-api addons
jschlight Oct 18, 2019
4458378
async_hooks: only emit `after` for AsyncResource if stack not empty
addaleax Oct 23, 2019
45c70a9
doc: remove dashes
Trott Oct 24, 2019
381c6cd
doc: delete "a number of" things in the docs
Trott Oct 23, 2019
32a5389
doc,n-api: sort bottom-of-the-page references
Oct 25, 2019
9a71091
doc: revise os.md
Trott Oct 23, 2019
f3d00c5
deps: V8: backport 777fa98
targos Oct 22, 2019
d78e317
src: fix crash with SyntheticModule#setExport
targos Oct 22, 2019
621eaf9
doc: remove "it is important to" phrasing
Trott Oct 24, 2019
a375754
tools: doc: improve async workflow of generate.js
tpoisseau Oct 24, 2019
d91d270
doc: claim NODE_MODULE_VERSION=80 for Electron 9
MarshallOfSound Oct 21, 2019
3c23224
doc: adjust code sample for stream.finished
imcotton Oct 15, 2019
e4ab6fc
doc: remove incorrect and outdated example
tniessen Oct 26, 2019
07b5584
fs: add `bufferSize` option to `fs.opendir()`
addaleax Oct 25, 2019
d549a34
tools: update ESLint to 6.6.0
cjihrig Oct 25, 2019
d05f67c
cli: whitelist new V8 flag in NODE_OPTIONS
codebytere Oct 23, 2019
87f14e1
stream: extract Readable.from in its own file
mcollina Oct 26, 2019
98c8f76
src: split up InitializeContext
codebytere Oct 22, 2019
403a648
doc: fix numbering in require algorithm
hybrist Oct 25, 2019
978946e
doc,meta: prefer aliases and stubs over Runtime Deprecations
Trott Oct 28, 2019
2505f67
http: support readable hwm in IncomingMessage
cjihrig Oct 26, 2019
dfb4a24
doc: fix an error in resolution algorithm steps
Oct 11, 2019
a48d179
doc: add options description for send APIs
dev-script Oct 7, 2019
3709b5c
doc: move inactive Collaborators to emeriti
Trott Oct 30, 2019
e312448
deps: update npm to 6.12.1
Oct 29, 2019
1499a72
doc: improve doc Http2Session:Timeout
dev-script Oct 29, 2019
b255688
build: fix pkg-config search for libnghttp2
bnoordhuis Oct 27, 2019
ae81360
doc: update AUTHORS list
targos Oct 27, 2019
ec7b69f
src: change env.h includes for forward declarations
alferpal Oct 26, 2019
14981f5
tools: git rm -r tools/v8_gypfiles/broken
cclauss Oct 27, 2019
5469811
build: find Python syntax errors in dependencies
cclauss Oct 27, 2019
104bfb9
deps: V8: cherry-pick e5dbc95
Oct 30, 2019
bcbcce5
tools: undefined name opts -> args in gyptest.py
cclauss Oct 27, 2019
e2fb353
tools: use print() function in buildbot_run.py
cclauss Oct 27, 2019
348ec69
tools: fix Python 3 syntax error in mac_tool.py
cclauss Oct 27, 2019
f8fb2c0
doc: linkify `.fork()` in cluster documentation
addaleax Oct 29, 2019
050efeb
meta: use contact_links instead of issue templates
targos Oct 30, 2019
a0df91c
src: expose granular SetIsolateUpForNode
codebytere Oct 26, 2019
cc1cd2b
src: isolate->Dispose() order consistency
codebytere Oct 30, 2019
03827dd
build: allow Python 3.8
targos Oct 31, 2019
b7070f3
doc: explain http2 aborted event callback
dev-script Oct 30, 2019
201a60e
doc: linkify `.setupMaster()` in cluster doc
trivikr Nov 1, 2019
fc407bb
doc: add missing hash for header link
nschonni Oct 31, 2019
68e4b5a
tools: fix Python 3 deprecation warning in test.py
Hellzed Nov 1, 2019
46c9194
deps: V8: cherry-pick a7dffcd767be
cclauss Nov 3, 2019
8860bd6
buffer: improve performance caused by primordials
jizusun Nov 3, 2019
49e7f04
build: add workaround for WSL
gengjiawen Nov 2, 2019
1bded98
build: fix detection of Visual Studio 2017
richardlau Oct 25, 2019
64eacd8
2019-11-05, Version 13.1.0 (Current)
targos Nov 5, 2019
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
n-api,doc: add info about building n-api addons
Adds information about tools available for building N-API addons.

Fixes: nodejs/abi-stable-node#384
PR-URL: #30032
Reviewed-By: Anna Henningsen <anna@addaleax.net>
Reviewed-By: Gabriel Schulhof <gabriel.schulhof@intel.com>
Reviewed-By: Luigi Pinca <luigipinca@gmail.com>
Reviewed-By: Colin Ihrig <cjihrig@gmail.com>
Reviewed-By: Michael Dawson <michael_dawson@ca.ibm.com>
  • Loading branch information
jschlight authored and targos committed Oct 28, 2019
commit 93b1bb8cb5cc3c6cc9726ea804f4af181217e1e9
119 changes: 109 additions & 10 deletions doc/api/n-api.md
Original file line number Diff line number Diff line change
Expand Up @@ -14,11 +14,10 @@ changes in the underlying JavaScript engine and allow modules
compiled for one major version to run on later major versions of Node.js without
recompilation. The [ABI Stability][] guide provides a more in-depth explanation.

Addons are built/packaged with the same approach/tools
outlined in the section titled [C++ Addons](addons.html).
The only difference is the set of APIs that are used by the native code.
Instead of using the V8 or [Native Abstractions for Node.js][] APIs,
the functions available in the N-API are used.
Addons are built/packaged with the same approach/tools outlined in the section
titled [C++ Addons][]. The only difference is the set of APIs that are used by
the native code. Instead of using the V8 or [Native Abstractions for Node.js][]
APIs, the functions available in the N-API are used.

APIs exposed by N-API are generally used to create and manipulate
JavaScript values. Concepts and operations generally map to ideas specified
Expand Down Expand Up @@ -76,8 +75,7 @@ if (status != napi_ok) {
The end result is that the addon only uses the exported C APIs. As a result,
it still gets the benefits of the ABI stability provided by the C API.

When using `node-addon-api` instead of the C APIs, start with the API
[docs](https://github.com/nodejs/node-addon-api#api-documentation)
When using `node-addon-api` instead of the C APIs, start with the API [docs][]
for `node-addon-api`.

## Implications of ABI Stability
Expand Down Expand Up @@ -118,11 +116,95 @@ must make use exclusively of N-API by restricting itself to using
and by checking, for all external libraries that it uses, that the external
library makes ABI stability guarantees similar to N-API.

## Building

Unlike modules written in JavaScript, developing and deploying Node.js
native addons using N-API requires an additional set of tools. Besides the
basic tools required to develop for Node.js, the native addon developer
requires a toolchain that can compile C and C++ code into a binary. In
addition, depending upon how the native addon is deployed, the *user* of
the native addon will also need to have a C/C++ toolchain installed.

For Linux developers, the necessary C/C++ toolchain packages are readily
available. [GCC][] is widely used in the Node.js community to build and
test across a variety of plarforms. For many developers, the [LLVM][]
compiler infrastructure is also a good choice.

For Mac developers, [Xcode][] offers all the required compiler tools.
However, it is not necessary to install the entire Xcode IDE. The following
command installs the necessary toolchain:

```bash
xcode-select --install
```

For Windows developers, [Visual Studio][] offers all the required compiler
tools. However, it is not necessary to install the entire Visual Studio
IDE. The following command installs the necessary toolchain:

```bash
npm install --global --production windows-build-tools
```

The sections below describe the additional tools available for developing
and deploying Node.js native addons.

### Build tools

Both the tools listed here require that *users* of the native
addon have a C/C++ toolchain installed in order to successfully install
the native addon.

#### node-gyp

[node-gyp][] is a build system based on Google's [GYP][] tool and comes
bundled with npm. GYP, and therefore node-gyp, requires that Python be
installed.

Historically, node-gyp has been the tool of choice for building native
addons. It has widespread adoption and documentation. However, some
developers have run into limitations in node-gyp.

#### CMake.js

[CMake.js][] is an alternative build system based on [CMake][].

CMake.js is a good choice for projects that already use CMake or for
developers affected by limitations in node-gyp.

### Uploading precompiled binaries

The three tools listed here permit native addon developers and maintainers
to create and upload binaries to public or private servers. These tools are
typically integrated with CI/CD build systems like [Travis CI][] and
[AppVeyor][] to build and upload binaries for a variety of platforms and
architectures. These binaries are then available for download by users who
do not need to have a C/C++ toolchain installed.

#### node-pre-gyp

[node-pre-gyp][] is a tool based on node-gyp that adds the ability to
upload binaries to a server of the developer's choice. node-pre-gyp has
particularly good support for uploading binaries to Amazon S3.

#### prebuild

[prebuild][] is a tool that supports builds using either node-gyp or
CMake.js. Unlike node-pre-gyp which supports a variety of servers, prebuild
uploads binaries only to [GitHub releases][]. prebuild is a good choice for
GitHub projects using CMake.js.

#### prebuildify

[prebuildify][] is tool based on node-gyp. The advantage of prebuildify is
that the built binaries are bundled with the native module when it's
uploaded to npm. The binaries are downloaded from npm and are immediately
available to the module user when the native module is installed.

## Usage

In order to use the N-API functions, include the file
[`node_api.h`](https://github.com/nodejs/node/blob/master/src/node_api.h)
which is located in the src directory in the node development tree:
In order to use the N-API functions, include the file [`node_api.h`][] which is
located in the src directory in the node development tree:

```C
#include <node_api.h>
Expand Down Expand Up @@ -5222,3 +5304,20 @@ This API may only be called from the main thread.
[context-aware addons]: addons.html#addons_context_aware_addons
[node-addon-api]: https://github.com/nodejs/node-addon-api
[worker threads]: https://nodejs.org/api/worker_threads.html
[C++ Addons]: addons.html
[docs]: https://github.com/nodejs/node-addon-api#api-documentation
[GCC]: https://gcc.gnu.org
[LLVM]: https://llvm.org
[Xcode]: https://developer.apple.com/xcode/
[Visual Studio]: https://visualstudio.microsoft.com
[node-gyp]: https://github.com/nodejs/node-gyp
[GYP]: https://gyp.gsrc.io
[CMake.js]: https://github.com/cmake-js/cmake-js
[CMake]: https://cmake.org
[Travis CI]: https://travis-ci.org
[AppVeyor]: https://www.appveyor.com
[node-pre-gyp]: https://github.com/mapbox/node-pre-gyp
[prebuild]: https://github.com/prebuild/prebuild
[GitHub releases]: https://help.github.com/en/github/administering-a-repository/about-releases
[prebuildify]: https://github.com/prebuild/prebuildify
[`node_api.h`]: https://github.com/nodejs/node/blob/master/src/node_api.h