node-gyp - 处理" .h.in"档

时间:2017-09-27 16:35:44

标签: python c++ node.js autoconf node-gyp

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

当我运行libxml2 autotools脚本时,首先一切正常,因为xmlversion.h会在xmlversion.h.in之外创建xmlversion.h文件

有没有办法使用node-gyp创建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 ] }] } 看起来像这样:

==5935== Invalid write of size 1
==5935==    at 0x50EAEEF: SetAggressiveDecommit (page_heap.h:197)
==5935==    by 0x50EAEEF: SetupAggressiveDecommit (static_vars.cc:120)
==5935==    by 0x50EAEEF: google_init_module_tcmalloc_setup_aggressive_decommit (static_vars.cc:122)
==5935==    by 0x50EAEEF: GoogleInitializer (googleinit.h:46)
==5935==    by 0x50EAEEF: __static_initialization_and_destruction_0 (static_vars.cc:122)
==5935==    by 0x50EAEEF: _GLOBAL__sub_I_static_vars.cc (static_vars.cc:124)
==5935==    by 0x400F3A2: _dl_init (in /usr/lib64/ld-2.17.so)
==5935==    by 0x4001469: ??? (in /usr/lib64/ld-2.17.so)
==5935==  Address 0x8309c is not stack'd, malloc'd or (recently) free'd

1 个答案:

答案 0 :(得分:0)

解决文件中.h.in问题的最佳解决方案是使用autotools构建它并将创建的.h文件复制到项目的其他目录(So子模块不会受到影响)。此外,您可能必须为多个平台或体系结构构建这些文件。之后,您可以在包含中添加新文件夹。一个非常好的解决方案可以在这里找到:

Github DEMO