【发布时间】:2020-10-05 07:31:20
【问题描述】:
自从升级到 Electron 10.1.2 后,electron-builder 出现问题。我的构建现在在为keyboard-layout 重建时失败。重建仅适用于 Windows,而不适用于 Mac。我不知道在哪里打开这个问题,所以我在这里问:)。
我的设置:
- 角度:9.0.7
- 电子:10.1.2
- 电子生成器:22.8.x
当我将 electron 从 9.0.0 更新到 10.1.2 时,问题就开始了。其他没有任何变化。
问题:
当使用命令electron-builder.cmd --x64 -p always -w 调用electron-builder 时,keyboard-layout 的重建被称为以下步骤之一:
> keyboard-layout@2.0.16 install C:\Users\<me>\<dir1>\<dir2>\dist\node_modules\keyboard-layout
> node-gyp rebuild
失败了:
...
win_delay_load_hook.cc
c:\users\<me>\.electron-gyp\10.1.2\include\node\v8.h(5378): error C2220: warning treated as error - no 'object' file generated (compiling source file ..\src\keyboard-layout-manager-windows.cc) [C:\Users\<me>\<dir1>\<dir2>\dist\node_modules\keyboard-layout\build\keyboard-layout-manager.vcxproj]
c:\users\<me>\.electron-gyp\10.1.2\include\node\v8.h(5378): warning C4309: 'static_cast': truncation of constant value (compiling source file ..\src\keyboard-layout-manager-windows.cc) [C:\Users\<me>\<dir1>\<dir2>\dist\node_modules\keyboard-layout\build\keyboard-layout-manager.vcxproj]
c:\users\<me>\.electron-gyp\10.1.2\include\node\v8.h(5378): error C2220: warning treated as error - no 'object' file generated (compiling source file ..\src\keyboard-layout-manager.cc) [C:\Users\<me>\<dir1>\<dir2>\dist\node_modules\keyboard-layout\build\keyboard-layout-manager.vcxproj]
c:\users\<me>\.electron-gyp\10.1.2\include\node\v8.h(5378): warning C4309: 'static_cast': truncation of constant value (compiling source file ..\src\keyboard-layout-manager.cc) [C:\Users\<me>\<dir1>\<dir2>\dist\node_modules\keyboard-layout\build\keyboard-layout-manager.vcxproj]
Done Building Project "C:\Users\<me>\<dir1>\<dir2>\dist\node_modules\keyboard-layout\build\keyboard-layout-manager.vcxproj" (default targets) -- FAILED.
Done Building Project "C:\Users\<me>\<dir1>\<dir2>\dist\node_modules\keyboard-layout\build\binding.sln" (default targets) -- FAILED.
Build FAILED.
...
我尝试过的没有帮助:
将node_modules/keyboard-layout 中的binding.gyp 更改为(标有<--- 的更改):
['OS=="win"', {
"sources": [
"src/keyboard-layout-manager-windows.cc",
],
'msvs_settings': {
'VCCLCompilerTool': {
'ExceptionHandling': 1, # /EHsc
'WarnAsError': 'false', # <--- I chnaged this from true to false
},
},
'msvs_disabled_warnings': [
4018, # signed/unsigned mismatch
2220, # <--- I added this
4244, # conversion from 'type1' to 'type2', possible loss of data
4267, # conversion from 'size_t' to 'type', possible loss of data
4302, # 'type cast': truncation from 'HKL' to 'UINT'
4311, # 'type cast': pointer truncation from 'HKL' to 'UINT'
4530, # C++ exception handler used, but unwind semantics are not enabled
4506, # no definition for inline function
4577, # 'noexcept' used with no exception handling mode specified
4996, # function was declared deprecated
],
}], # OS=="win"
我尝试过的 DID 帮助:
Electron 10.x.y 将 v8 更新到 8.5 (Electron 10.0.0 release notes) 并查看导致错误的行 (...\.electron-gyp\10.1.2\include\node\v8.h(5378)) 我看到了这个:
static constexpr size_t kMaxLength =
internal::kApiSystemPointerSize == 4
? internal::kSmiMaxValue
: static_cast<size_t>(uint64_t{1} << 32); <--- Line 5378
当我比较来自 ...\.electron-gyp\10.1.2\include\node\v8.h 和 ...\.electron-gyp\9.0.0\include\node\v8.h 的 v8.h 文件时,这一行发生了变化。
旧版本中的同一行:
static constexpr size_t kMaxLength = internal::kApiSystemPointerSize == 4
? internal::kSmiMaxValue
: 0xFFFFFFFF;
如果我将static_cast<size_t>(uint64_t{1} << 32) 更改为0xFFFFFFFF,构建成功。
我的理解到此结束。
- 新旧线路理论上不一样吗?一个移位 32 位的结果是
0xFFFFFFFF? - 我可以做些什么来解决这个问题?这个变化的原因是什么?
- 为什么这个问题只出现在 Windows 上?
【问题讨论】:
标签: electron v8 electron-builder keyboard-layout