2015-08-31 05:31:43 +00:00
|
|
|
# Source Code Directory Structure
|
2013-09-09 07:35:57 +00:00
|
|
|
|
2015-08-31 05:31:43 +00:00
|
|
|
The source code of Electron is separated into a few parts, mostly
|
2013-08-29 14:37:51 +00:00
|
|
|
following Chromium on the separation conventions.
|
2013-08-14 22:43:35 +00:00
|
|
|
|
2013-08-29 14:37:51 +00:00
|
|
|
You may need to become familiar with [Chromium's multi-process
|
2018-01-12 15:24:48 +00:00
|
|
|
architecture](https://dev.chromium.org/developers/design-documents/multi-process-architecture)
|
2013-08-29 14:37:51 +00:00
|
|
|
to understand the source code better.
|
2013-08-14 22:43:35 +00:00
|
|
|
|
2015-08-31 05:31:43 +00:00
|
|
|
## Structure of Source Code
|
2013-08-14 22:43:35 +00:00
|
|
|
|
2018-02-09 19:21:50 +00:00
|
|
|
```diff
|
2015-09-01 04:49:05 +00:00
|
|
|
Electron
|
2016-05-27 22:22:47 +00:00
|
|
|
├── atom/ - C++ source code.
|
|
|
|
| ├── app/ - System entry code.
|
|
|
|
| ├── browser/ - The frontend including the main window, UI, and all of the
|
2018-06-27 07:46:14 +00:00
|
|
|
| | | main process things. This talks to the renderer to manage web
|
|
|
|
| | | pages.
|
2016-05-27 22:22:47 +00:00
|
|
|
| | ├── ui/ - Implementation of UI stuff for different platforms.
|
|
|
|
| | | ├── cocoa/ - Cocoa specific source code.
|
|
|
|
| | | ├── win/ - Windows GUI specific source code.
|
|
|
|
| | | └── x/ - X11 specific source code.
|
|
|
|
| | ├── api/ - The implementation of the main process APIs.
|
|
|
|
| | ├── net/ - Network related code.
|
|
|
|
| | ├── mac/ - Mac specific Objective-C source code.
|
|
|
|
| | └── resources/ - Icons, platform-dependent files, etc.
|
|
|
|
| ├── renderer/ - Code that runs in renderer process.
|
|
|
|
| | └── api/ - The implementation of renderer process APIs.
|
|
|
|
| └── common/ - Code that used by both the main and renderer processes,
|
2018-06-27 07:46:14 +00:00
|
|
|
| | including some utility functions and code to integrate node's
|
|
|
|
| | message loop into Chromium's message loop.
|
2016-05-27 22:22:47 +00:00
|
|
|
| └── api/ - The implementation of common APIs, and foundations of
|
2018-06-27 07:46:14 +00:00
|
|
|
| Electron's built-in modules.
|
2017-11-21 18:55:56 +00:00
|
|
|
├── chromium_src/ - Source code copied from Chromium. See below.
|
2016-05-27 22:22:47 +00:00
|
|
|
├── default_app/ - The default page to show when Electron is started without
|
2018-06-27 07:46:14 +00:00
|
|
|
| providing an app.
|
2016-05-27 22:22:47 +00:00
|
|
|
├── docs/ - Documentations.
|
|
|
|
├── lib/ - JavaScript source code.
|
|
|
|
| ├── browser/ - Javascript main process initialization code.
|
|
|
|
| | └── api/ - Javascript API implementation.
|
|
|
|
| ├── common/ - JavaScript used by both the main and renderer processes
|
|
|
|
| | └── api/ - Javascript API implementation.
|
|
|
|
| └── renderer/ - Javascript renderer process initialization code.
|
|
|
|
| └── api/ - Javascript API implementation.
|
2018-06-27 07:46:14 +00:00
|
|
|
├── native_mate/ - A fork of Chromium's gin library that makes it easier to marshal
|
|
|
|
| types between C++ and JavaScript.
|
2016-05-27 22:22:47 +00:00
|
|
|
├── spec/ - Automatic tests.
|
2018-09-09 01:15:32 +00:00
|
|
|
└── BUILD.gn - Building rules of Electron.
|
2015-09-01 04:49:05 +00:00
|
|
|
```
|
2013-08-14 22:43:35 +00:00
|
|
|
|
2017-11-21 18:55:56 +00:00
|
|
|
## `/chromium_src`
|
|
|
|
|
2018-02-09 19:21:50 +00:00
|
|
|
The files in `/chromium_src` tend to be pieces of Chromium that aren't part of
|
|
|
|
the content layer. For example to implement Pepper API, we need some wiring
|
|
|
|
similar to what official Chrome does. We could have built the relevant
|
|
|
|
sources as a part of [libcc](../glossary.md#libchromiumcontent) but most
|
|
|
|
often we don't require all the features (some tend to be proprietary,
|
2018-05-08 05:16:09 +00:00
|
|
|
analytics stuff) so we took parts of the code. These could have easily
|
2018-02-09 19:21:50 +00:00
|
|
|
been patches in libcc, but at the time when these were written the goal of
|
|
|
|
libcc was to maintain very minimal patches and chromium_src changes tend to be
|
|
|
|
big ones. Also, note that these patches can never be upstreamed unlike other
|
2017-11-21 18:55:56 +00:00
|
|
|
libcc patches we maintain now.
|
|
|
|
|
2015-08-31 05:31:43 +00:00
|
|
|
## Structure of Other Directories
|
2013-08-14 22:43:35 +00:00
|
|
|
|
2014-05-04 12:15:20 +00:00
|
|
|
* **script** - Scripts used for development purpose like building, packaging,
|
|
|
|
testing, etc.
|
2018-09-09 01:15:32 +00:00
|
|
|
* **tools** - Helper scripts used by GN files, unlike `script`, scripts put
|
2014-05-04 12:15:20 +00:00
|
|
|
here should never be invoked by users directly.
|
|
|
|
* **vendor** - Source code of third party dependencies, we didn't use
|
2015-08-31 05:31:43 +00:00
|
|
|
`third_party` as name because it would confuse it with the same directory in
|
2014-05-04 12:15:20 +00:00
|
|
|
Chromium's source code tree.
|
|
|
|
* **node_modules** - Third party node modules used for building.
|
|
|
|
* **out** - Temporary output directory of `ninja`.
|
2013-08-29 14:37:51 +00:00
|
|
|
* **dist** - Temporary directory created by `script/create-dist.py` script
|
2016-02-01 09:10:36 +00:00
|
|
|
when creating a distribution.
|
2014-05-21 14:41:46 +00:00
|
|
|
* **external_binaries** - Downloaded binaries of third-party frameworks which
|
2018-09-09 01:15:32 +00:00
|
|
|
do not support building with `gn`.
|
2016-04-19 03:23:11 +00:00
|
|
|
|
|
|
|
## Keeping Git Submodules Up to Date
|
|
|
|
|
|
|
|
The Electron repository has a few vendored dependencies, found in the
|
2016-05-06 20:25:01 +00:00
|
|
|
[/vendor][vendor] directory. Occasionally you might see a message like this
|
2016-04-19 03:23:11 +00:00
|
|
|
when running `git status`:
|
|
|
|
|
|
|
|
```sh
|
|
|
|
$ git status
|
|
|
|
|
2018-09-09 01:15:32 +00:00
|
|
|
modified: vendor/depot_tools (new commits)
|
|
|
|
modified: vendor/boto (new commits)
|
2016-04-19 03:23:11 +00:00
|
|
|
```
|
|
|
|
|
|
|
|
To update these vendored dependencies, run the following command:
|
|
|
|
|
|
|
|
```sh
|
|
|
|
git submodule update --init --recursive
|
|
|
|
```
|
|
|
|
|
|
|
|
If you find yourself running this command often, you can create an alias for it
|
|
|
|
in your `~/.gitconfig` file:
|
|
|
|
|
2017-11-20 06:18:24 +00:00
|
|
|
```sh
|
2016-04-19 03:23:11 +00:00
|
|
|
[alias]
|
2016-04-19 16:46:48 +00:00
|
|
|
su = submodule update --init --recursive
|
2016-04-19 03:23:11 +00:00
|
|
|
```
|
2016-05-06 20:25:01 +00:00
|
|
|
|
|
|
|
[vendor]: https://github.com/electron/electron/tree/master/vendor
|