I'm trying to build a NodeJS addon from mixed C/C++ source. I want to avoid building the C code as separate shared library, though this is a partial solution.
I get the error:
Cannot guess how to process src:///home/chris/Dropbox/cbackend/data.c
(got mappings ['.C', '.cc', '.cpp', '.c++', '.cxx']
in <class 'cxx.cxx_taskgen'>) -> try conf.check_tool(..)?
when I try to build it. If I rename the .c file as .cc and change the wscript appropriately it all work fine.
I've tried adding a 'compiler_c' to the wscript, but it doesn't seem to be available.
Here's the wscript:
import os
import Options
srcdir = '.'
blddir = 'build'
VERSION = '0.3.0'
def set_options(opt):
opt.tool_options('compiler_cxx')
def configure(conf):
conf.check_tool('compiler_cxx')
conf.check_tool('node_addon')
conf.env.append_value('CCFLAGS', ['-O3'])
conf.env.append_value('CXXFLAGS', ['-O3'])
if Options.platform == 'darwin': conf.env.append_value('LINKFLAGS', ['-undefined', 'dynamic_lookup'])
def build(bld):
obj = bld.new_task_gen('cxx', 'shlib', 'node_addon')
obj.target = 'cbackend'
obj.source = 'cbackend.cc data.c'
obj.uselib = ['NODE']
I was given the solution on a mailing list.
The plain C compiler is called 'compiler_cc' in NodeJS, not 'compiler_c' as in the WAF docs.