| 
									
										
										
										
											2015-08-30 22:31:43 -07:00
										 |  |  | # Source Code Directory Structure
 | 
					
						
							| 
									
										
										
										
											2013-09-09 15:35:57 +08:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2015-08-30 22:31:43 -07:00
										 |  |  | The source code of Electron is separated into a few parts, mostly | 
					
						
							| 
									
										
										
										
											2013-08-29 16:37:51 +02:00
										 |  |  | following Chromium on the separation conventions. | 
					
						
							| 
									
										
										
										
											2013-08-14 15:43:35 -07:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2013-08-29 16:37:51 +02:00
										 |  |  | You may need to become familiar with [Chromium's multi-process | 
					
						
							|  |  |  | architecture](http://dev.chromium.org/developers/design-documents/multi-process-architecture) | 
					
						
							|  |  |  | to understand the source code better. | 
					
						
							| 
									
										
										
										
											2013-08-14 15:43:35 -07:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2015-08-30 22:31:43 -07:00
										 |  |  | ## Structure of Source Code
 | 
					
						
							| 
									
										
										
										
											2013-08-14 15:43:35 -07:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2015-08-31 21:49:05 -07:00
										 |  |  | ``` | 
					
						
							|  |  |  | Electron | 
					
						
							| 
									
										
										
										
											2016-03-24 14:47:31 -07:00
										 |  |  | ├── atom - C++ source code. | 
					
						
							|  |  |  | |   ├── app - System entry code. | 
					
						
							|  |  |  | |   ├── browser - The frontend including the main window, UI, and all of the | 
					
						
							|  |  |  | |   |   main process things. This talks to the renderer to manage web pages. | 
					
						
							|  |  |  | |   |   ├── ui - Implementation of UI stuff for different platforms. | 
					
						
							|  |  |  | |   |   |   ├── cocoa - Cocoa specific source code. | 
					
						
							|  |  |  | |   |   |   ├── gtk - GTK+ specific source code. | 
					
						
							|  |  |  | |   |   |   └── win - Windows GUI 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, | 
					
						
							|  |  |  | |       including some utility functions and code to integrate node's message | 
					
						
							|  |  |  | |       loop into Chromium's message loop. | 
					
						
							|  |  |  | |       └── api - The implementation of common APIs, and foundations of | 
					
						
							|  |  |  | |           Electron's built-in modules. | 
					
						
							| 
									
										
										
										
											2015-08-31 21:49:05 -07:00
										 |  |  | ├── chromium_src - Source code that copied from Chromium. | 
					
						
							| 
									
										
										
										
											2016-03-24 14:47:31 -07:00
										 |  |  | ├── default_app - The default page to show when Electron is started without | 
					
						
							|  |  |  | |   providing an app. | 
					
						
							| 
									
										
										
										
											2015-08-31 21:49:05 -07:00
										 |  |  | ├── docs - Documentations. | 
					
						
							| 
									
										
										
										
											2016-04-22 23:30:16 +09:00
										 |  |  | ├── lib - JavaScript source code. | 
					
						
							| 
									
										
										
										
											2016-03-24 14:47:31 -07:00
										 |  |  | |   ├── 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. | 
					
						
							| 
									
										
										
										
											2015-08-31 21:49:05 -07:00
										 |  |  | ├── spec - Automatic tests. | 
					
						
							|  |  |  | ├── atom.gyp - Building rules of Electron. | 
					
						
							|  |  |  | └── common.gypi - Compiler specific settings and building rules for other | 
					
						
							|  |  |  |     components like `node` and `breakpad`. | 
					
						
							|  |  |  | ``` | 
					
						
							| 
									
										
										
										
											2013-08-14 15:43:35 -07:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2015-08-30 22:31:43 -07:00
										 |  |  | ## Structure of Other Directories
 | 
					
						
							| 
									
										
										
										
											2013-08-14 15:43:35 -07:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2014-05-04 20:15:20 +08:00
										 |  |  | * **script** - Scripts used for development purpose like building, packaging, | 
					
						
							|  |  |  |   testing, etc. | 
					
						
							|  |  |  | * **tools** - Helper scripts used by gyp files, unlike `script`, scripts put | 
					
						
							|  |  |  |   here should never be invoked by users directly. | 
					
						
							|  |  |  | * **vendor** - Source code of third party dependencies, we didn't use | 
					
						
							| 
									
										
										
										
											2015-08-30 22:31:43 -07:00
										 |  |  |   `third_party` as name because it would confuse it with the same directory in | 
					
						
							| 
									
										
										
										
											2014-05-04 20:15:20 +08:00
										 |  |  |   Chromium's source code tree. | 
					
						
							|  |  |  | * **node_modules** - Third party node modules used for building. | 
					
						
							|  |  |  | * **out** - Temporary output directory of `ninja`. | 
					
						
							| 
									
										
										
										
											2013-08-29 16:37:51 +02:00
										 |  |  | * **dist** - Temporary directory created by `script/create-dist.py` script | 
					
						
							| 
									
										
										
										
											2016-02-01 14:40:36 +05:30
										 |  |  |   when creating a distribution. | 
					
						
							| 
									
										
										
										
											2014-05-21 22:41:46 +08:00
										 |  |  | * **external_binaries** - Downloaded binaries of third-party frameworks which | 
					
						
							| 
									
										
										
										
											2015-08-30 22:31:43 -07:00
										 |  |  |   do not support building with `gyp`. | 
					
						
							| 
									
										
										
										
											2016-04-18 20:23:11 -07:00
										 |  |  | 
 | 
					
						
							|  |  |  | ## Keeping Git Submodules Up to Date
 | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | The Electron repository has a few vendored dependencies, found in the | 
					
						
							|  |  |  | [/vendor](/vendor) directory. Occasionally you might see a message like this | 
					
						
							|  |  |  | when running `git status`: | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | ```sh | 
					
						
							|  |  |  | $ git status | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | 	modified:   vendor/brightray (new commits) | 
					
						
							|  |  |  | 	modified:   vendor/node (new commits) | 
					
						
							|  |  |  | ``` | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | 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: | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | ``` | 
					
						
							|  |  |  | [alias] | 
					
						
							| 
									
										
										
										
											2016-04-19 09:46:48 -07:00
										 |  |  | 	su = submodule update --init --recursive | 
					
						
							| 
									
										
										
										
											2016-04-18 20:23:11 -07:00
										 |  |  | ``` |