From 2869c0a819b571124f4967991839359b697802b6 Mon Sep 17 00:00:00 2001 From: "joi@chromium.org" Date: Wed, 7 Sep 2011 14:14:54 +0000 Subject: [PATCH] Use precompiled headers for most large projects where the .gyp file is not a third party file. On my machine, this speeds up a full recompile of the 'chrome' target in Debug mode by about 18%. BUG=none TEST=it builds, existing tests pass Review URL: http://codereview.chromium.org/7706011 git-svn-id: http://src.chromium.org/svn/trunk/src/build@99949 4ff67af0-8c30-449e-8e8b-ad334ec8d88c --- precompile.cc | 7 ++++ precompile.h | 100 ++++++++++++++++++++++++++++++++++++++++++++ win_precompile.gypi | 20 +++++++++ 3 files changed, 127 insertions(+) create mode 100644 precompile.cc create mode 100644 precompile.h create mode 100644 win_precompile.gypi diff --git a/precompile.cc b/precompile.cc new file mode 100644 index 000000000..db1ef6dfe --- /dev/null +++ b/precompile.cc @@ -0,0 +1,7 @@ +// Copyright (c) 2011 The Chromium Authors. All rights reserved. +// Use of this source code is governed by a BSD-style license that can be +// found in the LICENSE file. + +// Precompiled header generator for Windows builds. No include is needed +// in this file as the PCH include is forced via the "Forced Include File" +// flag in the projects generated by GYP. diff --git a/precompile.h b/precompile.h new file mode 100644 index 000000000..940d7302b --- /dev/null +++ b/precompile.h @@ -0,0 +1,100 @@ +// Copyright (c) 2011 The Chromium Authors. All rights reserved. +// Use of this source code is governed by a BSD-style license that can be +// found in the LICENSE file. + +// Precompiled header for Chromium project on Windows, not used by +// other build configurations. Using precompiled headers speeds the +// build up significantly, around 1/4th on VS 2010 on an HP Z600 with 12 +// GB of memory. +// +// Numeric comments beside includes are the number of times they were +// included under src/chrome/browser on 2011/8/20, which was used as a +// baseline for deciding what to include in the PCH. It may be +// possible to tweak the speed of the build by commenting out or +// removing some of the less frequently used headers. + +#if defined(BUILD_PRECOMPILE_H_) +#error You shouldn't include the precompiled header file more than once. +#endif + +#define BUILD_PRECOMPILE_H_ + +// The Windows header needs to come before almost all the other +// Windows-specific headers. +#include + +// TODO(joi): Defines in atlbase.h cause conflicts; need to figure out +// if/how this family of headers can be included in the PCH; several +// of them are used quite frequently. +/* +#include +#include +#include +#include // 2 +#include // 2 +#include // 2 +#include // 1 +#include // 1 +#include // 2 +*/ + +#include // 2 +#include // 3 +#include // 2 +#include +#include // 2 +#include // 1 +#include // 1 +#include // 2 +#include // 1 +#include // 1 +#include // 2 +#include // 2 +#include // 2 +#include +#include // 1 +//#include TODO(joi): Caused conflicts, see if they can be resolved. +#include // 1 +#include // 4 +#include // 2 +#include // 4 +#include // 2 + +#include +#include +#include // 4 +#include +#include // 1 +#include +#include // 1 +#include +#include +#include +#include +#include // 4 + +#include +#include // 3 +#include +#include +#include // 3 +#include // 2 +#include +#include +#include // 3 +#include +#include // 2 +#include // 2 +#include +#include +#include +#include +#include // 2 +#include +#include +#include +#include +#include +#include +#include +#include diff --git a/win_precompile.gypi b/win_precompile.gypi new file mode 100644 index 000000000..90bcdff61 --- /dev/null +++ b/win_precompile.gypi @@ -0,0 +1,20 @@ +# Copyright (c) 2011 The Chromium Authors. All rights reserved. +# Use of this source code is governed by a BSD-style license that can be +# found in the LICENSE file. + +# Include this file to make targets in your .gyp use the default +# precompiled header on Windows. + +{ + 'conditions': [ + # Restricted to VS 2010 until GYP also supports suppressing + # precompiled headers on .c files in VS 2008. + ['OS=="win" and (MSVS_VERSION=="2010" or MSVS_VERSION=="2010e")', { + 'target_defaults': { + 'msvs_precompiled_header': '<(DEPTH)/build/precompile.h', + 'msvs_precompiled_source': '<(DEPTH)/build/precompile.cc', + 'sources': ['<(DEPTH)/build/precompile.cc'], + }, + }], + ], +}