编译文档:
构建说明 | Electron
1 下载depot_tools
(1)安装depot_tools用于获取 Chromium 及其依赖项的工具集:地址
WINDOWS
Download the depot_tools bundle and extract it somewhere.
(2)在 Windows 上,您需要设置环境变量 DEPOT_TOOLS_WIN_TOOLCHAIN=0
。为此,打开Control Panel
→ System and Security
→ System
→Advanced system settings
并添加一个 DEPOT_TOOLS_WIN_TOOLCHAIN
值为 的系统变量0
。这告诉depot_tools
您使用本地安装的 Visual Studio 版本(默认情况下,depot_tools
将尝试下载只有 Google 员工才能访问的 Google 内部版本)
(2)depot_tools添加到系统环节变量path
2 下载代码
$ mkdir electron && cd electron
$ gclient config --name "src/electron" --unmanaged https://github.com/electron/electron
$ gclient sync --with_branch_heads --with_tags
# This will take a while, go get a coffee.
慢慢等......
git - error: RPC failed; curl 92 HTTP/2 stream 0 was not closed cleanly: PROTOCOL_ERROR (err 1) - Stack Overflow
git config --global http.version HTTP/1.1
git config --global http.postBuffer 524288000git config --global http.maxRequestBuffer 524288000git config --global core.compression 0
还报错的话:
clone时出现RPC failed; curl 56 OpenSSL SSL_read: SSL_ERROR_SYSCALL, errfno 10054
,输入命令行输入输入以下3个命令:
git initgit config http.postBuffer 524288000git config http.sslVerify "false"
如果报错:Hook 'python3 -c 'import os, subprocess; os.chdir(os.path.join("src", "electron")); subprocess.check_call(["python3", "script/lib/npx.py", "yarn@1.15.2", "install", "--frozen-lockfile"])
我重启了一下电脑就好了
3 编译
构建
设置chromium build tools的环境变量
在命令行中输入
cd srcset CHROMIUM_BUILDTOOLS_PATH=%cd%\buildtools
生成 Electron 的 Release build 配置
gn gen out/Release --args="import(\"//electron/build/args/release.gn\")"
编译
ninja -C out/Release electron