具有nw-gyp的Node-webkit多平台本机模块

时间:2021-12-05 05:40:28

I'm currently writing a node-webkit application which uses a native module (lwip). I found out that I need to compile native modules with nw-gyp. After using nw-gyp a new file lwip_image.node will be created under node_modules/lwip/build/Release.

我目前正在编写一个使用本机模块(lwip)的node-webkit应用程序。我发现我需要使用nw-gyp编译本机模块。使用nw-gyp后,将在node_modules / lwip / build / Release下创建一个新文件lwip_image.node。

  1. How is the native module required? Like this: var lwip_image = require('./node_modules/lwip/build/Release/lwip_image.node') ??

    如何需要本机模块?像这样:var lwip_image = require('。/ node_modules / lwip / build / Release / lwip_image.node')??

  2. If the native module was created on Win8 x64, will it also work on Win7 x64 or even Win8/7 x32? Same question for Mac vs Ubuntu x32 vs Ubuntu x64?

    如果本机模块是在Win8 x64上创建的,它还可以在Win7 x64甚至Win8 / 7 x32上运行吗?对于Mac和Ubuntu x32与Ubuntu x64相同的问题?

  3. To facilitate the build process I would build the native modules on the target platforms once. After that I would like to copy them all to my project dir so I can automate the build process to build it for all platforms at once. How would I go about that? Use os.platform() and require depending on platform? ...

    为了促进构建过程,我将在目标平台上构建一次本机模块。之后我想将它们全部复制到我的项目目录中,这样我就可以自动化构建过程,立即为所有平台构建它。我该怎么办呢?使用os.platform()并要求依赖于平台? ...

UPDATE: Those posts were what I was looking for: https://github.com/joyent/node/issues/4398#issuecomment-11233144 https://github.com/npm/npm/issues/1891

更新:那些帖子是我想要的:https://github.com/joyent/node/issues/4398#issuecomment-11233144 https://github.com/npm/npm/issues/1891

1 个解决方案

#1


2  

  1. Your module's short name will be used in "require"
  2. 您的模块的简称将用于“require”

  3. Your 32-bit code (compiled with target=ia32) will work on 64-bit platform, but not the other way around
  4. 您的32位代码(使用target = ia32编译)将在64位平台上运行,但不是相反

  5. After you have compiled your module for all platforms, it should be enough to pack different zip, .app or .exe versions for different platforms, with different respective binaries of your module.
  6. 在为所有平台编译模块之后,应该足以为不同的平台打包不同的zip,.app或.exe版本,以及模块的不同相应二进制文件。

#1


2  

  1. Your module's short name will be used in "require"
  2. 您的模块的简称将用于“require”

  3. Your 32-bit code (compiled with target=ia32) will work on 64-bit platform, but not the other way around
  4. 您的32位代码(使用target = ia32编译)将在64位平台上运行,但不是相反

  5. After you have compiled your module for all platforms, it should be enough to pack different zip, .app or .exe versions for different platforms, with different respective binaries of your module.
  6. 在为所有平台编译模块之后,应该足以为不同的平台打包不同的zip,.app或.exe版本,以及模块的不同相应二进制文件。