【问题标题】:How do you avoid full compilation with gyp?如何避免使用 gyp 进行完整编译?
【发布时间】:2022-10-01 11:09:50
【问题描述】:

我开始使用“node-addon-api”,当我的代码编译并运行时,我确实收到了以下警告:

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

事实上,当我运行命令 (node-gyp rebuild -j max) 时,所有内容都会重新编译,而且速度有点慢,因此欢迎避免重新编译所有文件,尤其是当项目变得更大时。

我只能找到this page,但添加该标志并没有做任何事情(在cflagscflags_ccmsvs_settings 下)。这是我的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\' ] }
        }
    }]
}

先感谢您!

    标签: node.js node-modules compiler-warnings node-addon-api


    【解决方案1】:

    rebuild 应该从头开始重新编译所有内容 - 您正在寻找 build

    rebuild 运行 cleanconfigurebuild

    • clean 删除构建目录(如果存在)<-清除以前编译的对象
    • configure 为当前平台生成项目构建文件
    • build 调用 make/msbuild.exe 并构建本机插件

    build 将旧版本与您的源代码进行比较,找到更改并仅重建更改的代码 - 据说build 并不总是完美的,所以偶尔可能需要rebuild

    source node-gyp readme

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2014-11-01
      • 2019-09-07
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2019-11-02
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多