Search code examples
pythonc++node.jsautoconfnode-gyp

node-gyp - Handling ".h.in" files


I created a project which contains a git submodule libxml2. I want to use this files inside my binding.gyp, but i get errors while running node-gyp build. The problem here is that there is only a xmlversion.h.in file but an xmlversion.h file is needed.

When i am running the autogen.sh script of libxml2 first everything is working fine, because the autotools will create the xmlversion.h file out of the xmlversion.h.in.

Is there a way to create the xmlversion.h file using node-gyp?

My current bindings.gyp looks like that:

{
    '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
        ]
    }]
}

Solution

  • The best solution to solve the problem of .h.in in files is to build it once using the autotools and to copy the created .h files to an other directory of the project (So the submodule will not be affected). Furthermore, you may have to build these files for several platforms or architectures. After that you can add a new folder to your includes. A pretty nice solution for that is available here:

    Github DEMO