node.jsnode-modulescompiler-warningsnode-addon-api

How do you avoid full compilation with gyp?


I'm getting started with the `node-addon-api' and while my code does compile and run, I do get the following warning:

Generating code
  Previous IPDB not found, fall back to full compilation.
  All 303 functions were compiled because no usable IPDB/IOBJ from previous compilation was found.
  Finished generating code

Indeed, everything gets recompiled when I run the command (node-gyp rebuild -j max) and it is kind of slow, so avoiding a recompilation of all the files would be welcome, especially when the project becomes bigger.

All I could find was this page, but adding that flag didn't do anything (either under cflags, cflags_cc or msvs_settings). Here is my binding.gyp:

{
    "targets": [{
        "target_name": "template",
        "cflags!": [ "-fno-exceptions" ],
        "cflags_cc!": [ "-fno-exceptions" ],
        "sources": [
            "src/cpp/wrapper.cpp",
            "src/cpp/functionexample.cpp"
        ],
        'include_dirs': [
            "<!@(node -p \"require('node-addon-api').include\")"
        ],
        'libraries': [],
        'dependencies': [
            "<!(node -p \"require('node-addon-api').gyp\")"
        ],
        'defines': [ 'NAPI_DISABLE_CPP_EXCEPTIONS' ],
        'msvs_settings': {
            'VCCLCompilerTool': { "ExceptionHandling": 1, 'AdditionalOptions': [ '-std:c++20' ] }
        }
    }]
}

Thank you in advance!


Solution

  • rebuild is supposed to recompile everything from scratch - you are looking for build

    rebuild runs clean, configure, and build:

    build compares the old build with the your source code, finds the changes, and rebuilds only the changed code - that being said build is not always perfect so an occasional rebuild maybe needed

    source node-gyp readme