Is there wildcard mechanism for listing sources in node-gyp

Figured it out

{
  'targets' : [
      {
          'target_name' : 'mymod',
          'sources' : [ '<!@(ls -1 src/*.cpp)' ],
      }
   ]
}

Check out this link

Update

The solution above is not portable across platforms. Here's a portable version:

{
  'targets' : [
      {
          'target_name' : 'mymod',
          'sources' : [  "<!@(node -p \"require('fs').readdirSync('./src').map(f=>'src/'+f).join(' ')\")" ],
      }
   ]
}

Essentially it replaces the platform specific directory listing command (ls), by Javascript code that uses node's fs module to list the directory contents.

Tags:

Node Gyp