node-gyp - 处理“.h.in”文件
node-gyp - Handling ".h.in" files
我创建了一个包含 git 子模块 libxml2
的项目。我想在 binding.gyp
中使用此文件,但在 运行 node-gyp build
时出现错误。这里的问题是只有一个 xmlversion.h.in
文件,但需要一个 xmlversion.h
文件。
当我是 运行 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
]
}]
}
解决文件.h.in
问题的最佳方案是使用autotools
构建一次,并将创建的.h
文件复制到项目的其他目录(所以子模块不会受到影响)。此外,您可能必须为多个平台或架构构建这些文件。之后,您可以将新文件夹添加到您的包含中。这里有一个非常好的解决方案:
我创建了一个包含 git 子模块 libxml2
的项目。我想在 binding.gyp
中使用此文件,但在 运行 node-gyp build
时出现错误。这里的问题是只有一个 xmlversion.h.in
文件,但需要一个 xmlversion.h
文件。
当我是 运行 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
]
}]
}
解决文件.h.in
问题的最佳方案是使用autotools
构建一次,并将创建的.h
文件复制到项目的其他目录(所以子模块不会受到影响)。此外,您可能必须为多个平台或架构构建这些文件。之后,您可以将新文件夹添加到您的包含中。这里有一个非常好的解决方案: