node-gyp - 处理“.h.in”文件

问题描述:

我创建了一个包含git子模块libxml2的项目。我想在我的binding.gyp里面使用这个文件,但是我在运行node-gyp build时遇到错误。这里的问题是只有一个xmlversion.h.in文件,但需要xmlversion.h文件。node-gyp - 处理“.h.in”文件

当我运行libxml2第一一切的autogen.sh脚本工作正常,因为autotools将创建xmlversion.h文件出xmlversion.h.in的。

有没有办法使用node-gyp来创建xmlversion.h文件?

我现在bindings.gyp看起来像这样:

{ 
    'targets': [{ 
     'target_name': 'library', 
     'product_extension': 'node', 
     'type': 'shared_library', 
     'include_dirs': [ 
      'libxml2/include', 
      'libxml2', 
      "<!(node -e \"require('nan')\")" 
     ], 
     'cflags': [ '-Wall' ], 
     'xcode_settings': { 
      'OTHER_CFLAGS': [ '-Wall' ] 
     }, 
     'sources': [ 
      # src/my_files.cc 
      # libxml2/libxml2_files.c 
     ] 
    }] 
} 
+0

你有什么特别的理由使用节点GYP,并与自动工具混? – VTT

的最佳解决方案,以在文件解决.h.in的问题是,它曾经使用autotools,并创建.h文件复制到的另一目录下建项目(所以子模块不会受到影响)。此外,您可能必须为几个平台或体系结构构建这些文件。之后,你可以添加一个新的文件夹到你的包括。对于一个相当不错的解决方案,请访问:

Github DEMO