1.0.4 • Published 4 years ago

hello_publishing-native-pre-gyp v1.0.4

Weekly downloads
1
License
ISC
Repository
-
Last release
4 years ago

在hello-publishing-native基础上,node-pre-gyp预编译

常用命令: npm i # 安装依赖库

arch等于当前node的arch

npm run build:node # 编译出node环境 npm run build:electron --target=8.2.5 --toolset=v141 # toolset指定vs编译工具 npm run upload # 上传 npm search 'hello_publishing-native-pre-gyp' # 最新发布版本 预拉取关键日志:node-pre-gyp http GET

远程:https://bingjunliu.cn/hello_publishing/node_modules/hello-v1.0.0-node-v57-darwin-x64.tar.gz 本地:lib/node-v57-darwin-x64-unknown/grpc_node.nod 规则为: 远程位置:{host}/{package_name} 本地位置:{module_path} package_name默认是{module_name}-v{version}-{node_abi}-{platform}-{arch}.tar.gz

必需配置 "binary": { "module_name": "hello", "module_path": "lib/{node_abi}-{platform}-{arch}-{libc}", "host": "https://bingjunliu.cn/hello_publishing/" } 具体: node_abi: node-v57 或 electron-v4.0,来自 node-v${NODE_MODULE_VERSION} 或 ${runtime}-v${target} platform: darwin,来自:node -p process.platform arch: x64 或 ia32,来自:node -p process.arch libc: unknown-v1.0.0-node-v57-darwin-x64

打包流程: node node_modules/node-pre-gyp/bin/node-pre-gyp rebuild package # 源码编译,tar.gz打包,结果在build/stage node node_modules/node-pre-gyp/bin/node-pre-gyp --runtime=electron --target=4.0.3 --dist-url=https://atom.io/download/electron rebuild package 把tar.gz放到https://bingjunliu.cn/hello_publishing

具体问题: problem1: 预编译包tar.gz上传bingjunliu.cn 1. npm run build:node 2. cp build/stage/hello-* ~/Documents/205_rsync_dir/html/hello_publishing 3. cd ~/Documents/205_rsync_dir; sh html_rsync.sh push problem2: js发布到npmjs 1. npm publish problem3: 代码提交到git 1. git push

问题:building.gpy能同时对node-pre-gyp与node-gyp通用吗 -- 通用的,仅仅module_name和module_path需要手工配置 如:node node_modules/node-gyp/bin/node-gyp.js configure build --module_name=hello --module_path=../lib node node_modules/node-pre-gyp/bin/node-pre-gyp rebuild

问题:MacOS的都不需要依赖node,但Win都需要 因为Mac使用-undefined dynamic_lookup链接,在运行时才找符号 electron-v4.0-darwin-x64/hello.node: /usr/lib/libc++.1.dylib (compatibility version 1.0.0, current version 400.9.4) /usr/lib/libSystem.B.dylib (compatibility version 1.0.0, current version 1252.200.5) node-v57-darwin-x64/hello.node: /usr/lib/libc++.1.dylib (compatibility version 1.0.0, current version 400.9.4) /usr/lib/libSystem.B.dylib (compatibility version 1.0.0, current version 1252.200.5) electron-v4.0-win32-ia32\hello.node: c:\windows\system32\KERNEL32.DLL c:\program files\nodejs\NODE.EXE node-v64-win32-ia32\hello.node: c:\windows\system32\KERNEL32.DLL c:\program files\nodejs\NODE.EXE 差异在于依赖的node的版本,这在编译时设置 electron-v4.0-win32-ia32\hello.node "C:\Users\lbj\AppData\Local\node-gyp\Cache\5.0.8\ia32\node.lib" node-v64-win32-ia32\hello.node依赖: "C:\Users\lbj\AppData\Local\node-gyp\Cache\10.15.3\ia32\node.lib"

detail 实践上遇到: 1. package.json的binary的module_name需与binding.gpy的target_name一样,否则错误,需加--verbose才能看到: Traceback (most recent call last): ... File "/Users/lbj/Documents/tools/node-v12.13.0-darwin-x64/lib/node_modules/npm/node_modules/node-gyp/gyp/pylib/gyp/input.py", line 1514, in RemoveLinkDependenciesFromNoneTargets if targetst.get('variables', {}).get('link_dependency', 0): KeyError: 'binding.gyp:hello#target'

mark npm publish 发布如下文件, npm notice === Tarball Contents === npm notice 3.0kB hello.cc
npm notice 415B index.js
npm notice 802B package.json npm notice 3.5kB README.md
由于package.json#files配置了白名单,建议做法:配置黑名单,.npmignore,.gitignore,这项目没用到这点

1.0.2

4 years ago

1.0.1

4 years ago

1.0.4

4 years ago

1.0.3

4 years ago

1.0.0

6 years ago