├── .gitattributes ├── .gitignore ├── For-Developers ├── Building-NW.js.md ├── Enable-Proprietary-Codecs.md ├── README.md ├── Repositories.md └── Understanding-Crash-Dump.md ├── For-Users ├── Advanced │ ├── Autoupdates.md │ ├── Build-Flavors.md │ ├── Content-Verification.md │ ├── Customize-Menubar.md │ ├── JavaScript-Contexts-in-NW.js.md │ ├── Protect-JavaScript-Source-Code.md │ ├── Security-in-NW.js.md │ ├── Support-for-Mac-App-Store.md │ ├── Test-with-ChromeDriver.md │ ├── Transparent-Window.md │ ├── Use-Flash-Plugin.md │ ├── Use-NaCl-in-NW.js.md │ └── Use-Native-Node-Modules.md ├── Debugging-with-DevTools.md ├── FAQ.md ├── Getting-Started.md ├── Package-and-Distribute.md └── README.md ├── README.md ├── References ├── App.md ├── Changes-to-DOM.md ├── Changes-to-Node.md ├── Chrome-Extension-APIs.md ├── Clipboard.md ├── Command-Line-Options.md ├── Manifest-Format.md ├── Menu.md ├── MenuItem.md ├── README.md ├── Screen.md ├── Shell.md ├── Shortcut.md ├── Tray.md ├── Window.md └── webview-Tag.md └── demo └── img └── 00.png /.gitattributes: -------------------------------------------------------------------------------- 1 | # Auto detect text files and perform LF normalization 2 | * text=auto 3 | 4 | # Custom for Visual Studio 5 | *.cs diff=csharp 6 | 7 | # Standard to msysgit 8 | *.doc diff=astextplain 9 | *.DOC diff=astextplain 10 | *.docx diff=astextplain 11 | *.DOCX diff=astextplain 12 | *.dot diff=astextplain 13 | *.DOT diff=astextplain 14 | *.pdf diff=astextplain 15 | *.PDF diff=astextplain 16 | *.rtf diff=astextplain 17 | *.RTF diff=astextplain 18 | -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | # Windows image file caches 2 | Thumbs.db 3 | ehthumbs.db 4 | 5 | # Folder config file 6 | Desktop.ini 7 | 8 | # Recycle Bin used on file shares 9 | $RECYCLE.BIN/ 10 | 11 | # Windows Installer files 12 | *.cab 13 | *.msi 14 | *.msm 15 | *.msp 16 | 17 | # Windows shortcuts 18 | *.lnk 19 | 20 | # ========================= 21 | # Operating System Files 22 | # ========================= 23 | 24 | # OSX 25 | # ========================= 26 | 27 | .DS_Store 28 | .AppleDouble 29 | .LSOverride 30 | 31 | # Thumbnails 32 | ._* 33 | 34 | # Files that might appear in the root of a volume 35 | .DocumentRevisions-V100 36 | .fseventsd 37 | .Spotlight-V100 38 | .TemporaryItems 39 | .Trashes 40 | .VolumeIcon.icns 41 | 42 | # Directories potentially created on remote AFP share 43 | .AppleDB 44 | .AppleDesktop 45 | Network Trash Folder 46 | Temporary Items 47 | .apdisk 48 | -------------------------------------------------------------------------------- /For-Developers/Building-NW.js.md: -------------------------------------------------------------------------------- 1 | # 构建NW.js 2 | 3 | ## 构建前提 4 | 5 | NW.js的构建工具与步骤类似Chromium. 请根据平台阅读并安装 `depot_tools`和其它前提: 6 | 7 | * [Windows](https://chromium.googlesource.com/chromium/src/+/master/docs/windows_build_instructions.md) 8 | * [Mac OS X](https://chromium.googlesource.com/chromium/src/+/master/docs/mac_build_instructions.md) 9 | * [Linux](https://chromium.googlesource.com/chromium/src/+/master/docs/linux_build_instructions.md) 10 | 11 | !!! "Windows"需知: 12 | 您需要运行 `set DEPOT_TOOLS_WIN_TOOLCHAIN=0` 或在环境中设置全局变量 13 | 14 | !!! "Xcode 7"需知: 15 | 不支持Xcode 7中的SDK 10.11 . 如果您已经升级到Xcode 7,则按照[Chromium文档](https://chromium.googlesource.com/chromium/src/+/master/docs/mac_build_instructions.md)降级到Xcode 6或拷贝其他设备的Mac SDK 10.10目录: ```xcode-select -p`/Platforms/MacOSX.platform/Developer/SDKs`` 16 | 17 | ## 获取代码 18 | **第一步:** 创建用于存放Nw.js源码的目录如 `$HOME/nwjs`, 再使用下列命令生成 `.gclient` 文档: 19 | 20 | ```bash 21 | mkdir -p $HOME/nwjs 22 | cd $HOME/nwjs 23 | gclient config --name=src https://github.com/nwjs/chromium.src.git@origin/nw17 24 | ``` 25 | 26 | 您要是对运行Chromium测试没有兴趣,大可省略同步测试用例与参考构建,这样可以节省很多时间. 打开你刚生成的 `.gclient` 文档并用下文替换 `custom_deps`部分: 27 | 28 | ```python 29 | "custom_deps" : { 30 | "src/third_party/WebKit/LayoutTests": None, 31 | "src/chrome_frame/tools/test/reference_build/chrome": None, 32 | "src/chrome_frame/tools/test/reference_build/chrome_win": None, 33 | "src/chrome/tools/test/reference_build/chrome": None, 34 | "src/chrome/tools/test/reference_build/chrome_linux": None, 35 | "src/chrome/tools/test/reference_build/chrome_mac": None, 36 | "src/chrome/tools/test/reference_build/chrome_win": None, 37 | } 38 | ``` 39 | 40 | 手动复制以及检查以下资源分支: 41 | 42 | | path | repo | 43 | |:---- |:---- | 44 | | src/content/nw | https://github.com/nwjs/nw.js | 45 | | src/third_party/node-nw | https://github.com/nwjs/node | 46 | | src/v8 | https://github.com/nwjs/v8 | 47 | 48 | **第二步:** 终端中运行以下命令: 49 | 50 | ``` 51 | gclient sync --with_branch_heads 52 | ``` 53 | 54 | 该命令将会从GitHub和Google下载超过20G的内容,所以请确保网络通畅. 一旦完成,您将看到一个 `.gclient`所在目录内将生成 `src`文件夹. 55 | 56 | 57 | !!! "Linux中首次构建时"需知: 58 | 您必须运行 `gclient sync --with_branch_heads --nohooks` 和 `./build/install-build-deps.sh` 来安装Ubuntu相关依赖. 在 [Chromium 文档中](http://dev.chromium.org/developers/how-tos/get-the-code)有详细说明. 59 | 60 | ## 利用 GN 为 Chromium生成ninja构建文件 61 | 62 | ```bash 63 | cd src 64 | gn gen out/nw (切勿更改 `nw`部分的路径,如果新建也不要改变 `out`部分) 65 | ``` 66 | 67 | 官方建议的构建参数: 68 | ```bash 69 | is_debug=false 70 | is_component_ffmpeg=true 71 | target_cpu="x64" 72 | ``` 73 | 74 | 注意,`is_component_build = true` 即支持组件构建可缩短开发周期.有关GN 和 GYP 请参考[谷歌文档](https://chromium.googlesource.com/chromium/src/+/master/tools/gn/docs/cookbook.md#Variable-mappings) 75 | 76 | ## 利用 GYP 为 Node生成ninja构建文件 77 | 78 | ```bash 79 | cd src 80 | GYP_CHROMIUM_NO_ACTION=0 ./build/gyp_chromium -I third_party/node-nw/common.gypi third_party/node-nw/node.gyp 81 | ``` 82 | 83 | 或者使用以下命令完成组件构建: 84 | 85 | ```bash 86 | ./build/gyp_chromium -D component=shared_library -I third_party/node-nw/common.gypi third_party/node-nw/node.gyp 87 | ``` 88 | 89 | 如需更改Node的构建配置,则需要设置GYP_DEFINES环境变量: 90 | 91 | ### 32-bit/64-bit 构建方法 92 | 93 | * Windows 94 | - 32-bit: 默认构建 95 | - 64-bit: `set GYP_DEFINES="target_arch=x64"` 并在 `out/Debug_x64` 或 `out/Release_x64`中重新构建 96 | * Linux 97 | - 32-bit: **TODO: chroot** 98 | - 64-bit: 默认构建 99 | * Mac 100 | - 32-bit: `export GYP_DEFINES="host_arch=ia32 target_arch=ia32"` 并在 `out/Debug` 或 `out/Release` 中重新构建 101 | - 64-bit: 默认构建 102 | 103 | ## 构建nwjs 104 | 105 | 运行GN后, `out/nw`中将生成ninja构建文件. 运行以下命令则会在 `out/nw` 文件夹中生成标准NW.js二进制代码: 106 | 107 | ```bash 108 | cd src 109 | ninja -C out/nw nwjs 110 | ``` 111 | 112 | !!! "构建耗时"需知: 113 | 取决于您的机器性能,完全构建可能耗时几个小时,推荐的配置是多喝CPU>=8核,硬盘>SSD,内存>8G的PC.阅读[快速构建](#build-faster)章节可加快一些速度. 114 | 115 | 构建32/64位或者非标准构建方式 , 可以通过编辑 `out/nw/args.gn`文档并重新运行上述命令以生成二进制文件。 116 | 117 | ## 构建Node 118 | 119 | ```bash 120 | cd src 121 | ninja -C out/Release node 122 | ``` 123 | 124 | 构建Node之后 , 最后需要拷贝Node构建的二进制文件到nwjs目录中: 125 | 126 | ```bash 127 | cd src 128 | ninja -C out/nw copy_node 129 | ``` 130 | 131 | ## 构建方式 132 | 133 | * Standard: `nwjs_sdk=false` 134 | * SDK: `enable_nacl=true` 135 | 136 | 有关不同构建方式之间的区别,请参阅[对于用户目录中的构建方式](../For-Users/Advanced/Build-Flavors.md)章节 137 | 138 | ## 专有编解码器 139 | 140 | 由于许可证问题,NW.js的预构建二进制文件不支持如H.264等专有编解码器。因此你无法使用 `