ninja build available on Windows

1,503 views
Skip to first unread message

Scott Graham

unread,
May 7, 2012, 7:56:49 PM5/7/12
to chromium-dev
Hi,

As of r135613, chromium can be built with ninja on Windows.

This is helpful to get faster incremental builds compared with
building in Visual Studio. Incremental linking is reliable when using
the ninja build, and so can be on by default. This improves link time
when iterating on a small set of .cc files by about 5x. You might
prefer ninja's UI also.

The ninja binary is in depot_tools, which means it's already in your path.

http://code.google.com/p/chromium/wiki/NinjaBuild#Windows has details
on how to use it. The summary is:

set GYP_GENERATORS=ninja
set GYP_DEFINES=component=shared_library incremental_chrome_dll=1
set GYP_MSVS_VERSION=2010
python build\gyp_chromium
ninja -C out\Debug chrome.exe

The ninja build isn't officially supported, but seems to work pretty
well. If you run into any problems, please don't hack around them by
modifying gyp files -- instead, ping Nico or me, and we'll fix them in
gyp or ninja.

scott


PS: tools/vim/ninja-build.vim was updated to work on Windows (a
"compile-this-file" command).

Evan Martin and Nico Weber wrote the ninja gyp generator for the other
platforms, Nico helped a lot with the Windows retargeting work, and
Evan is the original author of ninja.

Peter Kasting

unread,
May 7, 2012, 8:15:38 PM5/7/12
to sco...@chromium.org, chromium-dev
Is it possible to set up the GYP files so that hitting "build" in Visual Studio will invoke Ninja to perform the build?

Has this been tested with VS2010 Express?

PK

Scott Graham

unread,
May 7, 2012, 8:43:42 PM5/7/12
to Peter Kasting, chromium-dev
On Mon, May 7, 2012 at 5:15 PM, Peter Kasting <pkas...@chromium.org> wrote:
> Is it possible to set up the GYP files so that hitting "build" in Visual
> Studio will invoke Ninja to perform the build?

I think it'd depend what you want from the VS project. Just having a
'shell' project that lists all the files and shells to ninja to build
would be relatively easy. Having VS also be able to build (and keep
its browse information up-to-date), while building with ninja would be
harder (at least on 2008, might be more possible on 2010+). I haven't
investigated too deeply for lack of personally wanting it.

Maybe it'd work for you to add an External Tool that shells to ninja,
and use GYP_GENERATORS=msvs,ninja?

> Has this been tested with VS2010 Express?

alexeypa@ put some effort into getting that working (actually with the
compiler that's included in the Windows SDK), and I believe it's
buildable. There might be some minor env vars futzing needed though.

>
> PK

Peter Kasting

unread,
May 7, 2012, 8:45:14 PM5/7/12
to Scott Graham, chromium-dev
On Mon, May 7, 2012 at 5:43 PM, Scott Graham <sco...@chromium.org> wrote:
On Mon, May 7, 2012 at 5:15 PM, Peter Kasting <pkas...@chromium.org> wrote:
> Is it possible to set up the GYP files so that hitting "build" in Visual
> Studio will invoke Ninja to perform the build?

I think it'd depend what you want from the VS project. Just having a
'shell' project that lists all the files and shells to ninja to build
would be relatively easy. Having VS also be able to build (and keep
its browse information up-to-date), while building with ninja would be
harder (at least on 2008, might be more possible on 2010+).

In short, I don't ever want to type anything at a command line; I just want to use Visual Studio like I normally would but have builds be as fast as possible.

PK

Jeremy Apthorp

unread,
May 7, 2012, 10:14:52 PM5/7/12
to sco...@chromium.org, chromium-dev
+1000 :D


--
Chromium Developers mailing list: chromi...@chromium.org
View archives, change email options, or unsubscribe:
   http://groups.google.com/a/chromium.org/group/chromium-dev

Gregg Tavares (勤)

unread,
May 7, 2012, 10:16:21 PM5/7/12
to sco...@chromium.org, chromium-dev
U ROCK!


Scott Graham

unread,
May 7, 2012, 11:12:41 PM5/7/12
to Dominic Hamon, Peter Kasting, chromium-dev
On Mon, May 7, 2012 at 5:45 PM, Dominic Hamon <domi...@google.com> wrote:
>
> On Mon, May 7, 2012 at 5:43 PM, Scott Graham <sco...@chromium.org> wrote:
>>
>> On Mon, May 7, 2012 at 5:15 PM, Peter Kasting <pkas...@chromium.org>
>> wrote:
>> > Is it possible to set up the GYP files so that hitting "build" in Visual
>> > Studio will invoke Ninja to perform the build?
>>
>> I think it'd depend what you want from the VS project. Just having a
>> 'shell' project that lists all the files and shells to ninja to build
>> would be relatively easy. Having VS also be able to build (and keep
>> its browse information up-to-date), while building with ninja would be
>> harder (at least on 2008, might be more possible on 2010+). I haven't
>> investigated too deeply for lack of personally wanting it.
>>
>> Maybe it'd work for you to add an External Tool that shells to ninja,
>> and use GYP_GENERATORS=msvs,ninja?
>
>
> I've had success in the past creating a Makefile Project in VS and having it
> call out to external build tools. I haven't done it with GYP but have with
> other similar tech.

Yeah, that's what I meant by the shell project. I would consider it a
non-success though. :-) People inevitably want Intellisense, or Go To
Definition, or Open Document under cursor which break because the IDE
lacks the full build information.

