Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Move the project to NAPI #36

Merged
merged 13 commits into from
Jul 27, 2021
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

This library attempts to follow the libudev where it makes sense. I only needed some usb input device detection so I was happy with quite few features.

Requires node-v0.8.0, nan and libudev.
Requires node-v10.0.0, nan and libudev.

## Installation

Expand Down
47 changes: 22 additions & 25 deletions binding.gyp
Original file line number Diff line number Diff line change
@@ -1,27 +1,24 @@
{
"targets": [
{
"target_name": "udev",
"sources": [ "udev.cc" ],
"libraries": [
"-ludev",
],
"include_dirs" : [
"<!(node -e \"require('nan')\")"
]
},

{
"target_name": "action_after_build",
"type": "none",
"dependencies": [ "<(module_name)" ],
"copies": [
{
"files": [ "<(PRODUCT_DIR)/<(module_name).node" ],
"destination": "<(module_path)"
}
]
}

"targets": [{
"target_name": "udev",
"cflags!": [ "-fno-exceptions" ],
"cflags_cc!": [ "-fno-exceptions" ],
"xcode_settings": { "GCC_ENABLE_CPP_EXCEPTIONS": "YES",
"CLANG_CXX_LIBRARY": "libc++",
"MACOSX_DEPLOYMENT_TARGET": "10.7",
},
"msvs_settings": {
"VCCLCompilerTool": { "ExceptionHandling": 1 },
},
"sources": [ "main.cc", "udev.cc" ],
"libraries": [
"-ludev",
],
"include_dirs" : [
"<!@(node -p \"require('node-addon-api').include\")"
],
'dependencies': [
"<!(node -p \"require('node-addon-api').gyp\")"
]
}
}]
}
17 changes: 17 additions & 0 deletions main.cc
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
#include <napi.h>

#include "udev.h"

static Napi::Object Init(Napi::Env env, Napi::Object exports) {
Napi::HandleScope scope(env);

exports.Set("list", Napi::Function::New(env, Udev::List));
exports.Set("getNodeParentBySyspath",
Napi::Function::New(env, Udev::GetNodeParentBySyspath));
exports.Set("getSysattrBySyspath",
Napi::Function::New(env, Udev::GetSysattrBySyspath));

return Monitor::Init(env, exports);
}

NODE_API_MODULE(NODE_GYP_MODULE_NAME, Init)
Loading