VPN非常注意:
編譯的過程需要使用VPN, 否者chromium的源代碼無法下載, 后面會出現總總問題
Electron的編譯環境, 推薦使用物理機:
win10 64位 英文版, 為了避免后期出現編譯文件, 推薦使用64為的win10
node-v6.11.0-x64, node版本最好在6.x, 高版本的可能編譯不成功
python-2.7.10.amd64, python要求版本2.7.10 , 版本不要太高
Git, 使用最新版本即可
vs 2017 community,vs2017 V15.6.7是在線安裝, 沒法用離線安裝包安裝, 安裝VS的時候要注意把有關c++的安裝選項的都選上(visual studio 2017 16.7系列, vs的bug, 否則編譯webrtc的時候會報錯, 參考:installing-an-earlier-release-of-vs2017)
下載electron源碼
打開gitbash,或者bash for window ,執行以下代碼(請勿使用cmd執行命令, 會出各種問題)
下載electron源碼:
$ git clone https://github.com/electron/electron.git
清理構建文件:
npm run clean

清理 out 和 dist 目錄:
npm run clean-build
更新electron源碼,並下載libchromium源碼
注意默認情況下不會以 shared_library 方式編譯, 所以你如果使用"--build_release_libcc"參數的話, 只能編譯 Electron的 Release 版本, 網速10M的話, 這一步需要半天到一天的時間, 要非常久:
./script/bootstrap.py -v --build_release_libcc
修改源碼的isTrusted, 默認為true

編譯electron的Release版本
./script/build.py -c R

編譯后的文件會出現在 electron\dist\R 目錄下,而且編譯出來的文件夾大小有1.3G,非常大
最后再用create-dist.py 打包發行版的electron:
./script/create-dist.py --chromium_dir D:\\compile\\electron\\vendor\\libchromiumcontent\\dist\\main\\static_library

參考:
installing-an-earlier-release-of-vs2017
electron libchromiumcontent issue
How do I link a custom compiled libchromiumcontent with Electron?
how-to-submit-a-chromium-patch-to-libchromiumcontent.html
-how-do-you-make-a-patch-to-libchromium-content
https://bugzilla.mozilla.org/show_bug.cgi?id=1458247
作者: NONO
出處:http://www.cnblogs.com/diligenceday/
企業網站:http://www.idrwl.com/
開源博客:http://www.github.com/sqqihao
QQ:287101329
微信:18101055830

