add build-instructions three first

This commit is contained in:
heyunjiang 2016-03-16 11:54:33 +08:00
parent 12f218c747
commit 3eac767e72
4 changed files with 329 additions and 8 deletions

View file

@ -0,0 +1,123 @@
# Build Instructions (Linux)
遵循下面的引导,在 Linux 上构建 Electron .
## Prerequisites
* Python 2.7.x. 一些发行版如 CentOS 仍然使用 Python 2.6.x ,所以或许需要 check 你的 Python 版本,使用 `python -V`.
* Node.js v0.12.x. 有很多方法来安装 Node. 可以从 [Node.js](http://nodejs.org)下载原文件并且编译它 .也可以作为一个标准的用户在 home 目录下安装 node .或者尝试使用仓库 [NodeSource](https://nodesource.com/blog/nodejs-v012-iojs-and-the-nodesource-linux-repositories).
* Clang 3.4 或更新的版本.
* GTK+开发头文件和libnotify.
在 Ubuntu, 安装下面的库 :
```bash
$ sudo apt-get install build-essential clang libdbus-1-dev libgtk2.0-dev \
libnotify-dev libgnome-keyring-dev libgconf2-dev \
libasound2-dev libcap-dev libcups2-dev libxtst-dev \
libxss1 libnss3-dev gcc-multilib g++-multilib
```
在 Fedora, 安装下面的库 :
```bash
$ sudo yum install clang dbus-devel gtk2-devel libnotify-devel libgnome-keyring-devel \
xorg-x11-server-utils libcap-devel cups-devel libXtst-devel \
alsa-lib-devel libXrandr-devel GConf2-devel nss-devel
```
其它版本的也许提供了相似的包来安装,通过包管理器,例如 pacman.
或一个可以编译源文件的.
## 使用虚拟机
如果在虚拟机上构建 Electron你需要一个固定大小的设备至少需要 25 gigabytes .
## 获取代码
```bash
$ git clone https://github.com/atom/electron.git
```
## Bootstrapping
bootstrap 脚本也是必要下载的构建依赖,来创建项目文件.需要使用 Python 2.7.x 来让脚本成功执行.正确下载文件会花费较长的时间.
注意我们使用的是 `ninja` 来构建 Electron所以没有生成 `Makefile` 项目.
```bash
$ cd electron
$ ./script/bootstrap.py -v
```
### 交叉编译
如果想创建一个 `arm` target ,应当还要下载下面的依赖 :
```bash
$ sudo apt-get install libc6-dev-armhf-cross linux-libc-dev-armhf-cross \
g++-arm-linux-gnueabihf
```
为了编译 `arm``ia32` targets, 你应当为 `bootstrap.py` 脚本使用
`--target_arch` 参数:
```bash
$ ./script/bootstrap.py -v --target_arch=arm
```
## 构建
创建 `Release``Debug` target:
```bash
$ ./script/build.py
```
这个脚本也许会在目录 `out/R` 下创建一个巨大的可执行的 Electron . 文件大小或许会超过 1.3 gigabytes. 原因是 Release target 二进制文件包含了 调试符号 .运行 `create-dist.py` 脚本来减小文件的 size :
```bash
$ ./script/create-dist.py
```
这会在 `dist` 目录下创建一个有大量小文件的工作空间. 运行 create-dist.py 脚本之后, 或许你想删除仍然在 `out/R` 下的 1.3+ gigabyte 二进制文件.
可以只创建 `Debug` target:
```bash
$ ./script/build.py -c D
```
创建完毕, 可以在 `out/D`下面找到 `electron`.
## Cleaning
删除构建文件 :
```bash
$ ./script/clean.py
```
## 解决问题
确保你已经安装了所有的依赖 .
### Error While Loading Shared Libraries: libtinfo.so.5
预构建的 `clang` 会尝试链接到 `libtinfo.so.5`. 取决于 host 架构, 适当的使用 `libncurses`:
```bash
$ sudo ln -s /usr/lib/libncurses.so.5 /usr/lib/libtinfo.so.5
```
## Tests
测试你的修改是否符合项目代码风格,使用:
```bash
$ ./script/cpplint.py
```
测试有效性使用:
```bash
$ ./script/test.py
```

View file

@ -0,0 +1,62 @@
# Build Instructions (OS X)
遵循下面的引导,在 OS X 上构建 Electron .
## 前提
* OS X >= 10.8
* [Xcode](https://developer.apple.com/technologies/tools/) >= 5.1
* [node.js](http://nodejs.org) (外部)
如果你通过 Homebrew 使用 Python 下载,需要安装下面的 Python 模块:
* pyobjc
## 获取代码
```bash
$ git clone https://github.com/atom/electron.git
```
## Bootstrapping
bootstrap 脚本也是必要下载的构建依赖,来创建项目文件.注意我们使用的是 `ninja` 来构建 Electron所以没有生成 Xcode 项目.
```bash
$ cd electron
$ ./script/bootstrap.py -v
```
## 构建
创建 `Release``Debug` target:
```bash
$ ./script/build.py
```
可以只创建 `Debug` target:
```bash
$ ./script/build.py -c D
```
创建完毕, 可以在 `out/D` 下面找到 `Electron.app`.
## 32位支持
在 OS X 上,构建 Electron 只支持 64位的不支持 32位的 .
## 测试
测试你的修改是否符合项目代码风格,使用:
```bash
$ ./script/cpplint.py
```
测试有效性使用:
```bash
$ ./script/test.py
```

View file

@ -0,0 +1,136 @@
# Build Instructions (Windows)
遵循下面的引导,在 Windows 上构建 Electron .
## 前提
* Windows 7 / Server 2008 R2 or higher
* Visual Studio 2013 with Update 4 - [download VS 2013 Community Edition for
free](https://www.visualstudio.com/news/vs2013-community-vs).
* [Python 2.7](http://www.python.org/download/releases/2.7/)
* [Node.js](http://nodejs.org/download/)
* [Git](http://git-scm.com)
如果你现在还没有安装 Windows , [modern.ie](https://www.modern.ie/en-us/virtualization-tools#downloads) 有一个 timebombed 版本的 Windows ,你可以用它来构建 Electron.
构建 Electron 完全的依赖于命令行,并且不可通过 Visual Studio.
可以使用任何的编辑器来开发 Electron ,未来会支持 Visual Studio.
**注意:** 虽然 Visual Studio 不是用来构建的,但是它仍然
**必须的** ,因为我们需要它提供的构建工具栏.
**注意:** Visual Studio 2015 不可用. 请确定使用 MSVS
**2013**.
## 获取代码
```powershell
$ git clone https://github.com/atom/electron.git
```
## Bootstrapping
bootstrap 脚本也是必要下载的构建依赖,来创建项目文件.注意我们使用的是 `ninja` 来构建 Electron所以没有生成 Visual Studio 项目.
```powershell
$ cd electron
$ python script\bootstrap.py -v
```
## 构建
创建 `Release``Debug` target:
```powershell
$ python script\build.py
```
可以只创建 `Debug` target:
```powershell
$ python script\build.py -c D
```
创建完毕, 可以在 `out/D`(debug target) 或 `out\R` (release target) 下面找到 `electron.exe`.
## 64bit Build
为了构建64位的 target,在运行 bootstrap 脚本的时候需要使用 `--target_arch=x64` :
```powershell
$ python script\bootstrap.py -v --target_arch=x64
```
其他构建步骤完全相同.
## Tests
测试你的修改是否符合项目代码风格,使用:
```powershell
$ python script\cpplint.py
```
测试有效性使用:
```powershell
$ python script\test.py
```
在构建 debug 时为 Tests包含原生模块 (例如 `runas`) 将不会执行(详情 [#2558](https://github.com/atom/electron/issues/2558)), 但是它们在构建 release 会起效.
运行 release 构建使用 :
```powershell
$ python script\test.py -R
```
## 解决问题
### Command xxxx not found
如果你遇到了一个错误,类似 `Command xxxx not found`, 可以尝试使用 `VS2012 Command Prompt` 控制台来执行构建脚本 .
### Fatal internal compiler error: C1001
确保你已经安装了 Visual Studio 的最新安装包 .
### Assertion failed: ((handle))->activecnt >= 0
如果在 Cygwin 下构建的,你可能会看到 `bootstrap.py` 失败并且附带下面错误 :
```
Assertion failed: ((handle))->activecnt >= 0, file src\win\pipe.c, line 1430
Traceback (most recent call last):
File "script/bootstrap.py", line 87, in <module>
sys.exit(main())
File "script/bootstrap.py", line 22, in main
update_node_modules('.')
File "script/bootstrap.py", line 56, in update_node_modules
execute([NPM, 'install'])
File "/home/zcbenz/codes/raven/script/lib/util.py", line 118, in execute
raise e
subprocess.CalledProcessError: Command '['npm.cmd', 'install']' returned non-zero exit status 3
```
这是由同时使用 Cygwin Python 和 Win32 Node 造成的 bug.解决办法就是使用 Win32 Python 执行 bootstrap 脚本 (假定你已经在目录 `C:\Python27` 下安装了 Python):
```powershell
$ /cygdrive/c/Python27/python.exe script/bootstrap.py
```
### LNK1181: cannot open input file 'kernel32.lib'
重新安装 32位的 Node.js.
### Error: ENOENT, stat 'C:\Users\USERNAME\AppData\Roaming\npm'
简单创建目录 [应该可以解决问题](http://stackoverflow.com/a/25095327/102704):
```powershell
$ mkdir ~\AppData\Roaming\npm
```
### node-gyp is not recognized as an internal or external command
如果你使用 Git Bash 来构建,或许会遇到这个错误,可以使用 PowerShell 或 VS2012 Command Prompt 来代替 .

View file

@ -1,14 +1,14 @@
# Build System Overview
Electron 使用 `gyp` 来生成项目 ,使用 `ninja`编译项目. 项目配置可以在 `.gyp``.gypi` 文件中找到.
Electron 使用 `gyp` 来生成项目 ,使用 `ninja`构建项目. 项目配置可以在 `.gyp``.gypi` 文件中找到.
## Gyp 文件
下面的 `gyp` 文件包含了编译 Electron 的主要规则 :
下面的 `gyp` 文件包含了构建 Electron 的主要规则 :
* `atom.gyp` 定义了 Electron 它自己是怎样被编译的.
* `common.gypi` 调整 node 的编译配置,来让它结合 Chromium 一起编译.
* `vendor/brightray/brightray.gyp` 定义了 `brightray` 是如何被编译的,并且包含了默认配置来连接到 Chromium.
* `atom.gyp` 定义了 Electron 它自己是怎样被构建的.
* `common.gypi` 调整 node 的构建配置,来让它结合 Chromium 一起构建.
* `vendor/brightray/brightray.gyp` 定义了 `brightray` 是如何被构建的,并且包含了默认配置来连接到 Chromium.
* `vendor/brightray/brightray.gypi` 包含了常用的创建配置.
## 创建组件
@ -31,12 +31,12 @@ $ ./script/build.py -c D
## Two-Phase Project Generation
`Release``Debug` 编译的时候后Electron 链接了不同配置的库 .然而 `gyp`不支持为不同的配置文件进行不同的链接设置.
`Release``Debug` 构建的时候后Electron 链接了不同配置的库 .然而 `gyp`不支持为不同的配置文件进行不同的链接设置.
为了规避这个问题Electron 在运行 `gyp` 的时候,使用了一个 `gyp` 的变量 `libchromiumcontent_component`来控制应该使用哪个链接设置,并且只生成一个目标.
## Target Names
与大多数的项目不同,它们使用 `Release``Debug` 作为目标名字,而 Electron 使用使用的是 `R``D`.这是因为如果只定义了一个 `Release``Debug` 编译配置,`gyp` 会随机崩溃并且在同一时候Electron 只生成一个目标,如上所述.
与大多数的项目不同,它们使用 `Release``Debug` 作为目标名字,而 Electron 使用使用的是 `R``D`.这是因为如果只定义了一个 `Release``Debug` 构建配置,`gyp` 会随机崩溃并且在同一时候Electron 只生成一个目标,如上所述.
这只对开发者可用,如果想重新编译 Electron ,将不会成功.
这只对开发者可用,如果想重新构建 Electron ,将不会成功.