This process appears to be really painful challenge for my disk storage as well as network condition. To sum up, it downloads around 30 GiB contents from the Internet, and occupies 55 GiB storage space on the disk after the binary file 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 the greedy occupation of resources, the Electron team provides a command line tool
e (Electron build-tools), which eases the building process to a large extent. 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
mkdir -p $GIT_CACHE_PATH
# tell depot_tools not to update itself
# 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.