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],
"node/no-unsupported-features/es-builtins": [
"error",
{ "version": ">=16.17.0" }
{ "version": ">=18.12.1" }
],
"node/no-unsupported-features/node-builtins": [
"error",
{ "version": ">=16.17.0" }
{ "version": ">=18.12.1" }
],
"func-names": [
"error",

View File

@ -4,7 +4,8 @@
"name": "Win32",
"includePath": [
"${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": [
"UNICODE",

View File

@ -2,8 +2,7 @@
This is a part of [Node3D](https://github.com/node-3d) project.
[![NPM Package][npm]][npm-url]
[![NPM](https://nodei.co/npm/addon-tools-raub.png?compact=true)](https://www.npmjs.com/package/addon-tools-raub)
[![NPM](https://badge.fury.io/js/addon-tools-raub.svg)](https://badge.fury.io/js/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**:
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
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_EXT(VAL)` - return `Napi::External`, expected `VAL` is a pointer.
* `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>
@ -150,6 +151,7 @@ That extrapolates well to all the helpers below:
| `REQ_ARRAY_ARG` | `object` | `Napi::Array` | - |
| `USE_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_ARRV_ARG` | `ArrayBuffer` | `Napi::ArrayBuffer` | - |
| `REQ_BUF_ARG` | `Buffer` | `Napi::Buffer<uint8_t>` | - |

View File

@ -14,10 +14,12 @@ A snippet for **src/package.json**:
"version": "0.0.0",
"private": true,
"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": {
"addon-tools-raub": "6.0.0",
"addon-tools-raub": "6.1.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
append any given URL with `/${platform}.zip`
In **package.json**:
```
"config" : {
"install" : "v1.0.0"
},
"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.
To use it, create the *install.js* file in your addon:
Create the **install.js** file:
```
'use strict';
const install = require('addon-tools-raub/install');
const prefix = 'https://github.com/USER/ADDON/releases/download';
const tag = process.env.npm_package_config_install;
const prefix = 'https://github.com/node-3d/glfw-raub/releases/download';
const tag = '4.8.0';
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**.
* 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
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
`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.
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_bin' : '<!(node -p "require(\'DEPS\').bin")',
},
'targets': [
{
'target_name' : 'bullet',
'targets': [{
'target_name' : 'ADDON',
'sources' : [
'cpp/addon.cpp',
],
@ -138,39 +145,31 @@ dependency include path(s).
'<!@(node -p "require(\'addon-tools-raub\').include")',
'<(DEPS_include)',
],
'library_dirs' : [ '<(DEPS_bin)' ],
'libraries' : [ '-lDEPS' ],
'cflags!': ['-fno-exceptions'],
'cflags_cc!': ['-fno-exceptions'],
'defines': ['UNICODE', '_UNICODE'],
'library_dirs': ['<(DEPS_bin)'],
'libraries': ['-lDEPS' ],
'cflags_cc': ['-std=c++17'],
'conditions': [
[
'OS=="linux"',
{
['OS=="linux"', {
'libraries': [
"-Wl,-rpath,'$$ORIGIN'",
"-Wl,-rpath,'$$ORIGIN/../node_modules/DEPS/<(bin)'",
"-Wl,-rpath,'$$ORIGIN/../../DEPS/<(bin)'",
],
'defines': ['__linux__'],
}
],
[
'OS=="mac"',
{
}],
['OS=="mac"', {
'libraries': [
'-Wl,-rpath,@loader_path',
'-Wl,-rpath,@loader_path/../node_modules/DEPS/<(bin)',
'-Wl,-rpath,@loader_path/../../DEPS/<(bin)',
],
'MACOSX_DEPLOYMENT_TARGET': '10.9',
'defines': ['__APPLE__'],
}
],
[
'OS=="win"',
{
'CLANG_CXX_LIBRARY': 'libc++',
'OTHER_CFLAGS': ['-std=c++17'],
}],
['OS=="win"', {
'defines' : [
'WIN32_LEAN_AND_MEAN',
'VC_EXTRALEAN',
@ -186,12 +185,9 @@ dependency include path(s).
'AdditionalOptions' : ['/RELEASE','/OPT:REF','/OPT:ICF','/LTCG'],
},
},
},
}],
],
],
},
]
}],
}
```

4
package-lock.json generated
View File

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

View File

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

43
test/binding.gyp vendored
View File

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