Last night I started a journey to build Electron completely from the ground up, for investigating a subtle issue in VSCode.
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 gclient or gn or 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
$
$ export GIT_CACHE_PATH="/path/to/git-cache"
$ mkdir -p $GIT_CACHE_PATH
$
$ export DEPOT_TOOLS_UPDATE=0
$
$ export http_proxy=... https_proxy=...
$
$ mkdir -p $WORKSPACE && cd $WORKSPACE
$
$ e init --root=$PWD --bootstrap testing --fork hsfzxjy/electron --goma none
Some notes on these command:
depot_tools respect the environment variable GIT_CACHE_PATH to 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_tools will automatically check updates for itself and I don’t like it. Disable this behavior via DEPOT_TOOLS_UPDATE=0.depot_tools respect the http_proxy and https_proxy for network proxy, but proxychains might fail wierdly.--goma none is 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.Author: hsfzxjy.
Link: .
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.
Last night I started a journey to build Electron completely from the ground up, for investigating a subtle issue in VSCode.
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 gclient or gn or 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
$
$ export GIT_CACHE_PATH="/path/to/git-cache"
$ mkdir -p $GIT_CACHE_PATH
$
$ export DEPOT_TOOLS_UPDATE=0
$
$ export http_proxy=... https_proxy=...
$
$ mkdir -p $WORKSPACE && cd $WORKSPACE
$
$ e init --root=$PWD --bootstrap testing --fork hsfzxjy/electron --goma none
Some notes on these command:
depot_tools respect the environment variable GIT_CACHE_PATH to 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_tools will automatically check updates for itself and I don’t like it. Disable this behavior via DEPOT_TOOLS_UPDATE=0.depot_tools respect the http_proxy and https_proxy for network proxy, but proxychains might fail wierdly.--goma none is 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.Author: hsfzxjy.
Link: .
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.