I think Peter's case is probably best handled by setting up an
External Tool to run ninja, rebinding F7 to run that command, and
telling gyp to generate both VS and ninja build files. Drop me an
(off)line if you want to work that way and would like a hand setting
it up.


>>
>>
>> > Has this been tested with VS2010 Express?
>>
>> alexeypa@ put some effort into getting that working (actually with the
>> compiler that's included in the Windows SDK), and I believe it's
>> buildable. There might be some minor env vars futzing needed though.
>>
>> >
>> > PK
>>

Scott Graham

unread,
May 7, 2012, 11:16:26 PM5/7/12
to Dominic Hamon, Peter Kasting, chromium-dev
On Mon, May 7, 2012 at 8:15 PM, Dominic Hamon <domi...@google.com> wrote:
> By success I meant that these things all worked. See, for
> example, http://msdn.microsoft.com/en-us/library/ms173379(v=vs.80).aspx.

Aha, cool! Patches welcome in that case. :)

Alex Pakhunov

unread,
May 8, 2012, 12:14:23 PM5/8/12
to Scott Graham, Peter Kasting, chromium-dev
alexeypa@ put some effort into getting that working (actually with the
compiler that's included in the Windows SDK), and I believe it's
buildable. There might be some minor env vars futzing needed though.
Has this been tested with VS2010 Express?

It works but requires manual tweaking to get DirectX and WDK include and library paths into the environment. I'm going to fix that eventually.

Alex.

Jian Li

unread,
May 8, 2012, 4:59:23 PM5/8/12
to alex...@google.com, Scott Graham, Peter Kasting, chromium-dev
I tried to use Ninja to build on my Windows machine but it did not work. So I switched back to the old way and got the following error in VS 2008:

188>nss_ssl_util.cc
188>d:\src\chromium2\src\net/base/address_list.h(21) : error C2220: warning treated as error - no 'object' file generated
188>d:\src\chromium2\src\net/base/address_list.h(21) : warning C4275: non dll-interface class 'std::_Container_base_aux' used as base for dll-interface class 'std::_Container_base_aux_alloc_real<_Alloc>'
188>        with
188>        [
188>            _Alloc=std::allocator<net::IPEndPoint>
188>        ]
188>        C:\Program Files (x86)\Microsoft Visual Studio 9.0\VC\include\xutility(377) : see declaration of 'std::_Container_base_aux'

Anyone knows how to solve this? I did try to unset those GYP_* variables and rerun "python build\gyp_chromium" and "gclient runhooks --force", but the problem still exists even with clean build.


--

Alex Pakhunov

unread,
May 8, 2012, 5:03:53 PM5/8/12
to Jian Li, Scott Graham, Peter Kasting, chromium-dev
Anyone knows how to solve this? I did try to unset those GYP_* variables and rerun "python build\gyp_chromium" and "gclient runhooks --force", but the problem still exists even with clean build. 

Have you restarted the command line prompt window?

warning C4275: non dll-interface class 'std::_Container_base_aux' used as base for dll-interface class 'std::_Container_base_aux_alloc_real<_Alloc>'
 
The error looks like some sort of collision between component and non-component builds.

Alex. 

Jian Li

unread,
May 8, 2012, 5:28:13 PM5/8/12
to Alex Pakhunov, Scott Graham, Peter Kasting, chromium-dev
I've just restarted the command window, regenerated gyp, erased whole build directory and the same error still hit me.

Alex Pakhunov

unread,
May 8, 2012, 5:32:56 PM5/8/12
to Jian Li, Scott Graham, Peter Kasting, chromium-dev
I wonder if it is related to  http://codereview.chromium.org/10309002/?

Alex.

Szymon Jakubczak

unread,
May 8, 2012, 5:38:32 PM5/8/12
to jia...@chromium.org, Alex Pakhunov, Scott Graham, Peter Kasting, chromium-dev
I think this is my mistake. Could you edit net/base/address_list.h and
edit it as follows:
http://codereview.chromium.org/10391019/

Jian Li

unread,
May 8, 2012, 5:47:08 PM5/8/12
to Szymon Jakubczak, Alex Pakhunov, Scott Graham, Peter Kasting, chromium-dev
With your change, the build seems to work fine now, though not finished yet. Thanks for all your help.

Dominic Mazzoni

unread,
May 9, 2012, 5:03:52 PM5/9/12
to jia...@chromium.org, Szymon Jakubczak, Alex Pakhunov, Scott Graham, Peter Kasting, chromium-dev
Scott et al.:

You guys are awesome! I just upgraded to VS 2010 and got ninja working and my happiness has already improved!

Only one inconvenience - it doesn't work for me unless I use vcvarsall. Previously I was able to compile with devenv.com using a different command shell that I prefer (Console2).

Is it supposed to be used with vcvarsall? Or are there just one or two environment variables that should suffice to allow it to work from any command shell? If you happen to know what I might need other than PATH I can try to add those to my global environment - or any other suggestions are welcome.

Thanks,
- Dominic

Scott Graham

unread,
May 9, 2012, 5:15:12 PM5/9/12
to Dominic Mazzoni, jia...@chromium.org, Szymon Jakubczak, Alex Pakhunov, Peter Kasting, chromium-dev
Glad to hear you got it (mostly) working. The details of environment
setup are slightly complicated, in an attempt to be easy to use...
that's apparently failing.

ninja.bat is in depot_tools. If the compiler's not found, it attempts
to get the environment set up by running set_environment.bat that is
generated by gyp into out\Debug. Once the environment is set up, it
then prepends the real ninja binary location to PATH so that next time
you run 'ninja ...' it'll just run directly without doing the set up
(to avoid the visual noise, and it taking ~1s to run).

That applies to a VS installation. If you're using the Windows SDK
vcvarsall might be the best way though.

If that doesn't help narrow down the problem, LMK offline and we can
debug what it doesn't like about your setup.

scott
(I use Console2 too, of course! :)

Dominic Mazzoni

unread,
May 9, 2012, 6:08:11 PM5/9/12
to Scott Graham, jia...@chromium.org, Szymon Jakubczak, Alex Pakhunov, Peter Kasting, chromium-dev
FYI, chatted with Scott and got it working! The problem was that I had Visual Studio's vc\bin in my PATH already, so Ninja didn't try to set up the environment. The easiest solution was to remove it from my PATH and then everything just worked.

- Dominic

Jói Sigurðsson

unread,
May 11, 2012, 5:22:55 PM5/11/12
to sco...@chromium.org, chromium-dev
ZOMG I just touched a .cc file in base and rebuilt chrome.exe and it
took 15 seconds.

Ninja on Windows FTW!

Cheers,
Jói

Daniel Cheng

unread,
May 11, 2012, 5:29:18 PM5/11/12
to j...@chromium.org, sco...@chromium.org, chromium-dev
ninja is great!

I hit one small issue when I switched over though--during the process, I also switched from VS 2008 to VS 2010 to "make things simpler". The resulting chrome.exe ended up crashing randomly, and I /think/ it was because I forgot to add the DX SDK includes to the props files for MSVS 2010. I ended up just mapping in the platform SDK and DirectX SDK from src-internal, and everything Just Worked after that.

Daniel

Chris Hamilton

unread,
May 24, 2012, 12:47:30 PM5/24/12
to dch...@chromium.org, j...@chromium.org, sco...@chromium.org, chromium-dev
Awesome... just started with a freshly installed machine, VS2010,
ninja, and new git workflow. Happy to see everything working on
Windows.

For people that regularly use MSVS, would there be any interest in
having a ninja-msvs 'hybrid' target for gyp? That is, generate MSVS
project files, but use custom build steps to use ninja for building?

Cheers,

Chris

Jake

unread,
May 24, 2012, 12:48:56 PM5/24/12
to chr...@chromium.org, dch...@chromium.org, j...@chromium.org, sco...@chromium.org, chromium-dev
I'm definitely interested!

Ben Goodger (Google)

unread,
May 24, 2012, 12:52:00 PM5/24/12
to chr...@chromium.org, dch...@chromium.org, j...@chromium.org, sco...@chromium.org, chromium-dev
I'll leave it to others to express support for this, but one of the big benefits of this for me was explicitly avoiding having MSVS load/reload chrome.sln. At this point it's really beyond MSVS' ability to do it in a reasonable time and not get all janky.

My old workflow was:

gclient sync
task manager, end process devenv.exe
open chrome.sln
wait 5 minutes for devenv.exe to become a little responsive
open relevant files
wait 1 minute for devenv to become responsive again
do some work

Now, it's just gclient sync, open relevant files in msvs (as a text editor, or using a stub sln for chrome.exe debugging purposes). Sadly this sidesteps all the builtin completion tools, but I've ended up deciding it's just faster to work this way.

I recommend anyone who hasn't tried this, try it for a day or two.

-Ben

tomato

unread,
Nov 3, 2012, 4:50:22 AM11/3/12
to chromi...@chromium.org
I am trying to build chromium using ninja..but its failing. I am running these commands

set GYP_GENERATORS=ninja
  set GYP_DEFINES=component=shared_
library incremental_chrome_dll=1
  set GYP_MSVS_VERSION=2010
  python build\gyp_chromium
  ninja -C out\Debug chrome.exe


I am getting error:

C:\Data\Chromium\Source\chromium\src>third_party\python_26\python.exe build/gyp_
chromium
Enabled Psyco JIT.
Updating projects from gyp files...
Traceback (most recent call last):
  File "build/gyp_chromium", line 175, in <module>
    sys.exit(gyp.main(args))
  File "C:\Data\Chromium\Source\chromium\src\tools\gyp\pylib\gyp\__init__.py", l
ine 523, in main
    return gyp_main(args)
  File "C:\Data\Chromium\Source\chromium\src\tools\gyp\pylib\gyp\__init__.py", l
ine 499, in gyp_main
    options.circular_check)
  File "C:\Data\Chromium\Source\chromium\src\tools\gyp\pylib\gyp\__init__.py", l
