I'm writing binding.gyp
file for my new node.js module. I have all my source files under src/
subdirectory. I would like to use all of them while building the module. Instead of modifying binding.gyp each time I add a new cpp file, I would like to list all cpp files through some wildcard mechanism. Does node-gyp support that? Something like following (which doesn't work
{
'targets' : [
{
'target_name' : 'mymod',
'sources' : 'src/*.cpp'
}
]
}
I looked at https://code.google.com/p/gyp/wiki/InputFormatReference , but didn't find anything readily useful.
To filter specific file extensions like
cpp
and to support also pre-compiledlibraries
.a
files, I have slightly modified the accepted solution to be:Figured it out
Check out this link
Update
The solution above is not portable across platforms. Here's a portable version:
Essentially it replaces the platform specific directory listing command (
ls
), by Javascript code that uses node'sfs
module to list the directory contents.An even more portable version (that doesn't depend on node, but rather python):
If anyone wants to include all sub files and folders within a certain folder (defined at end of line, here as "sources"):
(based off, but not exactly: node.js fs.readdir recursive directory search)