Linking against arch specific locations with node-gyp

问题内容:

I’m trying to build a native Node.js module that links against a 3rd party shared library. This library is delivered as part of a bundle that includes pre-built versions for different OSes and Architectures in different directories.

e.g.

/opt/Foo/linux/x86/lib/libfoo.so
/opt/Foo/linux/x86/include/foo.h
/opt/Foo/linux/x86_64/lib/libfoo.so
/opt/Foo/linux/x86_64/include/foo.h
/opt/Foo/linux/arm/lib/libfoo.so
/opt/Foo/linux/arm/include/foo.h
/opt/Foo/mac/x86_64/lib/libfoo.so
/opt/Foo/mac/x86_64/include/foo.h

my binding.gyp currently looks like this:

{
  'targets': [
    {
      'target_name': 'foo',
      'sources': ['foo.cpp', 'foo.h'],
      'include_dirs': ["<!(node -e \"require('nan')\")"],
      'conditions': [
        ['OS=="mac"', {
            'include_dirs': ['/opt/Foo/mac/x86_64/include'],
            'libraries': ['-L/opt/Foo/mac/x86_64/lib', '-lfoo']
          }
        ],
        ['OS=="linux"', {
            'include_dirs': ['/opt/Foo/linux/x86_64/include'],
            'libraries': ['-L/opt/Foo/linux/x86_64/lib', '-lfoo']
          }
        ]
      ]
    }
  ]
}

I don’t seem to be able to find the syntax for conditions to differentiate on the current platform architecture.

问题评论:

原文地址:

https://stackoverflow.com/questions/47755654/linking-against-arch-specific-locations-with-node-gyp

添加评论

友情链接:蝴蝶教程