Node.js 原生 C/C++插件构建工具

介绍

  1. gyp(python写的,已经改用GN):google 开源的跨平台构建系统,与 cmake 类似
  2. node-gyp:专门提供给 Node.js 编译 C++模块使用的
  3. node-gyp 流程 ```bash
  4. make
  5. make install
  6. cmake
  7. gyp
  8. node-gyp ```

    安装

  9. python 3.6+

  10. v8.h
  11. Visual C++ Build Tools

    1. yarn global add node-gyp

    使用

  12. binding.gyp 指定需要编译的文件

    1. {
    2. "targets": [
    3. {
    4. "target_name": "binding",
    5. "sources": [ "src/binding.cc" ]
    6. }
    7. ]
    8. }
  13. 命令

    1. # configure 利用 gyp 生成不同的预编译配置文件
    2. node-gyp configure
    3. # build 根据不同平台、不同构建配置进行编译
    4. node-gyp build

    参考链接

  14. https://github.com/tsy77/blog/issues/5

  15. https://blog.csdn.net/putao2062/article/details/107884370
  16. https://github.com/nodejs/node-gyp/blob/master/README.md