ine 90, in Load
    for (key, val) in generator.generator_default_variables.items():
AttributeError: 'module' object has no attribute 'generator_default_variables'


Scott Graham

unread,
Nov 3, 2012, 11:21:10 PM11/3/12
to anand...@gmail.com, chromi...@chromium.org
It seems like some of your dependencies must be very out of date.

Did you run gclient sync after pulling the latest source? What
revision of Chromium and gyp are you at? (svn info in tools/gyp).

anand

unread,
Nov 3, 2012, 11:29:55 PM11/3/12
to chromi...@chromium.org, anand...@gmail.com
Here is svn info
Repository UUID: 78cadc50-ecff-11dd-a971-7dbc132099af
Revision: 1527
Node Kind: directory
Schedule: normal
Last Changed Author: sco...@chromium.org
Last Changed Rev: 1527
Last Changed Date: 2012-10-31 06:55:40 +0530 (Wed, 31 Oct 2012)

Suresh Arora

unread,
Jan 25, 2014, 3:17:30 AM1/25/14
to chromi...@chromium.org
Hi,

I m trying to compile the code with eclipse on UBUNTU 12.04... using the link": https://code.google.com/p/chromium/wiki/AndroidEclipseDev

But i m getting this error : ::
When i m trying to run the command :  GYP_GENERATORS="eclipse,${GYP_GENERATORS}" android_gyp
The error is as such ::

GYP_GENERATORS set to 'eclipse,'
Generating gyp files from GN...
Updating projects from gyp files...
Traceback (most recent call last):
  File "/home/hiddenreflex/src/build/gyp_chromium", line 384, in <module>
    sys.exit(gyp.main(args))
  File "/home/hiddenreflex/src/tools/gyp/pylib/gyp/__init__.py", line 527, in main
    return gyp_main(args)
  File "/home/hiddenreflex/src/tools/gyp/pylib/gyp/__init__.py", line 503, in gyp_main
    options.circular_check)
  File "/home/hiddenreflex/src/tools/gyp/pylib/gyp/__init__.py", line 92, in Load
    for (key, val) in generator.generator_default_variables.items():
AttributeError: 'module' object has no attribute 'generator_default_variables'

Any help .
Thanks
Reply all
Reply to author
Forward
0 new messages