1,安裝"Debugging Tools for Windows“
Control Panel → Programs → Programs and Features → Select the “Windows Software Development Kit” → Change → Change → Check “Debugging Tools For Windows” → Change. Or, you can download the standalone SDK installer and use it to install the Debugging Tools.
2,gn gen out\Default
gn gen --ide=vs --filters=//chrome;//third_party/WebKit/*;//gpu/*
. --no-deps out\Default
輸入參數:(gn args out/Default
) or on the gn gen command line (gn gen out/Default --args="is_component_build = true is_debug = true"
)
報錯
ERROR at //cef/BUILD.gn:140:1: Assertion failed.
assert(!enable_print_preview)
可以鍵入命令輸入編譯參數: gn args out/Default 在彈出的編輯notepad里面加入一行:
enable_print_preview = false
enable_widevine = true
clang_use_chrome_plugins = false
這個文件保存在 out/Default/args.gn
加速:
is_component_build = true
- this uses more, smaller DLLs, and incremental linking.enable_nacl = false
- this disables Native Client which is usually not needed for local builds.target_cpu = "x86"
- x86 builds are slightly faster than x64 builds and support incremental linking for more targets. Note that if you set this but don‘t’ set enable_nacl = false then build times may get worse.blink_symbol_level = 0
- turn off source-level debugging for blink to reduce build times, appropriate if you don't plan to debug blink.-
# Build arguments go here. # See "gn args <out_dir> --list" for available build arguments. enable_print_preview = false enable_widevine = true clang_use_chrome_plugins = false is_component_build = true enable_nacl = false target_cpu = "x86"
- ../../base/win/windows_version.cc(26,2): error: Creators Update SDK (10.0.15063.468) required.
-
安裝windows sdk
-
這個原因是因為新版的win10 sdk改變了目錄結構,使得編譯軟件無法找到必要的處理程序。解決辦法如下:
- 進入C:\Program Files (x86)\Windows Kits\10\bin,將arm、armx64、x64、x86文件夾備份並刪除,
- 將10.0.15063.0文件夾中的arm、armx64、x64、x86文件夾拖出。
- 再次運行ninja -C out.gn/x64.release
- https://developer.microsoft.com/zh-cn/windows/downloads/ windows sdk下載。
-
//chrome_elf/BUILD.gn:10:1: Can't load input file. import("//cef/libcef/features/features.gni") src/build.gn remove //cef
chrome_elf 移除 cef有關
-
electron windows 構建
構建步驟 (Windows)
遵循下面的步驟, 在 Windows 平台上構建 Electron。
基本要求
- Windows 10 / Server 2012 R2 或更高版本
- Visual Studio 2017 15.7.2 或更高版本 - 免費下載 VS 2019 社區版
- 請參閱Chromium構建文檔,以了解有哪些Visual Studio 組件需要安裝等詳細信息。
- 如果您的 Visual Studio 安裝在非默認目錄中, 您需要 設置幾個環境變量來將工具鏈指向您的安裝路徑。
vs2019_install = DRIVE:\path\to\Microsoft Visual Studio\2019\Community
, replacing2019
andCommunity
with your installed versions and replacingDRIVE:
with the drive that Visual Studio is on. Often, this will beC:
.WINDOWSSDKDIR = DRIVE:\path\to\Windows Kits\10
, replacingDRIVE:
with the drive that Windows Kits is on. Often, this will beC:
.
- Python 2.7.10 或更高版本
- 與下面
depot_tools
的安裝說明不同,你必須安裝 2.7.10 以上版本的 Python(支持 TLS 1.2)。 為此,應確保 PATH 中 Python 的安裝目錄在depot_tools
之前。 目前depot_tools
仍捆綁 Python 2.7.6,這將導致gclient
命令失效(見 crbug.com/868864)。 - Python for Windows (pywin32) 擴展對於構建流程也是必需的。
-
pip是自帶的。安裝whl文件方法如下:
pip install wheel。 pip install pywin32-227-cp27-cp27m-win_amd64.whl
- 與下面
- Node.js
- Git
- Debugging Tools for Windows of Windows SDK 10.0.15063.468 if you plan on creating a full distribution since
symstore.exe
is used for creating a symbol store from.pdb
files.- 不同版本的SDK可以同時安裝 安裝 SDK,打開 Visual Studio 安裝程序,選擇
更改
→單個組件
,向下滾動並選擇適當的 要安裝的 Windows SDK 組件。 另一個選擇是查看 windows SDK 和仿真器存檔 並分別下載 SDK 的獨立版本。 - 還必須安裝 SDK 調試工具。 如果已安裝了 Windows 10 SDK 通過 Visual Studio 安裝程序,然后可以用以下方式安裝它們:
控制面板
→程序
→程序和功能
→選擇“Windows 軟件開發工具包”→更改
→更改
→選中“Windows 調試工具”→更改
。 或者,您可以下載獨立的 SDK 安裝程序,並且使用它安裝調試工具。
- 不同版本的SDK可以同時安裝 安裝 SDK,打開 Visual Studio 安裝程序,選擇
如果您當前沒有安裝 Windows, dev.microsoftedge.com 上有時間限制的 Windows 版本,你可以用來構建 Electron。
構建 Electron 完全由命令行腳本完成,無法通過 Visual Studio 完成。 您可以使用任何編輯器開發 Electron,但將來將會使用 Visual Studio 構建支持。
Note: Even though Visual Studio is not used for building, it's still required because we need the build toolchains it provides.
32 位構建
為了構建 32bit 版本,您需要通過 target_cpu = “x86"
作為 GN 參數。 可以使用不同的 GN 輸出目錄(例如, out/Release-x86
) 和不同的參數,在 64 位目標旁邊構建 32 位目標。
$ gn gen out/Release-x86 --args="import(\"//electron/build/args/release.gn\") target_cpu=\"x86\""
其他構建步驟完全一樣。
Visual Studio 項目
要生成 Visual Studio 項目,可以傳遞 --ide=vs2017
參數 給 gn gen
:
$ gn gen out/Testing --ide=vs2017
Command xxxx not found
如果你遇到了一個錯誤,類似 Command xxxx not found
, 可以嘗試使用 VS2015 Command Prompt
控制台來執行構建腳本.
Fatal internal compiler error: C1001
確保你已經安裝了 Visual Studio 的最新安裝包.
LNK1181: cannot open input file 'kernel32.lib'
重新安裝 32位的 Node.js.
Error: ENOENT, stat 'C:\Users\USERNAME\AppData\Roaming\npm'
創建那個目錄 應該可以解決問題:
$ mkdir ~\AppData\Roaming\npm
node-gyp is not recognized as an internal or external command
如果你使用 Git Bash 來構建,或許會遇到這個錯誤,可以使用 PowerShell 或 VS2015 Command Prompt 來代替.
無法在“…”處創建目錄:文件名太長
node.js 有一些 極長的路徑名,默認情況下,windows 上的 git 不能正確處理長路徑名(即使 windows 支持它們)。 這應該可以修復它:
$ git config --system core.longpaths true
錯誤:使用未聲明的標識符“DefaultDelegateCheckMode”
This can happen during build, when Debugging Tools for Windows has been installed with Windows Driver Kit. Uninstall Windows Driver Kit and install Debugging Tools with steps described above.
導入錯誤:沒有名為 win32file 的模塊
確保已使用 pip install pywin32
安裝了 pywin32
。
構建腳本掛起, 直到某個按鍵按下才有響應
這個bug 是 Windows 命令提示符的一個"功能" It happens when clicking inside the prompt window with QuickEdit
enabled and is intended to allow selecting and copying output text easily. 由於每次意外點擊都會暫停構建過程,您可能需要在命令的屬性中禁用此 功能。