Update info

This commit is contained in:
Luis Blanco 2022-12-05 22:44:35 +04:00
parent eafb17d791
commit 5d4708dfdf
8 changed files with 116 additions and 133 deletions

View File

@ -82,11 +82,11 @@
"no-console": [0], "no-console": [0],
"node/no-unsupported-features/es-builtins": [ "node/no-unsupported-features/es-builtins": [
"error", "error",
{ "version": ">=16.17.0" } { "version": ">=18.12.1" }
], ],
"node/no-unsupported-features/node-builtins": [ "node/no-unsupported-features/node-builtins": [
"error", "error",
{ "version": ">=16.17.0" } { "version": ">=18.12.1" }
], ],
"func-names": [ "func-names": [
"error", "error",

View File

@ -4,7 +4,8 @@
"name": "Win32", "name": "Win32",
"includePath": [ "includePath": [
"${workspaceFolder}/**", "${workspaceFolder}/**",
"${LocalAppData}/node-gyp/Cache/16.17.0/include/node" "${LocalAppData}/node-gyp/Cache/16.17.0/include/node",
"${LocalAppData}/node-gyp/Cache/18.12.1/include/node"
], ],
"defines": [ "defines": [
"UNICODE", "UNICODE",

View File

@ -2,8 +2,7 @@
This is a part of [Node3D](https://github.com/node-3d) project. This is a part of [Node3D](https://github.com/node-3d) project.
[![NPM Package][npm]][npm-url] [![NPM](https://badge.fury.io/js/addon-tools-raub.svg)](https://badge.fury.io/js/addon-tools-raub)
[![NPM](https://nodei.co/npm/addon-tools-raub.png?compact=true)](https://www.npmjs.com/package/addon-tools-raub)
[![CodeFactor](https://www.codefactor.io/repository/github/node-3d/addon-tools-raub/badge)](https://www.codefactor.io/repository/github/node-3d/addon-tools-raub) [![CodeFactor](https://www.codefactor.io/repository/github/node-3d/addon-tools-raub/badge)](https://www.codefactor.io/repository/github/node-3d/addon-tools-raub)
``` ```

View File

@ -22,7 +22,7 @@ require('addon-tools-raub').include // a string
### Helpers in **addon-tools.hpp**: ### Helpers in **addon-tools.hpp**:
Usually all the helpers work within the context of a method. In this case we Usually all the helpers work within the context of a method. In this case we
have `CallbackInfo info` passed as an argument. And we can return `undefined` have `Napi::CallbackInfo info` passed as an argument. And we can return `undefined`
in case a problem has occured. So most of these macros are only usable in case a problem has occured. So most of these macros are only usable
within `Napi::Value`-returning functions. within `Napi::Value`-returning functions.
@ -42,6 +42,7 @@ within `Napi::Value`-returning functions.
* `RET_NUM(VAL)` - return `Napi::Number`, expected `VAL` is of numeric type. * `RET_NUM(VAL)` - return `Napi::Number`, expected `VAL` is of numeric type.
* `RET_EXT(VAL)` - return `Napi::External`, expected `VAL` is a pointer. * `RET_EXT(VAL)` - return `Napi::External`, expected `VAL` is a pointer.
* `RET_BOOL(VAL)` - return `Napi::Boolean`, expected `VAL` is convertible to bool. * `RET_BOOL(VAL)` - return `Napi::Boolean`, expected `VAL` is convertible to bool.
* `RET_ARRAY_STR(VAL)` - return `Napi::Array`, expected `VAL` is `std::vector<std::string>`.
</details> </details>
@ -150,6 +151,7 @@ That extrapolates well to all the helpers below:
| `REQ_ARRAY_ARG` | `object` | `Napi::Array` | - | | `REQ_ARRAY_ARG` | `object` | `Napi::Array` | - |
| `USE_ARRAY_ARG` | `object` | `Napi::Array` | - | | `USE_ARRAY_ARG` | `object` | `Napi::Array` | - |
| `LET_ARRAY_ARG` | `object` | `Napi::Array` | `[]` | | `LET_ARRAY_ARG` | `object` | `Napi::Array` | `[]` |
| `LET_ARRAY_STR_ARG` | `object` | `std::vector<std::string>` | `std::vector<std::string>()` |
| `REQ_FUN_ARG` | `function` | `Napi::Function` | - | | `REQ_FUN_ARG` | `function` | `Napi::Function` | - |
| `REQ_ARRV_ARG` | `ArrayBuffer` | `Napi::ArrayBuffer` | - | | `REQ_ARRV_ARG` | `ArrayBuffer` | `Napi::ArrayBuffer` | - |
| `REQ_BUF_ARG` | `Buffer` | `Napi::Buffer<uint8_t>` | - | | `REQ_BUF_ARG` | `Buffer` | `Napi::Buffer<uint8_t>` | - |

View File

@ -14,10 +14,12 @@ A snippet for **src/package.json**:
"version": "0.0.0", "version": "0.0.0",
"private": true, "private": true,
"scripts": { "scripts": {
"build": "node-gyp rebuild && node -e \"require('addon-tools-raub/cpbin')('ADDON')\"" "build": "node-gyp rebuild"
"build-dev": "node-gyp build && node -e \"require('addon-tools-raub/cpbin')('ADDON')\""
"rebuild-dev": "node-gyp rebuild && node -e \"require('addon-tools-raub/cpbin')('ADDON')\""
}, },
"dependencies": { "dependencies": {
"addon-tools-raub": "6.0.0", "addon-tools-raub": "6.1.0",
"DEPS": "1.0.0" "DEPS": "1.0.0"
} }
} }
@ -34,26 +36,32 @@ In **package.json** use the `"postinstall"` script to download the libraries.
For example the following structure might work. Note that **Addon Tools** will For example the following structure might work. Note that **Addon Tools** will
append any given URL with `/${platform}.zip` append any given URL with `/${platform}.zip`
In **package.json**:
``` ```
"config" : {
"install" : "v1.0.0"
},
"scripts": { "scripts": {
"postinstall": "install", "postinstall": "node install",
}, },
"dependencies": {
"addon-tools-raub": "^6.0.2",
"adm-zip": "^0.5.9"
},
"devDependencies": {
"node-addon-api": "^5.0.0"
}
``` ```
Here `config.install` is the tag name to download the binaries from. Create the **install.js** file:
To use it, create the *install.js* file in your addon:
``` ```
'use strict';
const install = require('addon-tools-raub/install'); const install = require('addon-tools-raub/install');
const prefix = 'https://github.com/USER/ADDON/releases/download'; const prefix = 'https://github.com/node-3d/glfw-raub/releases/download';
const tag = process.env.npm_package_config_install; const tag = '4.8.0';
install(`${prefix}/${tag}`); install(`${prefix}/${tag}`);
``` ```
**Addon Tools** will unzip the downloaded file into the platform binary **Addon Tools** will unzip (using **adm-zip**) the downloaded file into the platform binary
directory. E.g. on Windows it will be **bin-windows**. directory. E.g. on Windows it will be **bin-windows**.
* For a dependency package: * For a dependency package:
@ -76,7 +84,7 @@ directory. E.g. on Windows it will be **bin-windows**.
Publishing binaries is done by attaching a zipped platform folder to the GitHub Publishing binaries is done by attaching a zipped platform folder to the GitHub
release. Zip file must NOT contain platform folder as a subfolder, but rather release. Zip file must NOT contain platform folder as a subfolder, but rather
contain the final binaries. The tag of the release should be the same as in contain the final binaries. The tag of the release should be the same as in
`npm_package_config_install` - that is the way installer will find it. **install.js**.
> NOTE: You can publish your binaries to anywhere, not necessarily GitHub. > NOTE: You can publish your binaries to anywhere, not necessarily GitHub.
Just tweak **YOUR install.js** script as appropriate. The only limitation Just tweak **YOUR install.js** script as appropriate. The only limitation
@ -128,9 +136,8 @@ dependency include path(s).
'DEPS_include' : '<!(node -p "require(\'DEPS\').include")', 'DEPS_include' : '<!(node -p "require(\'DEPS\').include")',
'DEPS_bin' : '<!(node -p "require(\'DEPS\').bin")', 'DEPS_bin' : '<!(node -p "require(\'DEPS\').bin")',
}, },
'targets': [ 'targets': [{
{ 'target_name' : 'ADDON',
'target_name' : 'bullet',
'sources' : [ 'sources' : [
'cpp/addon.cpp', 'cpp/addon.cpp',
], ],
@ -138,39 +145,31 @@ dependency include path(s).
'<!@(node -p "require(\'addon-tools-raub\').include")', '<!@(node -p "require(\'addon-tools-raub\').include")',
'<(DEPS_include)', '<(DEPS_include)',
], ],
'library_dirs' : [ '<(DEPS_bin)' ], 'defines': ['UNICODE', '_UNICODE'],
'libraries' : [ '-lDEPS' ], 'library_dirs': ['<(DEPS_bin)'],
'cflags!': ['-fno-exceptions'], 'libraries': ['-lDEPS' ],
'cflags_cc!': ['-fno-exceptions'], 'cflags_cc': ['-std=c++17'],
'conditions': [ 'conditions': [
['OS=="linux"', {
[
'OS=="linux"',
{
'libraries': [ 'libraries': [
"-Wl,-rpath,'$$ORIGIN'", "-Wl,-rpath,'$$ORIGIN'",
"-Wl,-rpath,'$$ORIGIN/../node_modules/DEPS/<(bin)'", "-Wl,-rpath,'$$ORIGIN/../node_modules/DEPS/<(bin)'",
"-Wl,-rpath,'$$ORIGIN/../../DEPS/<(bin)'", "-Wl,-rpath,'$$ORIGIN/../../DEPS/<(bin)'",
], ],
'defines': ['__linux__'], 'defines': ['__linux__'],
} }],
], ['OS=="mac"', {
[
'OS=="mac"',
{
'libraries': [ 'libraries': [
'-Wl,-rpath,@loader_path', '-Wl,-rpath,@loader_path',
'-Wl,-rpath,@loader_path/../node_modules/DEPS/<(bin)', '-Wl,-rpath,@loader_path/../node_modules/DEPS/<(bin)',
'-Wl,-rpath,@loader_path/../../DEPS/<(bin)', '-Wl,-rpath,@loader_path/../../DEPS/<(bin)',
], ],
'MACOSX_DEPLOYMENT_TARGET': '10.9',
'defines': ['__APPLE__'], 'defines': ['__APPLE__'],
} 'CLANG_CXX_LIBRARY': 'libc++',
], 'OTHER_CFLAGS': ['-std=c++17'],
}],
[ ['OS=="win"', {
'OS=="win"',
{
'defines' : [ 'defines' : [
'WIN32_LEAN_AND_MEAN', 'WIN32_LEAN_AND_MEAN',
'VC_EXTRALEAN', 'VC_EXTRALEAN',
@ -186,12 +185,9 @@ dependency include path(s).
'AdditionalOptions' : ['/RELEASE','/OPT:REF','/OPT:ICF','/LTCG'], 'AdditionalOptions' : ['/RELEASE','/OPT:REF','/OPT:ICF','/LTCG'],
}, },
}, },
}, }],
], ],
}],
],
},
]
} }
``` ```

4
package-lock.json generated
View File

@ -18,8 +18,8 @@
"typescript": "^4.9.3" "typescript": "^4.9.3"
}, },
"engines": { "engines": {
"node": ">=16.17.0", "node": ">=18.12.1",
"npm": ">=8.15.0" "npm": ">=8.19.2"
}, },
"peerDependencies": { "peerDependencies": {
"adm-zip": "^0.5.9", "adm-zip": "^0.5.9",

View File

@ -36,8 +36,8 @@
"README.md" "README.md"
], ],
"engines": { "engines": {
"node": ">=16.17.0", "node": ">=18.12.1",
"npm": ">=8.15.0" "npm": ">=8.19.2"
}, },
"scripts": { "scripts": {
"eslint": "eslint .", "eslint": "eslint .",

43
test/binding.gyp vendored
View File

@ -1,43 +1,30 @@
{ {
'targets': [ 'targets': [{
{
'target_name': 'test', 'target_name': 'test',
'sources': [ 'sources': [
'test.cpp', 'test.cpp',
], ],
'defines': [ 'defines': ['UNICODE', '_UNICODE'],
'UNICODE', '_UNICODE' 'cflags_cc': ['-std=c++17'],
],
'include_dirs': [ 'include_dirs': [
'<!@(node -p "require(\'..\').include")', '<!@(node -p "require(\'..\').include")',
], ],
'cflags_cc': ['-std=c++17'],
'conditions': [ 'conditions': [
[ ['OS=="linux"', {
'OS=="linux"',
{
'defines': ['__linux__'], 'defines': ['__linux__'],
} }],
], ['OS=="mac"', {
[ 'MACOSX_DEPLOYMENT_TARGET': '10.9',
'OS=="mac"',
{
'defines': ['__APPLE__'], 'defines': ['__APPLE__'],
'CLANG_CXX_LIBRARY': 'libc++',
'OTHER_CFLAGS': ['-std=c++17'], 'OTHER_CFLAGS': ['-std=c++17'],
} }],
], ['OS=="win"', {
[ 'defines' : ['WIN32_LEAN_AND_MEAN', 'VC_EXTRALEAN', '_WIN32'],
'OS=="win"',
{
'defines' : [
'WIN32_LEAN_AND_MEAN',
'VC_EXTRALEAN',
'_WIN32',
],
'msvs_settings' : { 'msvs_settings' : {
'VCCLCompilerTool' : { 'VCCLCompilerTool' : {
'AdditionalOptions' : [ 'AdditionalOptions' : [
'/O2','/Oy','/GL','/GF','/Gm-', '/O2','/Oy','/GL','/GF','/Gm-', '/std:c++17',
'/EHsc','/MT','/GS','/Gy','/GR-','/Gd', '/EHsc','/MT','/GS','/Gy','/GR-','/Gd',
] ]
}, },
@ -45,9 +32,7 @@
'AdditionalOptions' : ['/OPT:REF','/OPT:ICF','/LTCG'] 'AdditionalOptions' : ['/OPT:REF','/OPT:ICF','/LTCG']
}, },
}, },
}, }],
],
],
},
], ],
}],
} }