Skip to content

Building node webkit

Roger Wang edited this page Oct 24, 2013 · 29 revisions

Our compilation will follow Chromium's standard, by using gclient and gyp, be sure to read following documentations before you continue, they contained required knowledge to build node-webkit.

And preview the upstream instructions for your platform, they contained important building conventions.

Prerequisite

  1. Get the Chromium depot_tools.
  2. Setup building enviroment, see Build Instructions above.

Get the Code

node-webkit is now a part of our custom Chromium, that means the way we get node-webkit is mostly the same with Chromium, following steps are indeed modified from the Get the Code.

First find a place to put our code, it will take up about 14G disk space after compilation.

To start, make an empty directory, say node-webkit, then create the .gclient file in it, its content should be:

solutions = [
   { "name"        : "src",
     "url"         : "https://github.com/zcbenz/chromium.git@origin/node",
     "deps_file"   : ".DEPS.git",
     "managed"     : True,
     "custom_deps" : {
       "src/third_party/WebKit/LayoutTests": None,
       "src/chrome_frame/tools/test/reference_build/chrome": None,
       "src/chrome_frame/tools/test/reference_build/chrome_win": None,
       "src/chrome/tools/test/reference_build/chrome": None,
       "src/chrome/tools/test/reference_build/chrome_linux": None,
       "src/chrome/tools/test/reference_build/chrome_mac": None,
       "src/chrome/tools/test/reference_build/chrome_win": None,
     },
     "safesync_url": "",
   },
]

Finally sync code under node-webkit directory (where .gclient resides), it would spend a few hours depending on your network condition:

gclient sync

Assume you store code under node-webkit folder, after all code is downloaded by gclient, our final directory architecture will be like:

node-webkit/
|-- .gclient
`-- src/
    |-- many-stuff
    |-- ...
    `-- content
        |-- ...
        `-- nw  (source code of this repo)

Note: if you're on Linux and you get any dependency errors during gclient sync (like 'nss' or 'gtk+-2.0'), run ./src/build/install-build-deps.sh, then re-run gclient sync:

cd /path/to/node-webkit
# Do this to boot strap dependencies on Linux:
gclient sync --nohooks
./src/build/install-build-deps.sh
gclient sync

If you encountered other problems, see UsingNewGit.

Extra Steps on Windows

If you're building node-webkit on Windows, you should copy DirectX SDK files into /path/to/node-webkit/src/third_party/directxsdk/files:

mkdir -p /path/to/node-webkit/src/third_party/directxsdk/files
cp -r /c/Program\ Files\ \(x86\)/Microsoft\ DirectX\ SDK\ \(June\ 2010\)/* /path/to/node-webkit/src/third_party/directxsdk/files/

This step is necessary to get some DirectX dlls files extracted, and we mentioned it here because this is not documented in Chromium's site.

Build

After the gclient sync, project files should have be prepared. If not, you should manually run:

./build/gyp_chromium content/content.gyp   (on OSX the argument '--no-circular-check' is needed)

Then you can just compile the nw target (and don't forget to build with Release mode):

  • Windows - Use ninja as described below. Currently building with Visual Studio (Open the Visual Studio solution file and build project nw under content) is reported broken.
  • Mac OS X - Use ninja as described bellow, XCode will die building node-webkit :(.
  • Linux - Run make -j4 nw BUILDTYPE=Release from the Chromium src directory.

Alternately, you can use ninja to build node-webkit, see NinjaBuild. This method is also recommended since it's very fast and easy to use. A short summary of using ninja is:

export GYP_GENERATORS='ninja'
./build/gyp_chromium content/content.gyp
ninja -C out/Release nw -j4

##Tips

  1. You can specify what project files to generate through GYP_GENERATORS. And you can export it in ~/.bashrc etc.For example, if you want to use make:
export GYP_GENERATORS='make'
./build/gyp_chromium content/content.gyp
  1. When you build on Mac, don't forget to pass --no-circular-check to generate project files:
export GYP_GENERATORS='ninja'
./build/gyp_chromium content/content.gyp --no-circular-check

Build Faster

Update to upstream

You can use gclient to update everything automatically:

cd /path-to-node-webkit
gclient sync

node-webkit's code are in 6 git repos. To keep an eye on the commits, subscribe to our dev mailing list: node-webkit-dev+subscribe@googlegroups.com .

List of node-webkit repos:

https://github.com/rogerwang/node-webkit
https://github.com/rogerwang/blink
https://github.com/zcbenz/chromium
https://github.com/rogerwang/breakpad
https://github.com/rogerwang/v8
https://github.com/rogerwang/node

Clone this wiki locally