The journey appears as a really painful challenge for my disk storage as well as network condition. It has downloaded around 30 GiB contents from the Internet, and occupied 55 GiB of storage space on the disk after the binary file was fully compiled. I will suggest anyone to go through this journey should place his workspace on an SSD, and adopt a network proxy of good quality if in China.
Albeit it occupies a bunch of resources greedily, the Electron team provides a command line tool
e (Electron build-tools) to hopefully simplify the building process. The guidance leading to this tool, however, is not obvious enough on the doc page. I’ve wasted two or three hours following the instructions in the doc that explicitly invokes
ninja, which yet resulted in a bunch of errors and a hell of mess. So here’s the first advice – DO NOT follow any instructions after section “GN files” in this page. Just go ahead to use Electron build-tools!
Things become easier once you’ve learned the existence of Electron build-tools. To install the tool you only have to type one command
$ npm i -g @electron/build-tools
This package manages for you all the necessary stuffs to build Electron, including Depot Tools for source code management and Rust/clang toolchains for building, which are exposed as a single command
e. To fetch the source code and build Electron in one go, you need to run
$ # you'd better add this to .bashrc
$ export GIT_CACHE_PATH="/path/to/git-cache"
$ mkdir -p $GIT_CACHE_PATH
$ # tell depot_tools not to update itself
$ export DEPOT_TOOLS_UPDATE=0
$ # setup network proxy if necessary
$ export http_proxy=... https_proxy=...
$ # go to your workspace
$ mkdir -p $WORKSPACE && cd $WORKSPACE
$ # fetch and build Electron!
$ e init --root=$PWD --bootstrap testing --fork hsfzxjy/electron --goma none
Some notes on these command:
depot_toolsrespect the environment variable
GIT_CACHE_PATHto cache up git database for all fetched dependencies. The variable is highly recommended to set as it could significantly speed up file synchronization next time.
depot_toolswill automatically check updates for itself and I don’t like it. Disable this behavior via
https_proxyfor network proxy, but
proxychainsmight fail wierdly.
- The flag
--goma noneis necessary if you build Electron on your personal computer without using distributed building facility like Goma. Otherwise the building process will emit errors in the middle.
License: CC BY-NC-ND 4.0.
All rights reserved by the author.
Commercial use of this post in any form is NOT permitted.
Non-commercial use of this post should be attributed with this block of text.