May 25, 2021 Electron
Electron
uses
gyp to
build the project and
ninja to
build the project.
The project
configuration can
be found in the
.gyp
.gypi
files.
The
gyp
contains the main rules for building Electron:
atom.gyp
defines how Electron itself is built.
common.gypi
node's build configuration to make it build with Chromium.
vendor/brightray/brightray.gyp
brightray
is built and includes a default configuration to connect to Chromium.
vendor/brightray/brightray.gypi
commonly used creation configurations.
The final link phase takes several minutes when Chromium is still a fairly large project, which makes development difficult. To solve this difficulty, Chromium introduced "component build", which allows each creation to be separated from the shared library and makes the links faster, but this wastes file size and performance.
In Electron, we take a very
similar approach: when
Debug
the binary is linked to a shared repository of chromium components to get a quick link;
In
Release
, the binary will be linked into a static repository, so we can have the smallest binary size and the best experience.
All Chromium precompiled binary files will be downloaded while the bootstrap script is running. The default static and shared libraries are downloaded and the final size of the project is between 800MB and 2GB, depending on the platform type.
By default,
libchromiumcontent
is downloaded from Amazon Web Services. I
f you
set
LIBCHROMIUMCONTENT_MIRROR
variable, the bootstrap script will be downloaded from here.
libchromiumcontent-qiniu-mirror
is
libchromiumcontent
libchromiumcontent.
If you can't connect to AWS, you can switch the download path:
export LIBCHROMIUMCONTENT_MIRROR=http://7xk3d2.dl1.z0.glb.clouddn.com/
you just want to quickly build an Electron test or development
--dev
parameter:
$ ./script/bootstrap.py --dev
$ ./script/build.py -c D
After
Release
and
Debug
Electron linked
gyp
libraries with different configurations .
To circumvent this
problem,
gyp
using
gyp
libchromiumcontent_component
control which link setting should be used and generate only one target.
Unlike most projects,
they
use
Release
and
Debug
as the
target
names, while Electron uses
R
and
D
This is because if only
Release
or
Debug
build configuration is defined,
gyp
randomly and at the same time,
Electron generates only one target, as described above.
This is only available to developers and will not succeed if you want to rebuild Electron.