Run configure in gyp file

Suppose I have a node module that is essentially a wrapper around some standard C library using autotools. Therefore the library itself will be installed using ./configure

and make

and possibly make install

. The shell code is just a few files and can be handled by gyp. But how can I deal with addiction? How can I tell gyp that I want to build an autostart library before I compile my code? Or is it not possible because autotools cannot be run on Windows? If I can't get it running configure

, is there a gyp way to do this sort of thing, specifically to determine which features are available and which are not?

+3


source to share


2 answers


With gyp actions and 'target_type': none

it might look like this:

   {
        'target_name': 'FTGL',
        'type': 'none',
        'dependencies': ['FreeType'],
        'actions': [
            {
                'action_name': 'build_ftgl',
                'message': 'Building FTGL...',
                'inputs': ['ftgl/src/FTGL/ftgl.h'],
                'outputs': ['ftgl/src/.libs/libftgl.a'],
                'action': [''eval', 'cd ftgl && ./configure --with-pic && make -C src''],
            },
        ],
  }

      



Note eval

, using in action, it allows you to run multiple commands.

+4


source


You can execute arbitrary commands in gyp using the command line extension . However, as you noted, this is not reliable if you want to be cross-platform.

Usually, if you want it to be cross platform, you will need the "gyp-ify" of your dependency. This means creating a separate gyp file that is included as a dependency gyp function in your main binding.gyp

. This may take a while because you must list all the source files to be compiled, and you must also add any compilation flags required for the library (for example, if the library uses compile time, for example -Dfoo

).



You might also consider creating a dynamic dependency instead of linking the source for the library you are wrapping and just linking back to the library dynamically. This is much easier since you don't need the "gyp-ify" libraries and you just need to add a few things like libraries: ['-lfoo']

yours binding.gyp

.

+2


source







All Articles