c++ - 绑定(bind).gyp : How to use "copies" section to copy files in multiple location

标签 c++ electron node-gyp

我正在编写代码从 Electron 加载 C++ DLL。我正在使用node-gyp。在我的 binding.gyp 文件中,我使用“copies”标签将 dll 复制到 Release 文件夹。但是我想复制更多文件以复制到不同的位置。我尝试了点击和尝试的方法来做到这一点,但没有成功。这是我的 binding.gyp 的外观:

{
    "targets": [{
            "conditions":[
            ["OS=='win'", {
                "copies":[{ 
                        'destination': './build/Release',
                        'files':[
                            '../../cl-fc-client-thirdparty/bugtrap/BugTrapU-x64.dll',
                            '../build/bin/msvc/Release64/cloudDrive2Lib.dll',
                            '../../cl-fc-client-thirdparty/openssl/1.0.2j/lib/x86_64-win32/ssleay32MD.dll',
                            '../../cl-fc-client-thirdparty/poco/1.7.5/bin64/PocoZip64.dll',
                             '../../cl-fc-client-thirdparty/poco/1.7.5/bin64/PocoXML64.dll',
                            '../../cl-fc-client-thirdparty/poco/1.7.5/bin64/PocoUtil64.dll',
                            '../../cl-fc-client-thirdparty/poco/1.7.5/bin64/PocoNetSSL64.dll',
                            '../../cl-fc-client-thirdparty/poco/1.7.5/bin64/PocoNet64.dll',
                            '../../cl-fc-client-thirdparty/poco/1.7.5/bin64/PocoJSON64.dll',
                            '../../cl-fc-client-thirdparty/poco/1.7.5/bin64/PocoFoundation64.dll',
                            '../../cl-fc-client-thirdparty/poco/1.7.5/bin64/PocoCrypto64.dll',
                            '../../cl-fc-client-thirdparty/openssl/1.0.2j/lib/x86_64-win32/libeay32MD.dll'
                        ]
                    }]
            }]
        ],
        "target_name": "electronToCppBridge",
        "cflags!": [ "-fno-exceptions" ],
        "cflags_cc!": [ "-fno-exceptions" ],
        "sources": [
            "src/electronToCppBridge.cc",
        ],
        'include_dirs': [
            "<!@(node -p \"require('node-addon-api').include\")"
        ],
        'libraries': ["../libs/cloudDrive2Lib.lib"],
        'dependencies': [
            "<!(node -p \"require('node-addon-api').gyp\")"
        ],
        'defines': [ 'NAPI_DISABLE_CPP_EXCEPTIONS' ]
    }]
}

最佳答案

没关系,我可以通过以下方式实现这一目标:

{
    "targets": [{
            "conditions":[
            ["OS=='win'", {
                "copies":[
                    { 
                        'destination': './build/Release',
                        'files':[
                            '../../cl-fc-client-thirdparty/bugtrap/BugTrapU-x64.dll',
                            '../build/bin/msvc/Release64/cloudDrive2Lib.dll',
                            '../../cl-fc-client-thirdparty/openssl/1.0.2j/lib/x86_64-win32/ssleay32MD.dll',
                            '../../cl-fc-client-thirdparty/poco/1.7.5/bin64/PocoZip64.dll',
                             '../../cl-fc-client-thirdparty/poco/1.7.5/bin64/PocoXML64.dll',
                            '../../cl-fc-client-thirdparty/poco/1.7.5/bin64/PocoUtil64.dll',
                            '../../cl-fc-client-thirdparty/poco/1.7.5/bin64/PocoNetSSL64.dll',
                            '../../cl-fc-client-thirdparty/poco/1.7.5/bin64/PocoNet64.dll',
                            '../../cl-fc-client-thirdparty/poco/1.7.5/bin64/PocoJSON64.dll',
                            '../../cl-fc-client-thirdparty/poco/1.7.5/bin64/PocoFoundation64.dll',
                            '../../cl-fc-client-thirdparty/poco/1.7.5/bin64/PocoCrypto64.dll',
                            '../../cl-fc-client-thirdparty/openssl/1.0.2j/lib/x86_64-win32/libeay32MD.dll'
                        ]
                    },
                    {                        
                        'destination': './libs',
                        'files':['../build/bin/msvc/Release64/cloudDrive2Lib.lib']
                    }
                ]
            }]
        ],
        "target_name": "electronToCppBridge",
        "cflags!": [ "-fno-exceptions" ],
        "cflags_cc!": [ "-fno-exceptions" ],
        "sources": [
            "src/electronToCppBridge.cc",
        ],
        'include_dirs': [
            "<!@(node -p \"require('node-addon-api').include\")"
        ],
        'libraries': ["../libs/cloudDrive2Lib.lib"],
        'dependencies': [
            "<!(node -p \"require('node-addon-api').gyp\")"
        ],
        'defines': [ 'NAPI_DISABLE_CPP_EXCEPTIONS' ]
    }]
}

关于c++ - 绑定(bind).gyp : How to use "copies" section to copy files in multiple location,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/56966497/

相关文章:

javascript - 无法 "npm install @tensorflow/tfjs-node"

c++ - C++库应如何允许自定义分配器?

electron - 从子目录执行main.js

Electron 在没有任何信息的情况下死亡,现在怎么办?

node.js - 安装 nodeBB 时出现 node-gyp 重建状态 1 问题

c++ - 使用 node-nan 在 node.js 模块中设置 WindowsHookEx

c++ - 如何使用相同的调用签名在张量中索引和分配元素?

c++ - 多个 .cpp 文件中包含的头文件

C++ 禁止指针到指针的转换

node.js - Spectron:如何测试Electron `shell.openExternal('一些url')`