构建说明(Windows)

在Windows中,构建Electron

前提要求

假如需要创建一个完整发行版,则使用 symstore.exe.pdb文件中新建符号存储.

如果你现在还没有安装 Windows , modern.ie 有一个 timebombed 版本的 Windows ,你可以用它来构建 Electron.

Building Electron完全使用命令行脚本完成,您可以使用任何编辑器开发Electron,但不能使用Visual Studio完成(将来可能支持)。

注意:即使Visual Studio不用于构建,但它仍然是必须的,因为我们需要它提供的构建工具链。

获取代码

  1. $ git clone https://github.com/electron/electron.git

引导

引导脚本将下载所有必需的构建依赖项并创建构建项目文件,由于使用了 ninja进行构建,因此不存在 Visual Studio项目.

  1. $ cd electron
  2. $ python script\bootstrap.py -v

构建

创建 ReleaseDebug target:

  1. $ python script\build.py

还可以仅构建 Debug target :

  1. $ python script\build.py -c D

在构建完成后,你可以在 out\D (debug target) 或者 out\R (release target)下找到 Electron.exe .

32位系统支持

要构建32位目标,需要在运行引导脚本时传递 --target_arch=ia32参数:

  1. $ python script\bootstrap.py -v --target_arch=ia32

Visual Studio项目

要生成Visual Studio项目,可以传递 --msvs参数:

  1. $ python script\bootstrap.py --msvs

清理

清理构建文件:

  1. $ npm run clean

只清理outdist目录:

  1. $ npm run clean-build

注意:以上两个clean命令都需要在构建之前再次运行 bootstrap

相关测试

参见构建系统概述:测试

故障排除

未找到命令xxxx

遇到如 Command xxxx not found之类错误, 你可以尝试使用 VS2015命令提示控制台来执行构建脚本

致命内部编译器错误:C1001

确保您已安装最新的Visual Studio

Assertion failed: ((handle))->activecnt >= 0

如果在 Cygwin 下构建的,你可能会看到 bootstrap.py 失败并且附带下面错误 :

  1. Assertion failed: ((handle))->activecnt >= 0, file src\win\pipe.c, line 1430
  2. Traceback (most recent call last):
  3. File "script/bootstrap.py", line 87, in <module>
  4. sys.exit(main())
  5. File "script/bootstrap.py", line 22, in main
  6. update_node_modules('.')
  7. File "script/bootstrap.py", line 56, in update_node_modules
  8. execute([NPM, 'install'])
  9. File "/home/zcbenz/codes/raven/script/lib/util.py", line 118, in execute
  10. raise e
  11. subprocess.CalledProcessError: Command '['npm.cmd', 'install']' returned non-zero exit status 3

这是由同时使用 Cygwin Python 和 Win32 Node 造成的 bug.解决办法就是使用 Win32 Python 执行 引导脚本 (假设你已经在目录 C:\Python27 下安装了 Python):

  1. $ /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’

创建一个一样的目录 ,应该可以解决问题.

  1. $ mkdir ~\AppData\Roaming\npm

node-gyp is not recognized as an internal or external command

如果你使用 Git Bash 来构建,或许会遇到这个错误,可以使用 PowerShell 或 VS2015 Command Prompt 来代替 .