-
Notifications
You must be signed in to change notification settings - Fork 1.3k
Convert binding to N-API #2440
base: v5
Are you sure you want to change the base?
Convert binding to N-API #2440
Conversation
This is getting pretty close. There's a segfault in one of the tests I still need to debug. It's worth noting this unwinds the work @stefanpenner's to implement |
a342097
to
cec10ba
Compare
I have it compiling and running most of the tests. There is a segfault that seems semi random. I'll need to investigate. I've update the the install scripts to use the N-API version instead of module version. Have confirmed binary compiled Node 10 executes on Node 6, 8, 9, 10. Although 9 displays an annoying warning that people will definitely files issues about because... |
96b5e31
to
73a9cea
Compare
I've resolved the segfault. All tests are passing locally (OSX) on all Node LTS and current. We'll need to rejig CI a bit since the binary no longer builds on Node < 10. |
a9ba52c
to
fa03e0f
Compare
We have our first green N-API builds Just for kicks the current hacked CI setup shows that binaries built on Node 10 work on other LTS Node. |
@nschonni note this means we probably can't have node-gyp fallback to build |
No, the node-pre-gyp handles napi vs the module version in it's download and fallback |
Sorry what I mean is that with N-API we can no longer compile the binary on Node < 10. So if the download fails there's no point node-pre-gyp falling back to build locally. |
Ah, gotcha, but I think it is backported to v6 & v8. I think older stuff may be able to have support through https://github.com/nodejs/node-addon-api/blob/master/doc/setup.md but I'm not 💯 |
In my experiments binaries built on 10 run back until 6, but I couldn't get
it to build on < 10 because the have different napi versions. I could be
missing something though
…On Tue., 17 Jul. 2018, 2:14 am Nick Schonning, ***@***.***> wrote:
Ah, gotcha, but I think it is backported to v6 & v8. I think older stuff
may be able to have support through
https://github.com/nodejs/node-addon-api/blob/master/doc/setup.md but I'm
not 💯
—
You are receiving this because you were assigned.
Reply to this email directly, view it on GitHub
<#2440 (comment)>, or mute
the thread
<https://github.com/notifications/unsubscribe-auth/AAjZWEVhL0lhyjPYXpGzE9DtAqzfK9nUks5uHLvogaJpZM4VGwiO>
.
|
Four years ago there was a test that mutated `process.cwd` but didn't correctly reset it. The altered global state resulted in future tests having incorrect assetions. I only noticed this because for some reason it manifested in failures in only _some_ Node versions when N-API was being used.
This flag means we skip a bunch of code paths in CI which is not ideal. Since we tell people to use `npm rebuild` we should eat our own dog food. With this patch we do an install, then do a rebuild hitting all the major install code paths. Fixes #1453
Followup-to: #2553
indent_type_len == 1 ? '\t' : ' ' | ||
).c_str()); | ||
|
||
napi_value propertyLinefeed; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
indentation problem?
binding.gyp
Outdated
'xcode_settings': { | ||
'CLANG_CXX_LANGUAGE_STANDARD': 'c++11', | ||
'OTHER_CPLUSPLUSFLAGS': [ | ||
'-std=c++11' | ||
], |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
why do need this? should be covered by line 33 already...
// We can opt-in to later versions as we choose to adopt new API features. | ||
// | ||
// See https://nodejs.org/api/n-api.html#n_api_n_api_version_matrix | ||
Math.min(process.versions.napi, 3), |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Will napi version change when libuv interface is modified? we use that heavily as well.
napi_value Color::getConstructor(napi_env env, napi_callback cb) { | ||
napi_value ctor; | ||
napi_property_descriptor descriptors[] = { | ||
{ "getR", nullptr, GetR }, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
../src/sass_types/color.cpp:66:31: warning: missing field 'getter'
initializer [-Wmissing-field-initializers]
{ "getR", nullptr, GetR },
and for others, too
@@ -2,30 +2,32 @@ | |||
#define CALLBACK_BRIDGE_H | |||
|
|||
#include <vector> | |||
#include <nan.h> | |||
#include <algorithm> | |||
#include <uv.h> |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Including <uv.h>
breaks guarantees of ABI stability offered by N-API. #2312 (comment)
|
||
namespace SassTypes | ||
{ | ||
// This is the interface that all sass values must comply with | ||
class Value : public Nan::ObjectWrap { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We probable need to rebuild this without inheritance at all. Maybe this should become a template? We definitely need https://github.com/nodejs/node-addon-api/blob/master/doc/object_wrap.md here
…2620) * fix: the function only need to execute once enough * fix: typo `;`
Is anyone still working on this 👋 |
…overread Fix file content malloc to avoid reading beyond buffer
Heavy work in progress of replacing NAN with N-API.
Attempting to combine the prior work boingoing#1 with the drift in master, namely #2128 #2298.
Fixes #1988