Перейти к основному содержанию

Using GN to Build Electron

· 2 мин. прочитано

Electron now uses GN to build itself. Here's a discussion of why.


GYP and GN

Когда Electron был впервые выпущен в 2013 году, конфигурация сборки Chromium была написана GYP, короче "Генерировать ваши проекты".

В 2014 году Проект Chromium представил новый инструмент конфигурации сборки GN (короче "Generate Ninja") файлы сборки Chrome были перенесены в GN и GYP были удалены из исходного кода.

Electron исторически держал разделение между основными кодами Electron и libchromiumcontent, часть Electron, которая завершает содержимое подмодуля Chromium. Electron has carried on using GYP, while libchromiumcontent -- as a subset of Chromium -- switched to GN when Chromium did.

Like gears that don't quite mesh, there was friction between using the two build systems. Maintaining compatibility was error-prone, from compiler flags and #defines that needed to be meticulously kept in sync between Chromium, Node, V8, and Electron.

To address this, the Electron team has been working on moving everything to GN. Today, the commit to remove the last of the GYP code from Electron was landed in master.

What this means for you

If you're contributing to Electron itself, the process of checking out and building Electron from master or 4.0.0 is very different than it was in 3.0.0 and earlier. See the GN build instructions for details.

If you're developing an app with Electron, there are a few minor changes you might notice in the new Electron 4.0.0-nightly; but more than likely, Electron's change in build system will be totally transparent to you.

What this means for Electron

GN is faster than GYP and its files are more readable and maintainable. Moreover, we hope that using a single build configuration system will reduce the work required to upgrade Electron to new versions of Chromium.

  • It's already helped development on Electron 4.0.0 substantially because Chromium 67 removed support for MSVC and switched to building with Clang on Windows. With the GN build, we inherit all the compiler commands from Chromium directly, so we got the Clang build on Windows for free!

  • It's also made it easier for Electron to use BoringSSL in a unified build across Electron, Chromium, and Node -- something that was problematic before.